From 85c2474a545bfd0615cd3ff51621e87e9ec39aa5 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 16 Mar 2021 00:28:29 +0200 Subject: [PATCH 2/6] Fix extension for open-sans-condensed-300-700.font Otherwise browser shows a warning that mime type is incorrect --- ...densed-300-700.font => open-sans-condensed-300-700.font.css} | 0 index.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename css/{open-sans-condensed-300-700.font => open-sans-condensed-300-700.font.css} (100%) diff --git a/css/open-sans-condensed-300-700.font b/css/open-sans-condensed-300-700.font.css similarity index 100% rename from css/open-sans-condensed-300-700.font rename to css/open-sans-condensed-300-700.font.css diff --git a/index.html b/index.html index c0e0a15..29eccfd 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + From ed6dd154c60bbe105a5c62e18e101bdf8ab0fdce Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 16 Mar 2021 00:35:33 +0200 Subject: [PATCH 3/6] main.js cleanup Add error details for fail on switches.json. Use done() instead of always() that will executed on fails too. Add missing var ip. Remove redundant escaping for - in regexp --- js/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/main.js b/js/main.js index 7dfe6bf..c15ceac 100644 --- a/js/main.js +++ b/js/main.js @@ -4,10 +4,10 @@ $(document).ready( function() { // get the list of switches to poll var switchesJSON = $ .ajax( { url: 'switches.json', cache: false, dataType: 'json' } ) - .fail( function() { - alert( 'Cannot find any switches' ); + .fail( function(e, textStatus ) { + alert( 'Cannot find any switches: ' + textStatus ); }) - .always( function( data ) { + .done( function( data ) { // create a section for each switch $('#switches').html( '
' ); var menuCollapsed = ( data.switches.length > 1 ? 'true' : 'false' ); @@ -43,7 +43,7 @@ function takeAction( url, id ) { } function UpdateSwitchData( id ) { - ip = all_switches[id].ip; + var ip = all_switches[id].ip; var switchinfoJSON = $ .ajax( { url: 'http://' + ip + '/cgi-bin/json.cgi', cache: false, dataType: 'jsonp' } ) @@ -144,7 +144,7 @@ function slugify( text ) { return text.toString().toLowerCase() .replace( /\s+/g, '-' ) // Replace spaces with - .replace( /[^\w\-]+/g, '' ) // Remove all non-word chars - .replace( /\-\-+/g, '-' ) // Replace multiple - with single - + .replace( /--+/g, '-' ) // Replace multiple - with single - .replace( /^-+/, '' ) // Trim - from start of text .replace( /-+$/, '' ); // Trim - from end of text } From ecf010090a229d47a92e6a4378b5c141814039ff Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 16 Mar 2021 00:39:09 +0200 Subject: [PATCH 4/6] main.js Use jQuery chaining Instead of duplicating selectors we can just use call chains. This makes code faster --- js/main.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/main.js b/js/main.js index c15ceac..40354d2 100644 --- a/js/main.js +++ b/js/main.js @@ -22,8 +22,8 @@ $(document).ready( function() {