JavaScript & HTML5 - Brave New World

Robert Nyman
Robert NymanGlobal Lead for Programs & Initiatives, Web Developer Relations
JavaScript & HTML5
     Brave New World
JavaScript & HTML5 - Brave New World
“O wonder!
How many goodly creatures are there here! How
beauteous mankind is! O brave new world! That
has such people in't!”

                             - Shakespeare’s The Tempest
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
“Are you telling me that I cant away anymore
without getting deeply into Javascript?”

                                        - Developer
“That is a disaster for me! I have made a career
out of actively avoiding Javascript.”

                                         - Developer
“If I cant continue to ignore Javascript, then you
may as well amputate one of my limbs.”

                                           - Developer
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
// Variable declaration
var firstName = "Forrest";

// Function declaration
function party () {
    return "Stupid is as stupid does";
}
// If statement
if (badGrades) {
    return "Mom sleeps with teacher";
}

// Switch statement
var age = 10,
    lifeState;
switch (age) {
    case 10:
        lifeState = "Young";
        break;
    case 60:
        lifeState = "Old";
        break;
}
// Shorthand assignment
function (boxOfChocolates) {
    var life = boxOfChocolates || "Snickers bar";
}

// Ternary operators
(looking)? "I gotta find Bubba!" : "It's ok";
JavaScript & HTML5 - Brave New World
“Coercion is the practice of forcing another party
to behave in an involuntary manner”

                                          - Wikipedia
// Assignment
var happy = true;

// Equality
if (7 == "7") {
    // true
}

// Identity
if (7 === "7") {
    // false
}
// Assignment
                               rci on
                             oe
var happy = true;
                           c
// Equality        Ty pe
if (7 == "7") {
    // true
}

// Identity
if (7 === "7") {
    // false
}
// Type coercion
var sum = "5" + 6 + 7; // 567
// Prevent type coercion
var sum = parseInt("5", 10) + 6 + 7; // 18
JavaScript & HTML5 - Brave New World
// Various "false" values
var nullVal = null;
var undefinedVal = undefined;
var zeroVal = 0;
var falseVal = false;
var emptyString = "";

// All would equal false in an if-clause
if (emptyString) {
    // Would never go in here
}
JavaScript & HTML5 - Brave New World
// Self-invoking functions
(function () {
    var investment = "Lieutenant Dan got me
invested in some kind of fruit company.";
})();
JavaScript & HTML5 - Brave New World
// Scope - global or local

// Global
var quote = "I had run for 3 years, 2 months,
14 days, and 16 hours."

function () {
    // Local
    var pantherParty = "I'm sorry I had to
fight in the middle of your Black Panther
party.";

    // Global
    question = "And so, you just ran?";
}
// Global
function meetingJFK () {
    var JFKQuestion = "Congratulations, how do
you feel?";

    // Local
    function forrestReply () {
        return "I gotta pee.";
    }

    return forrestReply();
}

meetingJFK(); // I gotta pee
forrestReply(); // Error: not accessible
JavaScript & HTML5 - Brave New World
// Controlling scope
function whoAmI () {
    return this.nodeName;
}

whoAmI(); // undefined
whoAmI.call(document, "Hello"); // #document
whoAmI.apply(document.body, ["Hello", "Greetings?"]); // BODY
JavaScript & HTML5 - Brave New World
// Using arguments
function friends (friend1, friend2) {
    return friend1 + " & " + friend2;
}

// Lieutenant Dan & Bubba
friends("Lieutenant Dan", "Bubba");

// Lieutenant Dan & undefined
friends("Lieutenant Dan");
// Using the arguments collection
function friends () {
    var allFriends = [];
    for (var i=0, il=arguments.length; i<il; i++) {
        allFriends.push(arguments[i]);
    };
    return allFriends.join(" & ");
}

// Lieutenant Dan & Bubba
friends("Lieutenant Dan", "Bubba");

// Lieutenant Dan
friends("Lieutenant Dan");
JavaScript & HTML5 - Brave New World
// Extending core JavaScript objects
if (typeof Array.prototype.push === "undefined") {
    Array.prototype.push = function () {
        for (var i=0, il=arguments.length; i<il; i++) {
            this[this.length] = arguments[i];
        };
        return this;
    }
}



var locations = ["Vietnam"];
locations.push("China", "White House");
// locations = ["Vietnam", "China", "White House"];
JavaScript & HTML5 - Brave New World
// closures
function happens (what) {
    return function (verb) {
        return what + " " + verb;
    }
}

var action = happens("Shit");

action("happens"); // Shit happens
JavaScript & HTML5 - Brave New World
// closures
function happens (what) {
    return function (verb) {
        return what + " " + verb;
    }
}

var action = happens("Shit");

// Breaking it down
var action = function (verb) {
    return "Shit" + " " + verb;
};
// closures
function happens (what) {
    return function (verb) {
        return what + " " + verb;
    }
}

var action = happens("Shit");

// Breaking it down
var action = function (verb) {
    return "Shit" + " " + verb;
};
var link;
for (var i=0; i<3; i++) {
    link = document.createElement("a");
    link.innerHTML = "Link " + i;
    link.onclick = function () {
        alert("I am link " + i);
    };
    document.body.appendChild(link);
};
var link;
for (var i=0; i<3; i++) {
    link = document.createElement("a");
    link.innerHTML = "Link " + i;
    link.onclick = function (index) {
        return function () {
            alert("I am link " + index);
        };
    }(i);
    document.body.appendChild(link);
};
What is HTML5?
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Video
<video src="swedish-flag.ogv"></video>
<video src="swedish-flag.ogv" controls
  width="320" height="240">
</video>
<video controls>
  <source src="swedish-flag.mp4">
  <source src="swedish-flag.ogv">
  <p>
    Sorry, your web browser doesn't
    support the video element.
  </p>
</video>
JavaScript & HTML5 - Brave New World
<video controls>
    <source src="http://robertnyman.com/video/swedish-flag.mp4">
    <source src="http://robertnyman.com/video/swedish-flag.ogv">
    <object width="425" height="340" type="application/x-shockwave-flash"
data="http://pics.robertnyman.com/ria/ShizVidz-2010012201.swf">
         <param name="movie" value="http://pics.robertnyman.com/ria/
