diff --git a/index.php b/index.php
index ade2ebed..a02f8b03 100644
--- a/index.php
+++ b/index.php
@@ -27,6 +27,7 @@
+
diff --git a/js/main.js b/js/main.js
index df645416..0070fd67 100755
--- a/js/main.js
+++ b/js/main.js
@@ -45,21 +45,7 @@ jQuery(document).ready(function($) {
// }
// });
-
- (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);
- })();
+ version.init();
time.init();
diff --git a/js/version/version.js b/js/version/version.js
new file mode 100644
index 00000000..5931a179
--- /dev/null
+++ b/js/version/version.js
@@ -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);
+
+}
\ No newline at end of file