Mozilla Web Apps - Super-VanJS

67
Mozilla Web Apps Building apps with web technology

description

Building apps with web technology

Transcript of Mozilla Web Apps - Super-VanJS

Page 1: Mozilla Web Apps - Super-VanJS

Mozilla Web AppsBuilding apps with web technology

Page 4: Mozilla Web Apps - Super-VanJS
Page 5: Mozilla Web Apps - Super-VanJS

Mozilla is a global non-profit dedicated to putting you in control of your online experience and shaping the future of the Web for the public good

Page 7: Mozilla Web Apps - Super-VanJS
Page 8: Mozilla Web Apps - Super-VanJS

"Very emotional. But I don't like it."

Page 11: Mozilla Web Apps - Super-VanJS
Page 12: Mozilla Web Apps - Super-VanJS
Page 14: Mozilla Web Apps - Super-VanJS

Introducing Web Runtime - WebRT

Page 15: Mozilla Web Apps - Super-VanJS

Currently:

WindowsMacAndroid

Page 20: Mozilla Web Apps - Super-VanJS
Page 21: Mozilla Web Apps - Super-VanJS
Page 23: Mozilla Web Apps - Super-VanJS
Page 26: Mozilla Web Apps - Super-VanJS
Page 28: Mozilla Web Apps - Super-VanJS

Open Web technologies:

HTML5, CSS, JavaScript

A manifest file

Page 29: Mozilla Web Apps - Super-VanJS

Manifest file

Page 30: Mozilla Web Apps - Super-VanJS

{ "version": "1.0", "name": "ABBAInfo", "description": "Getting some ABBA info", "icons": { "16": "/abbainfo/images/icon-16.png", "48": "/abbainfo/images/icon-48.png", "128": "/abbainfo/images/icon-128.png" }, "developer": { "name": "Robert Nyman", "url": "http://robertnyman.com" }, "installs_allowed_from": [ "*" ], "launch_path": "/abbainfo/", "locales": { }, "default_locale": "en"}

Page 31: Mozilla Web Apps - Super-VanJS

MIME type:

application/x-web-app-manifest+json

Page 32: Mozilla Web Apps - Super-VanJS

Apache - in mime.types:

application/x-web-app-manifest+json webapp

Apache - in .htaccess:

AddType application/x-web-app-manifest+json webapp

Page 33: Mozilla Web Apps - Super-VanJS

NGinx - in mime.types:

application/x-web-app-manifest+json webapp;

Page 34: Mozilla Web Apps - Super-VanJS

IIS:

In IIS Manager, right-click the local computer, and click Properties.

Click the MIME Types button.

Click New.

In the Extension box, type the file name extension.

In the MIME type box, type a description that exactly matches the file type defined on the computer.

Click OK.

Page 35: Mozilla Web Apps - Super-VanJS

curl -I http://localhost/abbainfo/manifest.webapp

Page 36: Mozilla Web Apps - Super-VanJS

Installing a Web App

Page 37: Mozilla Web Apps - Super-VanJS

navigator.mozApps.install( URLToManifestFile, installData, sucessCallback, errorCallback);

Page 38: Mozilla Web Apps - Super-VanJS

var mozApps = navigator.mozApps;if (mozApps) { navigator.mozApps.install( "http://localhost/abbainfo/manifest.webapp", { "userID": "Robocop" }, function () { console.log("Worked!"); console.log(result); }, function (result) { console.log("Failed :-("); console.log(result); } );}

Page 39: Mozilla Web Apps - Super-VanJS

Errors

denied: permissionDenied: manifestURLError: networkError: manifestParseError:invalidManifest:

User refuses to install the appSite is not allowed to trigger the installationURL to the manifest is malformedapp host is unreachablemanifest contains syntax errorsmanifest contains semantic errors

Page 40: Mozilla Web Apps - Super-VanJS

Content

Page 41: Mozilla Web Apps - Super-VanJS