ShizVidz-2010012201.swf">
         <param name="allowFullScreen" value="true">
         <param name="flashVars"
value="s=ZT0xJmk9MzE5NjcyNDUwJms9UUVOdUomYT01MjU0ODc5X21uWFdIJnU9cm9iZXJ0b
nltYW4=">
    </object>
    <p>Sorry, your web browser doesn't support, well, anything...</p>
</video>
var video = document.getElementById("my-video");

 // Play/pause button
 if (video.paused || video.ended) {
     video.play();
 }
 else {
     video.pause();
 }
// Methods
video.canPlayType();
video.load();
video.pause();
video.play();
// Properties
video.paused;
video.muted;
video.autobuffer;
video.autoplay;
video.buffered; (Unimplemented)
video.bufferedBytes; (Unimplemented)
video.bufferingRate; (Unimplemented)
video.bufferingThrottled; (Unimplemented)
video.controls;
video.currentSrc;
video.currentTime;
video.defaultPlaybackRate;
video.duration;
video.ended;
video.error;
video.muted;
video.networkState;
video.paused;
video.playbackRate;
video.readyState;
video.seeking;
video.src;
video.totalBytes;
video.volume;
// Events
video.abort;
video.canplay;
video.canplaythrough;
video.canshowcurrentframe;
video.dataunavailable;
video.durationchange;
video.emptied;
video.empty;
video.ended;
video.error;
video.loadedfirstframe;
video.loadedmetadata;
video.loadstart;
video.pause;
video.play;
video.progress; (lengthComputable, loaded, total)
video.ratechange;
video.seeked;
video.seeking;
video.suspend;
video.timeupdate;
video.volumechange;
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
// Checking codec support
if (video.canPlayType('video/ogg; codecs="theora, vorbis"')) {
    video.play();
}
else {
    alert("Evil browser with only licensed codec support!");
}
Canvas
<canvas id="my-canvas" width="200" height="200">
    I am canvas
</canvas>
var canvas = document.getElementById("my-canvas"),
    context = canvas.getContext("2d");
var canvas = document.getElementById("my-canvas"),
    context = canvas.getContext("2d");

context.fillStyle = "#ffffa2";
context.fillRect(0, 0, 100, 100);
JavaScript & HTML5 - Brave New World
var canvas = document.getElementById("my-canvas"),
    context = canvas.getContext("2d");

context.fillStyle = "#ffffa2";

// Adding shadows and tilt
context.shadowOffsetX = 10;
context.shadowOffsetY = 10;
context.shadowBlur = 100;
context.shadowColor = "#000000";
context.rotate(0.05);

context.fillRect(10, 10, 100, 100);
JavaScript & HTML5 - Brave New World
var canvas = document.getElementById("my-canvas"),
    context = canvas.getContext("2d");

// Adding shadows and tilt
context.shadowOffsetX = 10;
context.shadowOffsetY = 10;
context.shadowBlur = 100;
context.shadowColor = "#000000";
context.rotate(0.05);

// Adding a little gradient
var gradient = context.createRadialGradient(90, 63, 10, 90,
63, 50);
gradient.addColorStop(0, "#ff0000");
gradient.addColorStop(1, "#000000");
context.fillStyle = gradient;

context.fillRect(10, 10, 100, 100);
JavaScript & HTML5 - Brave New World
HTML5 Canvas for Internet Explorer
                -
          explorercanvas
Geolocation
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        alert(position.coords.latitude + ", " + position.coords.longitude);
    });
}
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Web Storage
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
// sessionStorage
sessionStorage["name"] = "Robert";
alert(sessionStorage["name"]); // Robert
// localStorage
localStorage.setItem("origin", "Sweden");
alert(localStorage.origin); // Sweden
// Using JSON
var info = {
    "language" : "Bulgarian",
    "location" : "Veliko Tarnovo"
};

// Save as string
localStorage.setItem("info", JSON.stringify(info));

// Load as JSON object
alert(JSON.parse(localStorage.info));
postMessage
// Use postMessage on a window to send a message
var iframeWin = document.getElementById("da-iframe").contentWindow;
iframeWin.postMessage("Love you!", "http://robertnyman.com");
// Handle message
function displayMessage (evt) {
    var message;
    if (evt.origin !== "http://robertnyman.com") {
        message = "You are not worthy";
    }
    else {
        message = "I got " + evt.data + " from " + evt.origin;
    }
    document.getElementById("received-message").innerHTML = message;
}

// Using onmessage to receive message
if (window.addEventListener) {
    // For standards-compliant web browsers
    window.addEventListener("message", displayMessage, false);
}
else {
    window.attachEvent("onmessage", displayMessage);
}
Web Workers
var worker = new Worker("worker.js");
// Main page code
    var worker = new Worker("worker.js");

    // postMessage
    worker.postMessage(5);

    // Receive message back from Worker
    worker.onmessage = function (evt) {
        document.getElementById("worker-results").innerHTML = evt.data;
    };

    // Error handling
    worker.onerror = function (evt) {
        document.getElementById("worker-results").innerHTML = "An error
occurred";
    };
// Web Worker code
onmessage = function (evt) {
    for (var i=evt.data, il=1000001; i<il; i++) {
        postMessage(i);
    };
};
Offline Web Applications
if (window.addEventListener) {
    /*
        Works well in Firefox and Opera with the
        Work Offline option in the File menu.
        Pulling the ethernet cable doesn't seem to trigger it
    */
    window.addEventListener("online", isOnline, false);
    window.addEventListener("offline", isOffline, false);
}
else {
    /*
        Works in IE with the Work Offline option in the
        File menu and pulling the ethernet cable
    */
    document.body.ononline = isOnline;
    document.body.onoffline = isOffline;
}
// Poll the navigator.onLine property
setInterval(function () {
    console.log(navigator.onLine);
}, 1000);
<!DOCTYPE html>
<html manifest="offline.manifest">
<head>
...
CACHE MANIFEST

# VERSION 10

CACHE:
offline.html
base.css

FALLBACK:
online.css offline.css

NETWORK:
/live-updates
File API


