move version checking code into its own folder and file

This commit is contained in:
Jon Heller
2015-10-19 01:22:00 -04:00
parent e35c9e9fc5
commit 07ec697e2c
3 changed files with 33 additions and 15 deletions

31
js/version/version.js Normal file
View File

@@ -0,0 +1,31 @@
var version = {
updateInterval: 3000,
intervalId: null
}
version.checkVersion = function () {
$.ajax({
type: 'GET',
url: 'githash.php',
success: function (data) {
// The githash variable is located in index.php
if (data && data.gitHash !== gitHash) {
window.location.reload();
window.location.href = window.location.href;
}
},
error: function () {
}
});
}
version.init = function () {
this.intervalId = setInterval(function () {
this.checkVersion();
}.bind(this), this.updateInterval);
}