Dan Scott (dscott@laurentian.ca)
Associate Librarian, Chair of the Library & Archives, Systems Librarian, …
March 21, 2017
Thank you ECMA TC 39!
var flavours = ['orange', 'lemon'];
var styles = ['ice cream', 'sherbet'];
flavours.forEach(function(flavour) {
for (let style of styles) {
console.log(flavour + ' ' + style);
}
});
querySelector()
until IE9[1]1. In programming, a collection of routines stored in a file. Each set of instructions in a library has a name, and each performs a different task.
2. A collection of software or data files. Microsoft Computer Dictionary. (2002). Redmond, WA: Microsoft Press.
Prototype takes the complexity out of client-side web programming. Built to solve real-world problems, it adds useful extensions to the browser scripting environment and provides elegant APIs around the clumsy interfaces of Ajax and the Document Object Model. http://prototypejs.org/
Originally developed with Ruby on Rails
$()
for selecting elements by ID!$$()
for CSS selector syntax!Ajax.Request
for cross-browser Ajax!$('itemId').hide();
$('div img.loading').hide();
new Ajax.Request('/some_url', {
method:'get',
onSuccess: function(transport) {
alert("Success!\n\n" + transport.responseText || "no text");
},
onFailure: function() { alert('Something went wrong...'); }
});
UI library that builds on Prototype.js
<html>
element gets a class
attribute of (no-)feature-name
for each feature
<html class="gamepads video webgl no-emoji">
Modernizr
object
if (Modernizr.awesomeNewFeature) {
showOffAwesomeNewFeature();
} else {
getTheOldLameExperience();
}
The Dojo Toolkit began in 2004 by a group of like-minded JavaScript engineers that were tired of reinventing the wheel and hacking around browser inconsistencies. https://dojotoolkit.org/community/roadmap/vision.html
in "modern" Dojo, if you are about to access something in the global namespace STOP because you are doing something wrong https://dojotoolkit.org/documentation/tutorials/1.10/modern_dojo/index.html
dojo/dom
for selecting elements by ID!dojo/query
for CSS selector syntax!dojo/request
for cross-browser Ajax!require(["dojo/dom", "dojo/domReady!"], function(dom){
dom.byId("helloworld").innerHTML = "Hello New World!";
});
require(["dojo/query", "dojo/dom", "dojo/domReady!"],
function (query, dom) {
// retrieve an array of nodes with the ID "list"
var list = query("#list")[0];
}
)
require(["dojo/request"], function(request){
request.get("/some_url", {
data: { id: 123 },
// The type of data we expect back
handleAs: "json"
}).then(function(response){
console.log("response:", response);
}, function(err){
console.log("error:", err);
});
});
Originally developed by John Resig
$()
for selecting elements by CSS selector$.ajax
for cross-browser Ajax!
$('#itemId').hide("slow");
$('body').innerHtml =
"<h1>Good news, everyone!</h1>";
$.ajax({
url: "/some_url",
type: "GET",
data: { id: 123 },
dataType : "json",
}).done(function(response) {
console.log("response:", response);
}).fail(function(xhr, status, err) {
console.log("Error: " + err);
console.dir(xhr);
}).always(function(xhr, status) {
console.log("The request is complete!");
});
UI library that builds on jQuery
a touch-optimized HTML5 UI framework designed to make responsive web sites and apps that are accessible on all smartphone, tablet and desktop devices http://view.jquerymobile.com/master/demos/
"for modern browsers and touch devices. No jQuery."
http://rubaxa.github.io/Sortable/
"an easy to use, lightweight, 3D library"
https://github.com/mrdoob/three.js/
"A web framework for building virtual reality experiences"
https://aframe.io/
And I'm famous!
F12
or CTRL-Shift-i
and select Consoleconsole.error()
, console.info()
, console.log()
alert(2 + 2);
1 == "1";
1 === "1";
// Manipulate browser history
window.history.back();
// Change the browser URL
window.location.href = 'https://laurentian.ca';
function be_john_malkovich() {
// image via https://www.flickr.com/photos/vhf/4058845635
let malkovich = 'https://goo.gl/uYmCUg';
document.querySelectorAll('img').forEach(
function(el) {
el.src = malkovich;
});
}
F12
or CTRL-Shift-i
and select Network
F12
or CTRL-Shift-i
and select Debugger (Firefox)
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License