forked from christi3k/browser-pairs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.js
38 lines (37 loc) · 1.29 KB
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Install app
if (navigator.mozApps) {
var checkIfInstalled = navigator.mozApps.getSelf();
checkIfInstalled.onsuccess = function () {
if (checkIfInstalled.result) {
// Already installed
var installationInstructions = document.querySelector("#installation-instructions");
if (installationInstructions) {
installationInstructions.style.display = "none";
}
}
else {
var install = document.querySelector("#install"),
manifestURL = location.href.substring(0, location.href.lastIndexOf("/")) + "/manifest.webapp";
install.className = "button visible";
install.onclick = function () {
var installApp = navigator.mozApps.install(manifestURL);
installApp.onsuccess = function(data) {
install.style.display = "none";
};
installApp.onerror = function() {
alert("Install failed\n\n:" + installApp.error.name);
};
};
}
};
}
else {
console.log("Open Web Apps not supported");
}
// Reload content
var reload = document.querySelector("#reload");
if (reload) {
reload.onclick = function () {
location.reload(true);
};
}