Drag & drop
                     History

 contentEditable
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Robert Nyman
                                                              http://robertnyman.com/speaking/
                                                               http://robertnyman.com/html5/

                                                                                Twitter: @robertnyman
Pictures:

Volcano: http://www.boston.com/bigpicture/2010/04/more_from_eyjafjallajokull.html                               Overloading: http://theshadowhive.blogspot.com/2010/04/mutating-chaos-gene.html
Laptop smurf: http://www.schleich-s.de/cms_schleich/cms_bilder/detail/40263.jpg                                 Closure movie: http://www.monstersandcritics.com/dvd/news/article_1332892.php/
Computer smurf: http://www.schleich-s.com/en/wishlist/index.html?PHPSESSID=cwjpavod                             Golden_Globe_winner_Gillian_Anderson_stars_in_Closure
Swedish flag: http://www.olssonfoto.se/JAlbum/SGP%202008%20Ullevi/slides/Svenska%20flaggan.html                   Steve Ballmer: http://www.businessinsider.com/microsoft-completely-rebooted-its-mobile-strategy-yesterday-heres-
Euro Coin: http://accidentaldong.blogspot.com/2009/10/euro-uh-oh.html                                           what-you-missed-2010-2
Smurfette in car: http://www.schleich-s.com/cms_schleich/cms_bilder/detail/40265.jpg                            What is HTML5: http://www.thedvshow.com/mini-guide-html-5-for-video-producers/
Baby smurf one: http://images.esellerpro.com/13/I/106/33/baby%20A.jpg                                           Semantics: http://www.cs.cmu.edu/~tom7/csnotes/fall02/semantics.gif
Baby smurf two: http://www.arbgames.com.au/images/T/Smurf%20Baby%20With%20Teddy.jpg                             APIs: http://lonewolflibrarian.wordpress.com/2009/09/01/library-apis-09-01-09/
Most popular language: http://odetocode.com/Blogs/scott/archive/2009/03/18/signs-that-your-javascript-skills-   Progressive enhancement: http://www.flickr.com/photos/cole007/4187641210/
need-updating.aspx                                                                                              Video: http://www.roirevolution.com/blog/2009/05/make_sure_your_excluded_placements_are_actually_be.html
Sunrise: http://www.manywallpapers.com/space-wallpapers/earth/sunrise-from-space.html                           Waiting in line: http://www.roirevolution.com/blog/2009/05/
Astronaut: http://martianchronicles.wordpress.com/2009/01/23/carnival-of-space-87/                              make_sure_your_excluded_placements_are_actually_be.html
Netscape 2: http://blog.explorelearning.com/2005/12/index.html                                                  Canvas: http://www.brianbatson.com/ablankcanvas/giftlist.html
Internet Explorer 3: http://www.guidebookgallery.org/screenshots/browser                                        Geolocation: http://www.datadial.net/blog/index.php/2008/09/22/the-definitive-guide-to-website-geo-location/
Gandalf: http://web.mit.edu/kayla/Public/Backgrounds/LOTR%20Gandalf%204.JPG                                     Storage fail: http://failblog.org/2009/02/09/storage-box-fail/
Now: http://www.geekologie.com/2007/07/15-week/                                                                 Cookie monster: http://open.salon.com/blog/shiral/2009/03/25/
Axe: http://bestgamewallpapers.com/a3-the-age-of-sovereign/axe                                                  the_coveted_shiral_interview_with_kermit_and_cookie_monster
Time: http://www.mindhacks.com/blog/seeing/index.html                                                           Boy giving the finger: http://www.deangoodman.com/ThingsThatSuck.html
Money: http://www.mediabistro.com/unbeige/ideas/                                                                Postman (Costner): http://nationallampoon.com/articles/the-list-top-20-movies-about-the-end-of-the-world
Happy Ape: http://thesituationist.wordpress.com/2007/06/14/                                                     Web Workers: http://miscellanea.wellingtongrey.net/2007/06/03/this-modern-life/
High speed train: http://www.freefoto.com/preview/23-22-1?ffid=23-22-1                                           Dude offline: http://blogs.phoenixnewtimes.com/uponsun/2008/06/you_asked_for_it_dude_offline.php
Sunspider results: http://blogs.msdn.com/ie/archive/2010/03/18/the-new-javascript-engine-in-internet-           Cute dog: http://www.emmitsburg.net/humor/daily_additions/2007/mar/30.htm
explorer-9.aspx                                                                                                 Firefox: http://www.flickr.com/photos/tedion/3966234643/
Forrest Gump: http://wallpaper-s.org/36__Forrest_Gump,_1994,_Tom_Hanks,_Robin_Wright_Penn.htm                   Google Chrome: http://www.flickr.com/photos/tedion/3966233919/
Hillary Clinton & Soldier: http://confederateyankee.mu.nu/archives/154032.php                                   Safari: http://www.rapidshareindex.com/Apple-Safari-v4-0-3-Portable_284132.html
Dog (Cat): http://www.cartoonstock.com/directory/f/false_identity.asp                                           Opera: http://www.geek.com/wp-content/uploads/2009/11/Opera_512x512.png
Play with yourself: http://www.justwhatshesaid.com/?p=965                                                       Bill Gates: http://punditkitchen.com/2009/04/14/political-pictures-bill-gates-failure-windows/
Tiger Woods: http://blogs.bigadda.com/pal4868546/2010/01/                                                       Winning IE: http://cybernetnews.com/april-browser-stats-safari-triples-its-windows-market-share/
Dirty water: http://www.freefoto.com/preview/13-08-52?ffid=13-08-52                                              Internet Explorer 9: http://www.redmondpie.com/internet-explorer-9-to-be-announced-at-pdc-9140118/
Extensible table: http://www.amishshowroom.com/index.php?main_page=index&cPath=40_64                            Mila & Macaulay: http://uk.eonline.com/uberblog/b61889_mila_macaulay_home_alone.html
                                                                                                                Hearts: http://www.funonthenet.in/content/view/395/31/
JavaScript & HTML5 - Brave New World
1 of 117

Recommended

