2018-08-10 19:42:30 +00:00
var time = 10
$ ( document ) . ready ( function ( ) {
2018-10-29 19:18:59 +00:00
checkUpdate ( )
} ) ;
function checkUpdate ( ) {
2018-08-28 15:29:27 +00:00
if ( ! isMac && webgl ) {
setTimeout ( function ( ) {
console . log ( 'checking for update' )
printLog ( "<span class='fg-red'>[ update ] </span><span class='fg-green'>Checking for Updates</span>" )
$ . getJSON ( "https://api.github.com/repos/OpenBuilds/SW-Machine-Drivers/releases/latest?client_id=fbbb80debc1197222169&client_secret=7dc6e463422e933448f9a3a4150c8d2bbdd0f87c" ) . 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
2018-11-23 16:13:16 +00:00
printLog ( "<span class='fg-red'>[ Update Available! ] </span><span class='fg-green'>OpenBuilds CONTROL <code>" + availVersion + "</code>. is available now.</span>" )
2018-08-28 15:29:27 +00:00
printLog ( "<span class='fg-red'>[ Update Available! ] </span><span class='fg-green'>Download will start in <span class='tally' id='countdown'>10</span> seconds (<a href='#' onclick='cancelTimer();'>cancel</a>) </span>" )
printLog ( "<span class='fg-red'>[ Update Available! ] </span><span class='fg-green'>You will be prompted when its ready to be installed </span>" )
setTimeout ( function ( ) {
updateTime ( ) ;
} , 1000 ) ;
} else {
2018-11-23 16:13:16 +00:00
printLog ( "<span class='fg-red'>[ update ] </span><span class='fg-green'>You are already running OpenBuilds CONTROL " + currentVersion + "</span>" )
2018-10-29 19:18:59 +00:00
setTimeout ( function ( ) {
checkUpdate ( )
} , 15 * 60 * 1000 ) // 15 mins
2018-08-28 15:29:27 +00:00
}
} ) ;
} , 1000 )
}
2018-10-29 19:18:59 +00:00
}
2018-08-10 19:42:30 +00:00
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 ( "<span class='fg-red'>[ Update Deferred! ] </span><span class='fg-green'>No problem, we will ask you again next time</span>" )
}