<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>ABBAInfo</title> <link rel="stylesheet" href="css/base.css" type="text/css" media="screen"> </head>

<body>

<div id="container"> ABBA </div>

<script type="text/javascript"> (function () { // Press the R key to reload the page window.addEventListener("keydown", function (evt) { if (evt.keyCode === 82) { location.reload(); } }, false); })(); </script>

</body></html>

Page 42: Mozilla Web Apps - Super-VanJS

offline & localStorage

Page 43: Mozilla Web Apps - Super-VanJS

sessionStorage.setItem("Swedes", "Sedins");console.log(sessionStorage.getItem("Swedes"));

Page 44: Mozilla Web Apps - Super-VanJS

localStorage.setItem("Bryan Adams", "Musician");

Page 45: Mozilla Web Apps - Super-VanJS

var ryanReynolds = { "startedIn" : "Hillside", "movie" : "Green Lantern"};

localStorage.setItem("ryanReynolds", JSON.stringify(anthonyWeiner));

console.log(typeof JSON.parse(localStorage.getItem("ryanReynolds")));

Page 46: Mozilla Web Apps - Super-VanJS

<!DOCTYPE html><html manifest="offline.appcache"><head>...

Page 47: Mozilla Web Apps - Super-VanJS

CACHE MANIFEST

# VERSION 10

CACHE:offline.htmlbase.css

FALLBACK:online.css offline.css

NETWORK:/live-updates

Page 48: Mozilla Web Apps - Super-VanJS

IndexedDB

Page 49: Mozilla Web Apps - Super-VanJS

var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB;

var request = indexedDB.open("ABBADatabase");

Page 50: Mozilla Web Apps - Super-VanJS

var request = indexedDB.open("ABBADatabase", 2), customerData = [ {ssn: "444-44-4444", name: "Bill", age: 35, email: "[email protected]"}, {ssn: "555-55-5555", name: "Donna", age: 32, email: "[email protected]"} ]; request.onerror = function(event) { // Handle errors.};

request.onupgradeneeded = function(event) var objectStore = db.createObjectStore("customers", { keyPath: "ssn"} );

objectStore.createIndex("name", "name", { unique: false });

objectStore.createIndex("email", "email", { unique: true } );

for (var i in customerData) { objectStore.add(customerData[i]); }};

Page 51: Mozilla Web Apps - Super-VanJS

Fullscreen

Page 52: Mozilla Web Apps - Super-VanJS

<button id="view-fullscreen">Fullscreen</button>

<script type="text/javascript">(function () { var viewFullScreen = document.getElementById("view-fullscreen"); if (viewFullScreen) { viewFullScreen.addEventListener("click", function () { var docElm = document.documentElement; if (docElm.mozRequestFullScreen) { docElm.mozRequestFullScreen(); } else if (docElm.webkitRequestFullScreen) { docElm.webkitRequestFullScreen(); } }, false); }})(); </script>

Page 53: Mozilla Web Apps - Super-VanJS

mozRequestFullScreenWithKeys?

Page 54: Mozilla Web Apps - Super-VanJS

html:-moz-full-screen { background: red;}

html:-webkit-full-screen { background: red;}

Page 55: Mozilla Web Apps - Super-VanJS
Page 56: Mozilla Web Apps - Super-VanJS
Page 58: Mozilla Web Apps - Super-VanJS

https://apps-preview.mozilla.org/

Page 59: Mozilla Web Apps - Super-VanJS
Page 62: Mozilla Web Apps - Super-VanJS
Page 63: Mozilla Web Apps - Super-VanJS
Page 65: Mozilla Web Apps - Super-VanJS

irc.mozilla.org

#openwebapps

Page 66: Mozilla Web Apps - Super-VanJS

Try new things

Page 67: Mozilla Web Apps - Super-VanJS

Robert [email protected]: @robertnyman

robertnyman.com/speaking/robertnyman.com/html5/robertnyman.com/css3/