HTML5 JavaScript APIs by
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
54.8K views101 slides
Node.js in action by
Node.js in actionNode.js in action
Node.js in actionSimon Su
8.7K views38 slides
HTML,CSS Next by
HTML,CSS NextHTML,CSS Next
HTML,CSS Next지수 윤
798 views114 slides
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K by
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KThomas Fuchs
13.6K views39 slides
Forget the Web by
Forget the WebForget the Web
Forget the WebRemy Sharp
1.5K views78 slides
Web Crawling with NodeJS by
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
119.1K views17 slides

More Related Content

What's hot

HTML5: friend or foe (to Flash)? by
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
53.4K views162 slides
JavaScript APIs - The Web is the Platform - .toster conference, Moscow by
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowRobert Nyman
4.6K views73 slides
Paris js extensions by
Paris js extensionsParis js extensions
Paris js extensionserwanl
1.6K views30 slides
node.js Module Development by
node.js Module Developmentnode.js Module Development
node.js Module DevelopmentJay Harris
3.9K views149 slides
CouchDB on Android by
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
5.4K views49 slides
Progressive What Apps? by
Progressive What Apps?Progressive What Apps?
Progressive What Apps?Patrick Kettner
738 views166 slides

What's hot(20)

HTML5: friend or foe (to Flash)? by Remy Sharp
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
Remy Sharp53.4K views
JavaScript APIs - The Web is the Platform - .toster conference, Moscow by Robert Nyman
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
Robert Nyman4.6K views
Paris js extensions by erwanl
Paris js extensionsParis js extensions
Paris js extensions
erwanl1.6K views
node.js Module Development by Jay Harris
node.js Module Developmentnode.js Module Development
node.js Module Development
Jay Harris3.9K views
CouchDB on Android by Sven Haiges
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges5.4K views
History of jQuery by jeresig
History of jQueryHistory of jQuery
History of jQuery
jeresig9.9K views
HTML5 & The Open Web - at Nackademin by Robert Nyman
HTML5 & The Open Web -  at NackademinHTML5 & The Open Web -  at Nackademin
HTML5 & The Open Web - at Nackademin
Robert Nyman5.3K views
HTML5 APIs - Where no man has gone before! - Altran by Robert Nyman
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - Altran
Robert Nyman12.6K views
KISSY 的昨天、今天与明天 by tblanlan
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
tblanlan971 views
kissy-past-now-future by yiming he
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
yiming he1.1K views
Open Source Ajax Solution @OSDC.tw 2009 by Robbie Cheng
Open Source Ajax  Solution @OSDC.tw 2009Open Source Ajax  Solution @OSDC.tw 2009
Open Source Ajax Solution @OSDC.tw 2009
Robbie Cheng8.9K views
Backbone.js: Run your Application Inside The Browser by Howard Lewis Ship
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
Howard Lewis Ship2.7K views
REST with Eve and Python by PiXeL16
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL161.9K views
¿Cómo de sexy puede hacer Backbone mi código? by jaespinmora
¿Cómo de sexy puede hacer Backbone mi código?¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?
jaespinmora618 views
Praktik Pengembangan Konten E-Learning HTML5 Sederhana by Muhammad Yusuf
Praktik Pengembangan Konten E-Learning HTML5 SederhanaPraktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Muhammad Yusuf1.7K views

Similar to JavaScript & HTML5 - Brave New World

JavaScript and HTML5 - Brave New World (revised) by
JavaScript and HTML5 - Brave New World (revised)JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)Robert Nyman
15.5K views115 slides
JavaScript - Like a Box of Chocolates - jsDay by
JavaScript - Like a Box of Chocolates - jsDayJavaScript - Like a Box of Chocolates - jsDay
JavaScript - Like a Box of Chocolates - jsDayRobert Nyman
10.1K views80 slides
JavaScript - Like a Box of Chocolates by
JavaScript - Like a Box of ChocolatesJavaScript - Like a Box of Chocolates
JavaScript - Like a Box of ChocolatesRobert Nyman
8.1K views100 slides
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre! by
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!Guilherme Carreiro
224 views80 slides
Intro to Advanced JavaScript by
Intro to Advanced JavaScriptIntro to Advanced JavaScript
Intro to Advanced JavaScriptryanstout
599 views111 slides
The Beauty Of Java Script V5a by
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
899 views77 slides

Similar to JavaScript & HTML5 - Brave New World(20)

JavaScript and HTML5 - Brave New World (revised) by Robert Nyman
JavaScript and HTML5 - Brave New World (revised)JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)
Robert Nyman15.5K views
JavaScript - Like a Box of Chocolates - jsDay by Robert Nyman
JavaScript - Like a Box of Chocolates - jsDayJavaScript - Like a Box of Chocolates - jsDay
JavaScript - Like a Box of Chocolates - jsDay
Robert Nyman10.1K views
JavaScript - Like a Box of Chocolates by Robert Nyman
JavaScript - Like a Box of ChocolatesJavaScript - Like a Box of Chocolates
JavaScript - Like a Box of Chocolates
Robert Nyman8.1K views
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre! by Guilherme Carreiro
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
Guilherme Carreiro224 views
Intro to Advanced JavaScript by ryanstout
Intro to Advanced JavaScriptIntro to Advanced JavaScript
Intro to Advanced JavaScript
ryanstout599 views
The Beauty Of Java Script V5a by rajivmordani
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
rajivmordani899 views
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo by Robert Nyman
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao PauloJavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Sao Paulo
Robert Nyman27.5K views
Firefox OS learnings & visions, WebAPIs - budapest.mobile by Robert Nyman
Firefox OS learnings & visions, WebAPIs - budapest.mobileFirefox OS learnings & visions, WebAPIs - budapest.mobile
Firefox OS learnings & visions, WebAPIs - budapest.mobile
Robert Nyman2.1K views
The Open Web and what it means by Robert Nyman
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
Robert Nyman3.2K views
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile by Robert Nyman
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, ChileJavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
JavaScript APIs - The Web is the Platform - MDN Hack Day, Santiago, Chile
Robert Nyman6.2K views
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires by Robert Nyman
JavaScript APIs - The Web is the Platform - MozCamp, Buenos AiresJavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
JavaScript APIs - The Web is the Platform - MozCamp, Buenos Aires
Robert Nyman4.2K views
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo by Robert Nyman
JavaScript APIs - The Web is the Platform - MDN Hack Day, MontevideoJavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
JavaScript APIs - The Web is the Platform - MDN Hack Day, Montevideo
Robert Nyman5.3K views
Bestpractices nl by Wilfred Nas
Bestpractices nlBestpractices nl
Bestpractices nl
Wilfred Nas762 views
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires by Robert Nyman
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos AiresJavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
JavaScript APIs - The Web is the Platform - MDN Hack Day - Buenos Aires
Robert Nyman5.2K views
Node.js for PHP developers by Andrew Eddie
Node.js for PHP developersNode.js for PHP developers
Node.js for PHP developers
Andrew Eddie2.9K views
Adding ES6 to Your Developer Toolbox by Jeff Strauss
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
Jeff Strauss541 views

