From c7b5edf0351d678d26b17eb5e2f995a140e209bb Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Wed, 8 Feb 2012 14:38:25 -0800 Subject: Added manifest.json, and image file required for being a packaged chrome application. Removed the old versions.json and updated the main page to detect if it is running as a chrome app and retrieve the version info from the chrome.app object. If the app is running hosted, the code will use an XHR to load the manifest.json and retrieve the version number from it directly. --- index.html | 40 +++++++++++++++++++++++++++------------- manifest.json | 25 +++++++++++++++++++++++++ ninja_icon_128.png | Bin 0 -> 8742 bytes versions.json | 8 -------- 4 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 manifest.json create mode 100644 ninja_icon_128.png delete mode 100644 versions.json diff --git a/index.html b/index.html index f3018823..53bd6605 100644 --- a/index.html +++ b/index.html @@ -172,21 +172,35 @@ if(navigator.userAgent.toLowerCase().indexOf("chrome") === -1) { window.location = "./redirect.html"; } - // Load the version json - var req = new XMLHttpRequest(); - req.open("GET", "versions.json"); - req.onreadystatechange = (function(req) { - return function(event) { - if (req.readyState === 4) { - if (req.status === 200) { - window.ninjaVersion = JSON.parse(req.responseText); - } else { - console.log("Ninja version file could not be loaded"); + window.ninjaVersion = {}; + window.ninjaVersion.ninja = {}; + if (window.chrome.app.isInstalled) { + // Ninja is running as an installed app, started via the app launcher. + var info = chrome.app.getDetails(); + if(info) { + window.ninjaVersion.ninja.version = info.version; + } + } else { + // Ninja is running via a bookmark/link as a hosted web application. + // Load the version json + var req = new XMLHttpRequest(); + req.open("GET", "manifest.json"); + req.onreadystatechange = (function(req) { + return function(event) { + if (req.readyState === 4) { + if (req.status === 200) { + var manifestInfo = JSON.parse(req.responseText); + if(manifestInfo) { + window.ninjaVersion.ninja.version = manifestInfo.version; + } + } else { + console.log("Ninja version file could not be loaded"); + } } } - } - })(req); - req.send(); + })(req); + req.send(); + } // var star = document.getElementById('star'); // diff --git a/manifest.json b/manifest.json new file mode 100644 index 00000000..12047172 --- /dev/null +++ b/manifest.json @@ -0,0 +1,25 @@ +{ + "name": "Motorola Ninja", + "description": "Motorola Ninja HTML5 Authoring Tool Pre-Alpha", + "version": "0.5.0.0", + "app": { + "launch": { + "local_path": "index.html" + } + }, + "icons": { + "128": "ninja_icon_128.png" + }, + "permissions": [ + "unlimitedStorage", + "notifications" + ], + "requirements": { + "3D": { + "features": ["css3d", "webgl"] + } + }, + "minimum_chrome_version": "16.0.0.0", + "offline_enabled": true, + "update_url": "http://tetsubo.org/go/ninjaupdate" +} \ No newline at end of file diff --git a/ninja_icon_128.png b/ninja_icon_128.png new file mode 100644 index 00000000..6f609f4a Binary files /dev/null and b/ninja_icon_128.png differ diff --git a/versions.json b/versions.json deleted file mode 100644 index 017e22ce..00000000 --- a/versions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "ninja": { - "version": "0.5.5" - }, - "montage": { - "version": "0.6.0" - } -} \ No newline at end of file -- cgit v1.2.3