<link type="text/css" href="smallscreen.css" rel="stylesheet"
media="screen and (max-width:480px)" />
header {
width: 80%;
}
@media screen and (max-width:480px) {
header {
width: 100%;
}
}
var geolocAPI = navigator.geolocation;
var opts = { timeout: 10000 };
geolocAPI.getCurrentLocation(successCallback, errorCallback, opts);
geolocAPI.watchPosition(successCallback, errorCallback, opts);
function successCallback(e){
console.log(e.coords.latitude + ", " + e.coords.longitude);
}
var ws = new WebSocket("ws://mycoolserver.com");
ws.onopen = function(e){ // communication ready }
ws.onerror = function(e){ // something wrong happened }
ws.onclose = function(e){ // communication stopped }
ws.onmessage = function(e){
// Server sent us a message!
console.log(e.data);
}
//Let's reply
ws.send("Thanks man!");
var data = new FormData();
data.append('name', 'john');
var xhr = new XMLHttpRequest();
xhr.open('POST','http://mycoolserver.com/survey/42');
xhr.send();
xhr.onload = function(e){ // result }
// LocalStorage
localStorage[name] = "John";
alert("hello, "+ localStorage.name);
// WebSQL
var db = openDatabase("myAppDB", "1.0", "books", 1024*1024);
db.transaction(function (t){
t.execuleSql("SELECT * FROM books", _, onSuccesCallback);
}
// IndexedDB var openRequest = indexedDB.open("myAppDB", 1); openRequest.onsuccess = function(e){ var db = e.result; var tx = db.transaction(["books","readwrite"]); var store = tx.objectStore('books'); //Add data store.add({title: "html5 on mobile", author: "me"}); //Get Data store.get(1)
}
var worker = new Worker("myScript.js");
//myScript is launched, you can communicate by event messages
worker.postMessage("hello script");
worker.onMessage = function(e) {
console.log(e.data);
}
<html manifest="cache.manifest">
CACHE MANIFEST
# version 2.51
img/logo.png
styles/design.css
FALLBACK:
/img/online.png /img/offline.png
NETWORK:
script/websocket.js
<div id="touchzone">This is touchable</div>
<script>
var zone = document.getElementById("touchzone");
zone.addEventListener('touchstart', function(e){});
zone.addEventListener('touchmove', function(e){
console.log(e.screenX, e.screenY);
});
</script>
npm search jquery
# Get depency in current project repository
npm install jquery
# Or, install on global system
(sudo) npm install -g jquery
npm install -g grunt
grunt clean
grunt build
grunt serve
grunt test
...