|
a |
|
b/compass-app/plugins/org.apache.cordova.splashscreen/test/cordova-incl.js |
|
|
1 |
/*
|
|
|
2 |
*
|
|
|
3 |
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
4 |
* or more contributor license agreements. See the NOTICE file
|
|
|
5 |
* distributed with this work for additional information
|
|
|
6 |
* regarding copyright ownership. The ASF licenses this file
|
|
|
7 |
* to you under the Apache License, Version 2.0 (the
|
|
|
8 |
* "License"); you may not use this file except in compliance
|
|
|
9 |
* with the License. You may obtain a copy of the License at
|
|
|
10 |
*
|
|
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
12 |
*
|
|
|
13 |
* Unless required by applicable law or agreed to in writing,
|
|
|
14 |
* software distributed under the License is distributed on an
|
|
|
15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
16 |
* KIND, either express or implied. See the License for the
|
|
|
17 |
* specific language governing permissions and limitations
|
|
|
18 |
* under the License.
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
var PLAT;
|
|
|
23 |
if (/cordova-amazon-fireos/.exec(navigator.userAgent)) {
|
|
|
24 |
PLAT = 'amazon-fireos';
|
|
|
25 |
} else if (/Android/.exec(navigator.userAgent)) {
|
|
|
26 |
PLAT = 'android';
|
|
|
27 |
} else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) {
|
|
|
28 |
PLAT = 'ios';
|
|
|
29 |
} else if (/(BB10)|(PlayBook)|(BlackBerry)/.exec(navigator.userAgent)) {
|
|
|
30 |
PLAT = 'blackberry';
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
var scripts = document.getElementsByTagName('script');
|
|
|
34 |
var currentPath = scripts[scripts.length - 1].src;
|
|
|
35 |
var platformCordovaPath = currentPath.replace("cordova-incl.js", "cordova." + PLAT + ".js");
|
|
|
36 |
var normalCordovaPath = currentPath.replace("cordova-incl.js", "cordova.js");
|
|
|
37 |
var cordovaPath = normalCordovaPath;
|
|
|
38 |
|
|
|
39 |
if (PLAT) {
|
|
|
40 |
// XHR to local file is an error on some platforms, windowsphone for one
|
|
|
41 |
try {
|
|
|
42 |
var xhr = new XMLHttpRequest();
|
|
|
43 |
xhr.open("GET", platformCordovaPath, false);
|
|
|
44 |
xhr.onreadystatechange = function() {
|
|
|
45 |
|
|
|
46 |
if (this.readyState == this.DONE && this.responseText.length > 0) {
|
|
|
47 |
if(parseInt(this.status) >= 400){
|
|
|
48 |
cordovaPath = normalCordovaPath;
|
|
|
49 |
}else{
|
|
|
50 |
cordovaPath = platformCordovaPath;
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
};
|
|
|
54 |
xhr.send(null);
|
|
|
55 |
}
|
|
|
56 |
catch(e){
|
|
|
57 |
cordovaPath = normalCordovaPath;
|
|
|
58 |
} // access denied!
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
if (!window._doNotWriteCordovaScript) {
|
|
|
62 |
document.write('<script type="text/javascript" charset="utf-8" src="' + cordovaPath + '"></script>');
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
function backHome() {
|
|
|
66 |
if (window.device && device.platform && (device.platform.toLowerCase() == 'android' || device.platform.toLowerCase() == 'amazon-fireos')) {
|
|
|
67 |
navigator.app.backHistory();
|
|
|
68 |
}
|
|
|
69 |
else {
|
|
|
70 |
window.history.go(-1);
|
|
|
71 |
}
|
|
|
72 |
}
|