App cache
Storage
navigator online check
<script type='text/javascript'> var statusElem = document.getElementById('status') setInterval(function () { statusElem.className = navigator.onLine ? 'online' : 'offline'; statusElem.innerHTML = navigator.onLine ? 'online' : 'offline'; }, 250); </script>
<script type='text/javascript'> window.requestFileSystem( TEMPORARY, // persistent vs. temporary storage 1024 * 1024, // size (bytes) of needed space initFs, // success callback opt_errorHandler // opt. error callback, denial of access ); </script>
var xhr = new XMLHttpRequest(); xhr.open('GET', '/path/to/image.png', true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { }; xhr.send();
var xhr = new XMLHttpRequest(); xhr.open('GET', '/path/to/image.png', true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) { }, onError); }; xhr.send();
var xhr = new XMLHttpRequest(); xhr.open('GET', '/path/to/image.png', true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) { fs.root.getFile('image.png', {create: true}, function(fileEntry) { }, onError); }, onError); }; xhr.send();
var xhr = new XMLHttpRequest(); xhr.open('GET', '/path/to/image.png', true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { window.requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) { fs.root.getFile('image.png', {create: true}, function(fileEntry) { fileEntry.createWriter(function(writer) { writer.onwriteend = function(e) { ... }; writer.onerror = function(e) { ... }; writer.write(new Blob([xhr.response], {type: 'image/png'})); }, onError); }, onError); }, onError); }; xhr.send();
<script type='text/javascript'> var ctx = new window.AudioContext(); function playSound(arrBuff) { // Obtain arrBuffer from XHR var src = ctx.createBufferSource(); src.buffer = ctx.createBuffer(arrBuff, false /*mix2Mono*/); src.looping = true; src.connect(ctx.destination); src.noteOn(0); // Play immediately. } </script>
<script type='text/javascript' id="worker1" type="javascript/worker"> // This script won't be parsed by JS engines // because its type is javascript/worker. self.onmessage = function(e) { self.postMessage('msg from worker'); }; // Rest of your worker code goes here. </script>
<script type='text/javascript'> var blob = new Blob([document.querySelector('#worker1').textContent]); var worker = new Worker(window.URL.createObjectURL(blob)); worker.onmessage = function(e) { log("Received: " + e.data); } function sayHI() { worker.postMessage({'cmd': 'start', 'msg': 'Hi'}); } </script>
Daniel Kurka