From 657eb061cd439e77615aebda861cc12619f043fa Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Wed, 19 Feb 2014 17:02:17 +0100 Subject: [PATCH] auto reloader --- githash.php | 2 ++ index.php | 24 ++++++++++++++++++++++++ js/main.js | 18 +++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 githash.php create mode 100644 index.php diff --git a/githash.php b/githash.php new file mode 100644 index 00000000..9a839edf --- /dev/null +++ b/githash.php @@ -0,0 +1,2 @@ +trim(`git rev-parse HEAD`))); \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 00000000..40949129 --- /dev/null +++ b/index.php @@ -0,0 +1,24 @@ + + + Magic Mirror + + + + + + +
+
+
+
+ +
+ + + + + + + \ No newline at end of file diff --git a/js/main.js b/js/main.js index 2f7cb659..156ef886 100644 --- a/js/main.js +++ b/js/main.js @@ -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',