add an EPAPI update checker (experimental)

This commit is contained in:
Astra 2018-04-24 22:51:36 -04:00
parent ed2dc53d8e
commit 0cac2ac2b8
1 changed files with 42 additions and 1 deletions

View File

@ -29,7 +29,7 @@
.then(x => x.json())
.then(r => __goodies = r);
}
// Fetch goodies now and every half hour
fetchGoodies();
setInterval(fetchGoodies, 1800000);
@ -110,6 +110,47 @@
}
);
// check for epapi updates
(function () {
// fetch the latest build of epapi
fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now()).then(x => x.text()).then(x => {
// check the version
if (kparse(x).version > $api.version) {
// if the version on the server is newer, pester the user
$api.ui.showDialog({
title: 'EndPwn3: EPAPI Update Available',
body: 'An update to EPAPI has been released. It is recommended that you restart your client in order to gain access to new features and maintain compatibility.',
confirmText: 'Restart Now', cancelText: 'Later',
// user pressed "Restart Now"
onConfirm: () => {
// refresh the page if we're running in a browser, reboot the app if we're running outside of lite mode
if ($api.lite) location.reload();
else reload();
},
// they pressed "Later", for some reason
onCancel: () => {
// bother them again in 6 hrs (* 60 min * 60 sec * 1000 ms)
setTimeout(arguments.callee, 6 * 60 * 60 * 1000);
}
});
}
});
})();
});
})();