diff options
Diffstat (limited to 'index.html')
-rwxr-xr-x | index.html | 40 |
1 files changed, 27 insertions, 13 deletions
@@ -125,21 +125,35 @@ | |||
125 | if(navigator.userAgent.toLowerCase().indexOf("chrome") === -1) { | 125 | if(navigator.userAgent.toLowerCase().indexOf("chrome") === -1) { |
126 | window.location = "./redirect.html"; | 126 | window.location = "./redirect.html"; |
127 | } | 127 | } |
128 | // Load the version json | 128 | window.ninjaVersion = {}; |
129 | var req = new XMLHttpRequest(); | 129 | window.ninjaVersion.ninja = {}; |
130 | req.open("GET", "versions.json"); | 130 | if (window.chrome.app.isInstalled) { |
131 | req.onreadystatechange = (function(req) { | 131 | // Ninja is running as an installed app, started via the app launcher. |
132 | return function(event) { | 132 | var info = chrome.app.getDetails(); |
133 | if (req.readyState === 4) { | 133 | if(info) { |
134 | if (req.status === 200) { | 134 | window.ninjaVersion.ninja.version = info.version; |
135 | window.ninjaVersion = JSON.parse(req.responseText); | 135 | } |
136 | } else { | 136 | } else { |
137 | console.log("Ninja version file could not be loaded"); | 137 | // Ninja is running via a bookmark/link as a hosted web application. |
138 | // Load the version json | ||
139 | var req = new XMLHttpRequest(); | ||
140 | req.open("GET", "manifest.json"); | ||
141 | req.onreadystatechange = (function(req) { | ||
142 | return function(event) { | ||
143 | if (req.readyState === 4) { | ||
144 | if (req.status === 200) { | ||
145 | var manifestInfo = JSON.parse(req.responseText); | ||
146 | if(manifestInfo) { | ||
147 | window.ninjaVersion.ninja.version = manifestInfo.version; | ||
148 | } | ||
149 | } else { | ||
150 | console.log("Ninja version file could not be loaded"); | ||
151 | } | ||
138 | } | 152 | } |
139 | } | 153 | } |
140 | } | 154 | })(req); |
141 | })(req); | 155 | req.send(); |
142 | req.send(); | 156 | } |
143 | // | 157 | // |
144 | var star = document.getElementById('star'); | 158 | var star = document.getElementById('star'); |
145 | // | 159 | // |