JavaScript APIs HTMLs
JavaScript APIs HTMLs
HTML5
Remy Sharp @rem standards.next
JavaScript APIs
HTML5 & friends!
Remy Sharp @rem standards.next
HTML5: 2022?
Bollocks.
APIs
Canvas Drag & Drop History Inline Editing Messaging Offline Apps Video & Audio Geolocation Local Storage Selectors Server Events Web Sockets Workers
APIs
Canvas Drag & Drop History Inline Editing Messaging Offline Apps Video & Audio Geolocation Local Storage Selectors Server Events Web Sockets Workers
APIs
Canvas Drag & Drop History Inline Editing Messaging Offline Apps Video & Audio Geolocation Local Storage Selectors Server Events Web Sockets Workers
APIs
Canvas Drag & Drop History Inline Editing Messaging Offline Apps Video & Audio Geolocation Local Storage Selectors Server Events Web Sockets Workers
APIs
Canvas Drag & Drop? History Inline Editing Messaging Offline Apps Video & Audio Geolocation Local Storage Selectors Server Events Web Sockets Workers
Documentation
Canvas
Canvas
document.querySelector('canvas').getContext("2d")
http://tr.im/pRkz
document.querySelector('canvas').getContext("2d")
http://tr.im/pRkz
Drag'n Drop
Drag'n Drop
<div draggable="true">drag me</div> <script> document.querySelector('div').addEventListener( "dragstart", function (e) { e.dataTransfer.setData("arbitrary","data"); return true; }, true); </script>
???
http://html5demos.com/drag
http://html5demos.com/drag
Of fline Applications
Of fline Applications
Of fline Apps
Application cache Events: offline, online navigator.onLine property
Enable
<html manifest="my.manifest" >
my.manifest
CACHE MANIFEST images/shade.jpg images/bin.jpg
Cache
First line: CACHE MANIFEST Requires text/cache-manifest Recommend using versioning window.applicationCache
Cache
On load will hit my.manifest
Cache
On load will hit my.manifest Change manifest: trigger reload
Cache
On load will hit my.manifest Change manifest: trigger reload applicationCache.update() force
Cache
On load will hit my.manifest Change manifest: trigger reload applicationCache.update() force Cache events
Firefox
function online() { if (navigator.onLine == false) { // gone offline } else { // else we're online } }
http://html5demos.com/ofine
http://html5demos.com/ofine
navigator.onLine
Geolocation
Geolocation
Messaging
Messaging
Messaging
Communicate across domains Across window object With Workers String transfer only
.postMessage(str) .onMessage(event)
event.data == str
Cross Domain
document .getElementById("iframe") .contentWindow .postMessage("my message");
The Catcher
window.addEventListener( "message", function(e){ if (e.origin !== "http://example.com") { return; } alert(e.origin + " said: " + e.data); }, false );
Web Workers
Web Workers
Threads
Without
http://html5demos.com/worker
Storage
Storage
1. sessionStorage
1. sessionStorage 2. localStorage
Storage
sessionStorage.setItem(key, value)
sessionStorage.getItem(key)
Storage
localStorage.setItem(key, value)
localStorage.getItem(key)
And more!
Remy Sharp
@rem remy@leftlogic.com html5demos.com remysharp.com full-frontal.org