@@ -194,7 +194,7 @@ $('.output_radio_button').click(function() {
194194 */
195195function switchCSS ( new_theme ) {
196196 console . log ( 'switching to new Bootswatch theme: ' + new_theme ) ;
197- if ( new_theme == 'bootstrap' ) {
197+ if ( new_theme === 'bootstrap' ) {
198198 $ ( '#bootswatch_theme_stylesheet' ) . attr ( 'href' , '' ) ;
199199 } else {
200200 $ ( '#bootswatch_theme_stylesheet' ) . attr ( 'href' , 'https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/' + new_theme + '/bootstrap.min.css' ) ;
@@ -317,7 +317,7 @@ function fetchDebugDetails() {
317317 url : 'ajax/show_api_debug.php' ,
318318 dataType : 'html' ,
319319 success : function ( data ) {
320- if ( data != 'ignore' ) {
320+ if ( data !== 'ignore' ) {
321321 console . log ( 'debug messages as returned by the cURL request to the UniFi controller API:' ) ;
322322 console . log ( data ) ;
323323 }
@@ -532,28 +532,37 @@ $(function() {
532532 * upon opening the "About" modal we check latest version of API browser tool using AJAX and inform user when it's
533533 * more recent than the current
534534 */
535+ let version_update_span = $ ( '#span_api_browser_update' ) ;
535536$ ( '#about_modal' ) . on ( 'shown.bs.modal' , function ( e ) {
536537 $ . ajax ( {
537538 type : 'GET' ,
538539 url : 'https://api.github.com/repos/Art-of-WiFi/UniFi-API-browser/releases/latest' ,
539540 dataType : 'json' ,
540541 success : function ( json ) {
541- if ( api_browser_version != '' && typeof ( json . tag_name ) !== 'undefined' ) {
542- if ( cmpVersion ( api_browser_version , json . tag_name . substring ( 1 ) ) < 0 ) {
543- $ ( '#span_api_browser_update' ) . html ( 'an update is available: ' + json . tag_name . substring ( 1 ) ) ;
542+ if ( api_browser_version !== '' && typeof ( json . tag_name ) !== 'undefined' ) {
543+ const normalizedTagName = json . tag_name . startsWith ( 'v' ) ? json . tag_name . substring ( 1 ) : json . tag_name ;
544+
545+ if ( debug ) {
546+ console . log ( 'API Browser Version:' , api_browser_version ) ;
547+ console . log ( 'Normalized Tag Name:' , normalizedTagName ) ;
548+ console . log ( 'Comparison Result:' , cmpVersion ( api_browser_version , normalizedTagName ) ) ;
549+ }
550+
551+ if ( cmpVersion ( api_browser_version , normalizedTagName ) < 0 ) {
552+ version_update_span . html ( 'an update is available: ' + normalizedTagName ) ;
544553 $ ( '#span_api_browser_update' ) . removeClass ( 'badge-success' ) . addClass ( 'badge-warning' ) ;
545- } else if ( cmpVersion ( api_browser_version , json . tag_name . substring ( 1 ) ) === 0 ) {
546- $ ( '#span_api_browser_update' ) . html ( 'up to date' ) ;
547- $ ( '#span_api_browser_update' ) . removeClass ( 'badge-danger' ) . addClass ( 'badge-success' ) ;
554+ } else if ( cmpVersion ( api_browser_version , normalizedTagName ) === 0 ) {
555+ version_update_span . html ( 'up to date' ) ;
556+ version_update_span . removeClass ( 'badge-danger' ) . addClass ( 'badge-success' ) ;
548557 } else {
549- $ ( '#span_api_browser_update' ) . html ( 'bleeding edge!' ) ;
550- $ ( '#span_api_browser_update' ) . removeClass ( 'badge-success' ) . addClass ( 'badge-danger' ) ;
558+ version_update_span . html ( 'bleeding edge!' ) ;
559+ version_update_span . removeClass ( 'badge-success' ) . addClass ( 'badge-danger' ) ;
551560 }
552561 }
553562 } ,
554563 error : function ( jqXHR , textStatus , errorThrown ) {
555- $ ( '#span_api_browser_update' ) . html ( 'error checking updates' ) ;
556- $ ( '#span_api_browser_update' ) . removeClass ( 'badge-success' ) . addClass ( 'badge-danger' ) ;
564+ version_update_span . html ( 'error checking updates' ) ;
565+ version_update_span . removeClass ( 'badge-success' ) . addClass ( 'badge-danger' ) ;
557566 console . log ( jqXHR ) ;
558567 }
559568 } ) ;
0 commit comments