More from Robert Nyman

Have you tried listening? by
Have you tried listening?Have you tried listening?
Have you tried listening?Robert Nyman
14.2K views63 slides
Building for Your Next Billion - Google I/O 2017 by
Building for Your Next Billion - Google I/O 2017Building for Your Next Billion - Google I/O 2017
Building for Your Next Billion - Google I/O 2017Robert Nyman
8.6K views109 slides
Introduction to Google Daydream by
Introduction to Google DaydreamIntroduction to Google Daydream
Introduction to Google DaydreamRobert Nyman
4.1K views29 slides
Predictability for the Web by
Predictability for the WebPredictability for the Web
Predictability for the WebRobert Nyman
12K views74 slides
The Future of Progressive Web Apps - View Source conference, Berlin 2016 by
The Future of Progressive Web Apps - View Source conference, Berlin 2016The Future of Progressive Web Apps - View Source conference, Berlin 2016
The Future of Progressive Web Apps - View Source conference, Berlin 2016Robert Nyman
14.1K views122 slides
The Future of the Web - Cold Front conference 2016 by
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016Robert Nyman
13.2K views120 slides

More from Robert Nyman(20)

Have you tried listening? by Robert Nyman
Have you tried listening?Have you tried listening?
Have you tried listening?
Robert Nyman14.2K views
Building for Your Next Billion - Google I/O 2017 by Robert Nyman
Building for Your Next Billion - Google I/O 2017Building for Your Next Billion - Google I/O 2017
Building for Your Next Billion - Google I/O 2017
Robert Nyman8.6K views
Introduction to Google Daydream by Robert Nyman
Introduction to Google DaydreamIntroduction to Google Daydream
Introduction to Google Daydream
Robert Nyman4.1K views
Predictability for the Web by Robert Nyman
Predictability for the WebPredictability for the Web
Predictability for the Web
Robert Nyman12K views
The Future of Progressive Web Apps - View Source conference, Berlin 2016 by Robert Nyman
The Future of Progressive Web Apps - View Source conference, Berlin 2016The Future of Progressive Web Apps - View Source conference, Berlin 2016
The Future of Progressive Web Apps - View Source conference, Berlin 2016
Robert Nyman14.1K views
The Future of the Web - Cold Front conference 2016 by Robert Nyman
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016
Robert Nyman13.2K views
The Future of Progressive Web Apps - Google for Indonesia by Robert Nyman
The Future of Progressive Web Apps - Google for IndonesiaThe Future of Progressive Web Apps - Google for Indonesia
The Future of Progressive Web Apps - Google for Indonesia
Robert Nyman16.5K views
Google tech & products by Robert Nyman
Google tech & productsGoogle tech & products
Google tech & products
Robert Nyman16.2K views
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ... by Robert Nyman
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
Robert Nyman16.2K views
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan by Robert Nyman
Progressive Web Apps keynote, Google Developer Summit, Tokyo, JapanProgressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
Robert Nyman8.8K views
The web - What it has, what it lacks and where it must go - keynote at Riga D... by Robert Nyman
The web - What it has, what it lacks and where it must go - keynote at Riga D...The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...
Robert Nyman13.4K views
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ... by Robert Nyman
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
Robert Nyman13K views
The web - What it has, what it lacks and where it must go - Istanbul by Robert Nyman
The web - What it has, what it lacks and where it must go - IstanbulThe web - What it has, what it lacks and where it must go - Istanbul
The web - What it has, what it lacks and where it must go - Istanbul
Robert Nyman29.1K views
The web - What it has, what it lacks and where it must go by Robert Nyman
The web - What it has, what it lacks and where it must goThe web - What it has, what it lacks and where it must go
The web - What it has, what it lacks and where it must go
Robert Nyman36.2K views
Google, the future and possibilities by Robert Nyman
Google, the future and possibilitiesGoogle, the future and possibilities
Google, the future and possibilities
Robert Nyman9.1K views
Developer Relations in the Nordics by Robert Nyman
Developer Relations in the NordicsDeveloper Relations in the Nordics
Developer Relations in the Nordics
Robert Nyman3.7K views
What is Developer Relations? by Robert Nyman
What is Developer Relations?What is Developer Relations?
What is Developer Relations?
Robert Nyman7.4K views
Android TV Introduction - Stockholm Android TV meetup by Robert Nyman
Android TV Introduction - Stockholm Android TV meetupAndroid TV Introduction - Stockholm Android TV meetup
Android TV Introduction - Stockholm Android TV meetup
Robert Nyman8.1K views
New improvements for web developers - frontend.fi, Helsinki by Robert Nyman
New improvements for web developers - frontend.fi, HelsinkiNew improvements for web developers - frontend.fi, Helsinki
New improvements for web developers - frontend.fi, Helsinki
Robert Nyman7.5K views
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki by Robert Nyman
Mobile phone trends, user data & developer climate - frontend.fi, HelsinkiMobile phone trends, user data & developer climate - frontend.fi, Helsinki
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki
Robert Nyman4.4K views

Recently uploaded

Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
25 views43 slides
Business Analyst Series 2023 - Week 3 Session 5 by
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5DianaGray10
165 views20 slides
Future of Learning - Khoong Chan Meng by
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan MengNUS-ISS
31 views7 slides
.conf Go 2023 - Data analysis as a routine by
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routineSplunk
90 views12 slides
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM by
Samsung: CMM-H Tiered Memory Solution with Built-in DRAMSamsung: CMM-H Tiered Memory Solution with Built-in DRAM
Samsung: CMM-H Tiered Memory Solution with Built-in DRAMCXL Forum
105 views7 slides
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides

