var time = 10 $(document).ready(function() { checkUpdate() }); function checkUpdate() { if (!isMac && webgl) { setTimeout(function() { // console.log('checking for update') printLog("[ update ] Checking for Updates") $.getJSON("https://api.github.com/repos/OpenBuilds/OpenBuilds-CONTROL/releases/latest", { crossDomain: true }).done(function(release) { var availVersion = release.name.substr(1) var currentVersion = laststatus.driver.version // console.log(versionCompare(availVersion, currentVersion), availVersion, currentVersion); if (versionCompare(availVersion, currentVersion) == 1) { console.log('outdated') time = 10 printLog("[ Update Available! ] OpenBuilds CONTROL " + availVersion + ". is available now.") printLog("[ Update Available! ] Download will start in 10 seconds (cancel) ") printLog("[ Update Available! ] You will be prompted when its ready to be installed ") setTimeout(function() { updateTime(); }, 1000); } else { printLog("[ update ] You are already running OpenBuilds CONTROL " + currentVersion + "") setTimeout(function() { checkUpdate() }, 60 * 60 * 1000) // 15 mins } }); }, 1000) } } function updateTime() { time-- if (time > 0) { $('#countdown').html(time) setTimeout(function() { updateTime(); }, 1000); } else if (time == 0) { $('#countdown').html(time) socket.emit('downloadUpdate', true) } } function cancelTimer() { time = -1 $('#countdown').html('cancelled') printLog("[ Update Deferred! ] No problem, we will ask you again next time") }