mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
move version checking code into its own folder and file
This commit is contained in:
parent
e35c9e9fc5
commit
07ec697e2c
@ -27,6 +27,7 @@
|
|||||||
<script src="js/moment-with-locales.min.js"></script>
|
<script src="js/moment-with-locales.min.js"></script>
|
||||||
<script src="js/config.js"></script>
|
<script src="js/config.js"></script>
|
||||||
<script src="js/rrule.js"></script>
|
<script src="js/rrule.js"></script>
|
||||||
|
<script src="js/version/version.js" type="text/javascript"></script>
|
||||||
<script src="js/compliments/compliments.js" type="text/javascript"></script>
|
<script src="js/compliments/compliments.js" type="text/javascript"></script>
|
||||||
<script src="js/weather/weather.js" type="text/javascript"></script>
|
<script src="js/weather/weather.js" type="text/javascript"></script>
|
||||||
<script src="js/time/time.js" type="text/javascript"></script>
|
<script src="js/time/time.js" type="text/javascript"></script>
|
||||||
|
16
js/main.js
16
js/main.js
@ -45,21 +45,7 @@ jQuery(document).ready(function($) {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
version.init();
|
||||||
(function checkVersion()
|
|
||||||
{
|
|
||||||
$.getJSON('githash.php', {}, function(json, textStatus) {
|
|
||||||
if (json) {
|
|
||||||
if (json.gitHash != gitHash) {
|
|
||||||
window.location.reload();
|
|
||||||
window.location.href=window.location.href;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setTimeout(function() {
|
|
||||||
checkVersion();
|
|
||||||
}, 3000);
|
|
||||||
})();
|
|
||||||
|
|
||||||
time.init();
|
time.init();
|
||||||
|
|
||||||
|
31
js/version/version.js
Normal file
31
js/version/version.js
Normal 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);
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user