Recently uploaded(20)

Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman25 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10165 views
Future of Learning - Khoong Chan Meng by NUS-ISS
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan Meng
NUS-ISS31 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk90 views
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM by CXL Forum
Samsung: CMM-H Tiered Memory Solution with Built-in DRAMSamsung: CMM-H Tiered Memory Solution with Built-in DRAM
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM
CXL Forum105 views
Microchip: CXL Use Cases and Enabling Ecosystem by CXL Forum
Microchip: CXL Use Cases and Enabling EcosystemMicrochip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling Ecosystem
CXL Forum129 views
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor... by Vadym Kazulkin
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
How to reduce cold starts for Java Serverless applications in AWS at JCON Wor...
Vadym Kazulkin70 views
GigaIO: The March of Composability Onward to Memory with CXL by CXL Forum
GigaIO: The March of Composability Onward to Memory with CXLGigaIO: The March of Composability Onward to Memory with CXL
GigaIO: The March of Composability Onward to Memory with CXL
CXL Forum126 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst449 views
The Importance of Cybersecurity for Digital Transformation by NUS-ISS
The Importance of Cybersecurity for Digital TransformationThe Importance of Cybersecurity for Digital Transformation
The Importance of Cybersecurity for Digital Transformation
NUS-ISS25 views
TE Connectivity: Card Edge Interconnects by CXL Forum
TE Connectivity: Card Edge InterconnectsTE Connectivity: Card Edge Interconnects
TE Connectivity: Card Edge Interconnects
CXL Forum96 views
"How we switched to Kanban and how it integrates with product planning", Vady... by Fwdays
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays61 views
Micron CXL product and architecture update by CXL Forum
Micron CXL product and architecture updateMicron CXL product and architecture update
Micron CXL product and architecture update
CXL Forum27 views
Photowave Presentation Slides - 11.8.23.pptx by CXL Forum
Photowave Presentation Slides - 11.8.23.pptxPhotowave Presentation Slides - 11.8.23.pptx
Photowave Presentation Slides - 11.8.23.pptx
CXL Forum126 views
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure by CXL Forum
Astera Labs:  Intelligent Connectivity for Cloud and AI InfrastructureAstera Labs:  Intelligent Connectivity for Cloud and AI Infrastructure
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure
CXL Forum125 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
AMD: 4th Generation EPYC CXL Demo by CXL Forum
AMD: 4th Generation EPYC CXL DemoAMD: 4th Generation EPYC CXL Demo
AMD: 4th Generation EPYC CXL Demo
CXL Forum126 views

