auto reloader

This commit is contained in:
Michael Teeuw 2014-02-19 17:02:17 +01:00
parent cfff71a936
commit 657eb061cd
3 changed files with 43 additions and 1 deletions

2
githash.php Normal file
View File

@ -0,0 +1,2 @@
<?php
echo json_encode(array('gitHash'=>trim(`git rev-parse HEAD`)));

24
index.php Normal file
View File

@ -0,0 +1,24 @@
<html>
<head>
<title>Magic Mirror</title>
<link rel="stylesheet" type="text/css" href="css/main.css?nocache=<?php echo md5(microtime()) ?>">
<link rel="stylesheet" type="text/css" href="css/weather-icons.css">
<script type="text/javascript">
var gitHash = '<?php echo trim(`git rev-parse HEAD`) ?>';
</script>
</head>
<body>
<div class="TopLeft time"></div>
<div class="TopRight temp"></div>
<div class="Center compliment"></div>
<div class="Bottom">
</div>
<script src="js/jquery.js"></script>
<script src="js/jquery.feedToJSON.js"></script>
<script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script>
</body>
</html>

View File

@ -24,6 +24,23 @@ jQuery(document).ready(function($) {
var news = [];
var newsIndex = 0;
(function checkVersion()
{
$.getJSON('githash.php', {}, function(json, textStatus) {
if (json) {
if (json.gitHash != gitHash) {
console.log('refresh');
location.reload();
} else {
console.log('up to date');
}
}
});
setTimeout(function() {
checkVersion();
}, 3000);
})();
(function updateTime()
{
var now = new Date();
@ -95,7 +112,6 @@ jQuery(document).ready(function($) {
}, 60000);
})();
(function fetchNews() {
$.feedToJson({
feed:'http://feeds.nos.nl/nosjournaal?format=rss',