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 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'index.html') 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'); // -- cgit v1.2.3