JavaScript & HTML5 - Brave New World

  • 1. JavaScript & HTML5 Brave New World
  • 3. “O wonder! How many goodly creatures are there here! How beauteous mankind is! O brave new world! That has such people in't!” - Shakespeare’s The Tempest
  • 18. “Are you telling me that I cant away anymore without getting deeply into Javascript?” - Developer
  • 19. “That is a disaster for me! I have made a career out of actively avoiding Javascript.” - Developer
  • 20. “If I cant continue to ignore Javascript, then you may as well amputate one of my limbs.” - Developer
  • 27. // Variable declaration var firstName = "Forrest"; // Function declaration function party () { return "Stupid is as stupid does"; }
  • 28. // If statement if (badGrades) { return "Mom sleeps with teacher"; } // Switch statement var age = 10, lifeState; switch (age) { case 10: lifeState = "Young"; break; case 60: lifeState = "Old"; break; }
  • 29. // Shorthand assignment function (boxOfChocolates) { var life = boxOfChocolates || "Snickers bar"; } // Ternary operators (looking)? "I gotta find Bubba!" : "It's ok";
  • 31. “Coercion is the practice of forcing another party to behave in an involuntary manner” - Wikipedia
  • 32. // Assignment var happy = true; // Equality if (7 == "7") { // true } // Identity if (7 === "7") { // false }
  • 33. // Assignment rci on oe var happy = true; c // Equality Ty pe if (7 == "7") { // true } // Identity if (7 === "7") { // false }
  • 34. // Type coercion var sum = "5" + 6 + 7; // 567
  • 35. // Prevent type coercion var sum = parseInt("5", 10) + 6 + 7; // 18
  • 37. // Various "false" values var nullVal = null; var undefinedVal = undefined; var zeroVal = 0; var falseVal = false; var emptyString = ""; // All would equal false in an if-clause if (emptyString) { // Would never go in here }
  • 39. // Self-invoking functions (function () { var investment = "Lieutenant Dan got me invested in some kind of fruit company."; })();
  • 41. // Scope - global or local // Global var quote = "I had run for 3 years, 2 months, 14 days, and 16 hours." function () { // Local var pantherParty = "I'm sorry I had to fight in the middle of your Black Panther party."; // Global question = "And so, you just ran?"; }
  • 42. // Global function meetingJFK () { var JFKQuestion = "Congratulations, how do you feel?"; // Local function forrestReply () { return "I gotta pee."; } return forrestReply(); } meetingJFK(); // I gotta pee forrestReply(); // Error: not accessible
  • 44. // Controlling scope function whoAmI () { return this.nodeName; } whoAmI(); // undefined whoAmI.call(document, "Hello"); // #document whoAmI.apply(document.body, ["Hello", "Greetings?"]); // BODY
  • 46. // Using arguments function friends (friend1, friend2) { return friend1 + " & " + friend2; } // Lieutenant Dan & Bubba friends("Lieutenant Dan", "Bubba"); // Lieutenant Dan & undefined friends("Lieutenant Dan");
  • 47. // Using the arguments collection function friends () { var allFriends = []; for (var i=0, il=arguments.length; i<il; i++) { allFriends.push(arguments[i]); }; return allFriends.join(" & "); } // Lieutenant Dan & Bubba friends("Lieutenant Dan", "Bubba"); // Lieutenant Dan friends("Lieutenant Dan");
  • 49. // Extending core JavaScript objects if (typeof Array.prototype.push === "undefined") { Array.prototype.push = function () { for (var i=0, il=arguments.length; i<il; i++) { this[this.length] = arguments[i]; }; return this; } } var locations = ["Vietnam"]; locations.push("China", "White House"); // locations = ["Vietnam", "China", "White House"];
  • 51. // closures function happens (what) { return function (verb) { return what + " " + verb; } } var action = happens("Shit"); action("happens"); // Shit happens
  • 53. // closures function happens (what) { return function (verb) { return what + " " + verb; } } var action = happens("Shit"); // Breaking it down var action = function (verb) { return "Shit" + " " + verb; };
  • 54. // closures function happens (what) { return function (verb) { return what + " " + verb; } } var action = happens("Shit"); // Breaking it down var action = function (verb) { return "Shit" + " " + verb; };
  • 55. var link; for (var i=0; i<3; i++) { link = document.createElement("a"); link.innerHTML = "Link " + i; link.onclick = function () { alert("I am link " + i); }; document.body.appendChild(link); };
  • 56. var link; for (var i=0; i<3; i++) { link = document.createElement("a"); link.innerHTML = "Link " + i; link.onclick = function (index) { return function () { alert("I am link " + index); }; }(i); document.body.appendChild(link); };
  • 61. Video
  • 63. <video src="swedish-flag.ogv" controls width="320" height="240"> </video>
  • 64. <video controls> <source src="swedish-flag.mp4"> <source src="swedish-flag.ogv"> <p> Sorry, your web browser doesn't support the video element. </p> </video>
  • 66. <video controls> <source src="http://robertnyman.com/video/swedish-flag.mp4"> <source src="http://robertnyman.com/video/swedish-flag.ogv"> <object width="425" height="340" type="application/x-shockwave-flash" data="http://pics.robertnyman.com/ria/ShizVidz-2010012201.swf"> <param name="movie" value="http://pics.robertnyman.com/ria/ ShizVidz-2010012201.swf"> <param name="allowFullScreen" value="true"> <param name="flashVars" value="s=ZT0xJmk9MzE5NjcyNDUwJms9UUVOdUomYT01MjU0ODc5X21uWFdIJnU9cm9iZXJ0b nltYW4="> </object> <p>Sorry, your web browser doesn't support, well, anything...</p> </video>
  • 67. var video = document.getElementById("my-video"); // Play/pause button if (video.paused || video.ended) { video.play(); } else { video.pause(); }
  • 69. // Properties video.paused; video.muted; video.autobuffer; video.autoplay; video.buffered; (Unimplemented) video.bufferedBytes; (Unimplemented) video.bufferingRate; (Unimplemented) video.bufferingThrottled; (Unimplemented) video.controls; video.currentSrc; video.currentTime; video.defaultPlaybackRate; video.duration; video.ended; video.error; video.muted; video.networkState; video.paused; video.playbackRate; video.readyState; video.seeking; video.src; video.totalBytes; video.volume;
  • 75. // Checking codec support if (video.canPlayType('video/ogg; codecs="theora, vorbis"')) { video.play(); } else { alert("Evil browser with only licensed codec support!"); }
  • 77. <canvas id="my-canvas" width="200" height="200"> I am canvas </canvas>
  • 78. var canvas = document.getElementById("my-canvas"), context = canvas.getContext("2d");
  • 79. var canvas = document.getElementById("my-canvas"), context = canvas.getContext("2d"); context.fillStyle = "#ffffa2"; context.fillRect(0, 0, 100, 100);
  • 81. var canvas = document.getElementById("my-canvas"), context = canvas.getContext("2d"); context.fillStyle = "#ffffa2"; // Adding shadows and tilt context.shadowOffsetX = 10; context.shadowOffsetY = 10; context.shadowBlur = 100; context.shadowColor = "#000000"; context.rotate(0.05); context.fillRect(10, 10, 100, 100);
  • 83. var canvas = document.getElementById("my-canvas"), context = canvas.getContext("2d"); // Adding shadows and tilt context.shadowOffsetX = 10; context.shadowOffsetY = 10; context.shadowBlur = 100; context.shadowColor = "#000000"; context.rotate(0.05); // Adding a little gradient var gradient = context.createRadialGradient(90, 63, 10, 90, 63, 50); gradient.addColorStop(0, "#ff0000"); gradient.addColorStop(1, "#000000"); context.fillStyle = gradient; context.fillRect(10, 10, 100, 100);
  • 85. HTML5 Canvas for Internet Explorer - explorercanvas
  • 87. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { alert(position.coords.latitude + ", " + position.coords.longitude); }); }
  • 93. // sessionStorage sessionStorage["name"] = "Robert"; alert(sessionStorage["name"]); // Robert
  • 95. // Using JSON var info = { "language" : "Bulgarian", "location" : "Veliko Tarnovo" }; // Save as string localStorage.setItem("info", JSON.stringify(info)); // Load as JSON object alert(JSON.parse(localStorage.info));
  • 97. // Use postMessage on a window to send a message var iframeWin = document.getElementById("da-iframe").contentWindow; iframeWin.postMessage("Love you!", "http://robertnyman.com");
  • 98. // Handle message function displayMessage (evt) { var message; if (evt.origin !== "http://robertnyman.com") { message = "You are not worthy"; } else { message = "I got " + evt.data + " from " + evt.origin; } document.getElementById("received-message").innerHTML = message; } // Using onmessage to receive message if (window.addEventListener) { // For standards-compliant web browsers window.addEventListener("message", displayMessage, false); } else { window.attachEvent("onmessage", displayMessage); }
  • 100. var worker = new Worker("worker.js");
  • 101. // Main page code var worker = new Worker("worker.js"); // postMessage worker.postMessage(5); // Receive message back from Worker worker.onmessage = function (evt) { document.getElementById("worker-results").innerHTML = evt.data; }; // Error handling worker.onerror = function (evt) { document.getElementById("worker-results").innerHTML = "An error occurred"; };
  • 102. // Web Worker code onmessage = function (evt) { for (var i=evt.data, il=1000001; i<il; i++) { postMessage(i); }; };
  • 104. if (window.addEventListener) { /* Works well in Firefox and Opera with the Work Offline option in the File menu. Pulling the ethernet cable doesn't seem to trigger it */ window.addEventListener("online", isOnline, false); window.addEventListener("offline", isOffline, false); } else { /* Works in IE with the Work Offline option in the File menu and pulling the ethernet cable */ document.body.ononline = isOnline; document.body.onoffline = isOffline; }
  • 105. // Poll the navigator.onLine property setInterval(function () { console.log(navigator.onLine); }, 1000);
  • 107. CACHE MANIFEST # VERSION 10 CACHE: offline.html base.css FALLBACK: online.css offline.css NETWORK: /live-updates
  • 108. File API Drag & drop History contentEditable
  • 116. Robert Nyman http://robertnyman.com/speaking/ http://robertnyman.com/html5/ Twitter: @robertnyman Pictures: Volcano: http://www.boston.com/bigpicture/2010/04/more_from_eyjafjallajokull.html Overloading: http://theshadowhive.blogspot.com/2010/04/mutating-chaos-gene.html Laptop smurf: http://www.schleich-s.de/cms_schleich/cms_bilder/detail/40263.jpg Closure movie: http://www.monstersandcritics.com/dvd/news/article_1332892.php/ Computer smurf: http://www.schleich-s.com/en/wishlist/index.html?PHPSESSID=cwjpavod Golden_Globe_winner_Gillian_Anderson_stars_in_Closure Swedish flag: http://www.olssonfoto.se/JAlbum/SGP%202008%20Ullevi/slides/Svenska%20flaggan.html Steve Ballmer: http://www.businessinsider.com/microsoft-completely-rebooted-its-mobile-strategy-yesterday-heres- Euro Coin: http://accidentaldong.blogspot.com/2009/10/euro-uh-oh.html what-you-missed-2010-2 Smurfette in car: http://www.schleich-s.com/cms_schleich/cms_bilder/detail/40265.jpg What is HTML5: http://www.thedvshow.com/mini-guide-html-5-for-video-producers/ Baby smurf one: http://images.esellerpro.com/13/I/106/33/baby%20A.jpg Semantics: http://www.cs.cmu.edu/~tom7/csnotes/fall02/semantics.gif Baby smurf two: http://www.arbgames.com.au/images/T/Smurf%20Baby%20With%20Teddy.jpg APIs: http://lonewolflibrarian.wordpress.com/2009/09/01/library-apis-09-01-09/ Most popular language: http://odetocode.com/Blogs/scott/archive/2009/03/18/signs-that-your-javascript-skills- Progressive enhancement: http://www.flickr.com/photos/cole007/4187641210/ need-updating.aspx Video: http://www.roirevolution.com/blog/2009/05/make_sure_your_excluded_placements_are_actually_be.html Sunrise: http://www.manywallpapers.com/space-wallpapers/earth/sunrise-from-space.html Waiting in line: http://www.roirevolution.com/blog/2009/05/ Astronaut: http://martianchronicles.wordpress.com/2009/01/23/carnival-of-space-87/ make_sure_your_excluded_placements_are_actually_be.html Netscape 2: http://blog.explorelearning.com/2005/12/index.html Canvas: http://www.brianbatson.com/ablankcanvas/giftlist.html Internet Explorer 3: http://www.guidebookgallery.org/screenshots/browser Geolocation: http://www.datadial.net/blog/index.php/2008/09/22/the-definitive-guide-to-website-geo-location/ Gandalf: http://web.mit.edu/kayla/Public/Backgrounds/LOTR%20Gandalf%204.JPG Storage fail: http://failblog.org/2009/02/09/storage-box-fail/ Now: http://www.geekologie.com/2007/07/15-week/ Cookie monster: http://open.salon.com/blog/shiral/2009/03/25/ Axe: http://bestgamewallpapers.com/a3-the-age-of-sovereign/axe the_coveted_shiral_interview_with_kermit_and_cookie_monster Time: http://www.mindhacks.com/blog/seeing/index.html Boy giving the finger: http://www.deangoodman.com/ThingsThatSuck.html Money: http://www.mediabistro.com/unbeige/ideas/ Postman (Costner): http://nationallampoon.com/articles/the-list-top-20-movies-about-the-end-of-the-world Happy Ape: http://thesituationist.wordpress.com/2007/06/14/ Web Workers: http://miscellanea.wellingtongrey.net/2007/06/03/this-modern-life/ High speed train: http://www.freefoto.com/preview/23-22-1?ffid=23-22-1 Dude offline: http://blogs.phoenixnewtimes.com/uponsun/2008/06/you_asked_for_it_dude_offline.php Sunspider results: http://blogs.msdn.com/ie/archive/2010/03/18/the-new-javascript-engine-in-internet- Cute dog: http://www.emmitsburg.net/humor/daily_additions/2007/mar/30.htm explorer-9.aspx Firefox: http://www.flickr.com/photos/tedion/3966234643/ Forrest Gump: http://wallpaper-s.org/36__Forrest_Gump,_1994,_Tom_Hanks,_Robin_Wright_Penn.htm Google Chrome: http://www.flickr.com/photos/tedion/3966233919/ Hillary Clinton & Soldier: http://confederateyankee.mu.nu/archives/154032.php Safari: http://www.rapidshareindex.com/Apple-Safari-v4-0-3-Portable_284132.html Dog (Cat): http://www.cartoonstock.com/directory/f/false_identity.asp Opera: http://www.geek.com/wp-content/uploads/2009/11/Opera_512x512.png Play with yourself: http://www.justwhatshesaid.com/?p=965 Bill Gates: http://punditkitchen.com/2009/04/14/political-pictures-bill-gates-failure-windows/ Tiger Woods: http://blogs.bigadda.com/pal4868546/2010/01/ Winning IE: http://cybernetnews.com/april-browser-stats-safari-triples-its-windows-market-share/ Dirty water: http://www.freefoto.com/preview/13-08-52?ffid=13-08-52 Internet Explorer 9: http://www.redmondpie.com/internet-explorer-9-to-be-announced-at-pdc-9140118/ Extensible table: http://www.amishshowroom.com/index.php?main_page=index&cPath=40_64 Mila & Macaulay: http://uk.eonline.com/uberblog/b61889_mila_macaulay_home_alone.html Hearts: http://www.funonthenet.in/content/view/395/31/