From e9f8309b50cfb42b4f59565a4e8ab1c3bd8323ec Mon Sep 17 00:00:00 2001 From: birdhouse Date: Wed, 26 Jun 2019 18:17:39 +0200 Subject: [PATCH] New version function --- assets/webconfig/content/support.html | 1 + assets/webconfig/content/update.html | 38 ++++++++++-------- assets/webconfig/js/content_dashboard.js | 44 ++++++--------------- assets/webconfig/js/ui_utils.js | 50 +++++++++++++++++++++++- 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/assets/webconfig/content/support.html b/assets/webconfig/content/support.html index 00810b1c..310b499c 100644 --- a/assets/webconfig/content/support.html +++ b/assets/webconfig/content/support.html @@ -127,4 +127,5 @@ diff --git a/assets/webconfig/content/update.html b/assets/webconfig/content/update.html index 9ed48fc9..80e9cd46 100644 --- a/assets/webconfig/content/update.html +++ b/assets/webconfig/content/update.html @@ -16,25 +16,29 @@ diff --git a/assets/webconfig/js/content_dashboard.js b/assets/webconfig/js/content_dashboard.js index c94eef9b..19813502 100644 --- a/assets/webconfig/js/content_dashboard.js +++ b/assets/webconfig/js/content_dashboard.js @@ -80,43 +80,21 @@ $(document).ready( function() { $('#dash_ports').html(window.serverConfig.flatbufServer.port+' | '+window.serverConfig.protoServer.port); $('#dash_versionbranch').html(window.serverConfig.general.versionBranch); - $.get( window.gitHubReleaseApiUrl, function( releases ) { - window.gitHubVersionList = releases; + getReleases(function(){ + var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, ''); + var cleanCurrentVersion = window.currentVersion.replace(/\./g, ''); - for(var i in releases) - { - if(releases[i].prerelease == true) - { - window.latestBetaVersion = releases[i]; - break; - } - } + $('#dash_latev').html(window.currentVersion); + $('#dash_latev').html(window.latestVersion.tag_name + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')'); - $.get( window.gitHubReleaseApiUrl + "/latest", function( latest ) { - window.latestStableVersion = latest; - - if(window.serverConfig.general.versionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, '')) - { - window.latestVersion = window.latestBetaVersion; - } - else - { - window.latestVersion = window.latestStableVersion; - } - - var cleanLatestVersion = window.latestVersion.tag_name.replace(/\./g, ''); - var cleanCurrentVersion = window.currentVersion.replace(/\./g, ''); - - $('#dash_latev').html(window.currentVersion); - $('#dash_latev').html(window.latestVersion.tag_name + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')'); - - if ( cleanCurrentVersion < cleanLatestVersion ) - $('#versioninforesult').html('
'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')
'); - else - $('#versioninforesult').html('
'+$.i18n('dashboard_infobox_message_updatesuccess')+'
'); - }); + if ( cleanCurrentVersion < cleanLatestVersion ) + $('#versioninforesult').html('
'+$.i18n('dashboard_infobox_message_updatewarning', window.latestVersion.tag_name) + ' (' + (window.latestVersion.prerelease == true ? "Beta" : "Stable") + ')
'); + else + $('#versioninforesult').html('
'+$.i18n('dashboard_infobox_message_updatesuccess')+'
'); }); + + //determine platform var grabbers = window.serverInfo.grabbers.available; var html = ""; diff --git a/assets/webconfig/js/ui_utils.js b/assets/webconfig/js/ui_utils.js index b7f43d53..70340828 100644 --- a/assets/webconfig/js/ui_utils.js +++ b/assets/webconfig/js/ui_utils.js @@ -198,7 +198,7 @@ function showInfoDialog(type,header,message) $('#id_body').append(message); $('#id_footer').html(''); } - + $('#id_body').append('

'+header+'

'); $('#id_body').append(message); @@ -709,3 +709,51 @@ function encode_utf8(s) { return unescape(encodeURIComponent(s)); } + +function getReleases(callback) +{ + $.ajax({ + url: window.gitHubReleaseApiUrl, + method: 'get', + error: function(XMLHttpRequest, textStatus, errorThrown) + { + callback(false); + }, + success: function(releases) + { + window.gitHubVersionList = releases; + + for(var i in releases) + { + if(releases[i].prerelease == true) + { + window.latestBetaVersion = releases[i]; + break; + } + } + + $.ajax({ + url: window.gitHubReleaseApiUrl + "/latest", + method: 'get', + error: function(XMLHttpRequest, textStatus, errorThrown) + { + callback(false); + }, + success: function(latest) + { + window.latestStableVersion = latest; + + if(window.serverConfig.general.versionBranch == "Beta" && window.latestStableVersion.tag_name.replace(/\./g, '') <= window.latestBetaVersion.tag_name.replace(/\./g, '')) + { + window.latestVersion = window.latestBetaVersion; + } + else + { + window.latestVersion = window.latestStableVersion; + } + callback(true); + } + }); + } + }) +}