Skip to content

Commit

Permalink
Fix home.js loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
salbahra committed Jun 20, 2024
1 parent 66d027a commit d1f80e2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
54 changes: 28 additions & 26 deletions www/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,39 +120,41 @@
document.title = "Loading...";

// Insert main application stylesheet
insertStyleSheet( assetLocation + "css/app.css" );
insertStyleSheet( assetLocation + "css/jqm.css" );
insertStyleSheet( assetLocation + "css/main.css" );
insertStyleSheet( assetLocation + "css/analog.css" );

// Insert favicon for web page
insertStyleSheet( assetLocation + "img/favicon.ico", "shortcut icon" );

// Insert jQuery
insertScript( assetLocation + "js/jquery.js" );

// Insert primary application script
insertScript( assetLocation + "js/main.js", function() {
try {
localStorage.setItem( "testQuota", "true" );
localStorage.removeItem( "testQuota" );
init();
} catch ( err ) {
if ( err.code === 22 ) {
document.body.innerHTML = "<div class='spinner'><div class='logo'></div>" +
"<span class='feedback'>Local storage is not " +
"enabled on your device and is required by the application. " +
"You may be in private browsing mode.</span></div>";
return;
}
}
} );

// Insert libraries
insertScript( assetLocation + "js/libs.js" )
insertScript( assetLocation + "js/jquery.js", function() {
// Insert libraries
insertScript( assetLocation + "js/libs.js", function() {
// Insert primary application script
insertScript( assetLocation + "js/main.js", function() {
try {
localStorage.setItem( "testQuota", "true" );
localStorage.removeItem( "testQuota" );
init();
} catch ( err ) {
if ( err.code === 22 ) {
document.body.innerHTML = "<div class='spinner'><div class='logo'></div>" +
"<span class='feedback'>Local storage is not " +
"enabled on your device and is required by the application. " +
"You may be in private browsing mode.</span></div>";
return;
}
}
} );

// Insert analog sensor (if supported)
insertScript( assetLocation + "js/analog.js" );
// Insert analog sensor (if supported)
insertScript( assetLocation + "js/analog.js" );

// Insert charting library for analog support
insertScript( assetLocation + "js/apexcharts.min.js" );
// Insert charting library for analog support
insertScript( assetLocation + "js/apexcharts.min.js" );
} )
} );

// Insert home page icon for iOS
insertStyleSheet( assetLocation + "res/ios-web/icons/icon.png", "apple-touch-icon" );
Expand Down
38 changes: 19 additions & 19 deletions www/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1515,13 +1515,13 @@ function showAddNew( autoIP, closeOld ) {
"id='os_name' placeholder='Home'>" +
( isAuto ? "" :
"<div class='ui-field-contain'>" +
    "<fieldset data-role='controlgroup' class='ui-mini center connection-type' data-type='horizontal'>" +
        "<legend class='left'>" + _( "Connection Type" ) + ":</legend>" +
        "<input class='noselect' type='radio' name='connectionType' id='type-direct' value='ip' checked='checked'>" +
        "<label for='type-direct'>" + _( "Direct" ) + "</label>" +
        "<input class='noselect' type='radio' name='connectionType' id='type-token' value='token'>" +
        "<label for='type-token'>" + _( "OpenThings Cloud" ) + "</label>" +
    "</fieldset>" +
"<fieldset data-role='controlgroup' class='ui-mini center connection-type' data-type='horizontal'>" +
"<legend class='left'>" + _( "Connection Type" ) + ":</legend>" +
"<input class='noselect' type='radio' name='connectionType' id='type-direct' value='ip' checked='checked'>" +
"<label for='type-direct'>" + _( "Direct" ) + "</label>" +
"<input class='noselect' type='radio' name='connectionType' id='type-token' value='token'>" +
"<label for='type-token'>" + _( "OpenThings Cloud" ) + "</label>" +
"</fieldset>" +
"</div>" +
"<label class='ip-field' for='os_ip'>" + _( "Open Sprinkler IP:" ) + "</label>" ) +
"<input data-wrapper-class='ip-field' " + ( isAuto ? "data-role='none' style='display:none' " : "" ) +
Expand Down Expand Up @@ -3691,19 +3691,19 @@ function showOptions( expandItem ) {
"</div>" ),
generateSensorOptions = function( index, sensorType, number ) {
return "<div class='ui-field-contain'>" +
    "<fieldset data-role='controlgroup' class='ui-mini center sensor-options' data-type='horizontal'>" +
        "<legend class='left'>" + _( "Sensor" ) + ( number ? " " + number + " " : " " ) + _( "Type" ) + "</legend>" +
        "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-none' value='0'" + ( sensorType === 0 ? " checked='checked'" : "" ) + ">" +
        "<label for='o" + index + "-none'>" + _( "None" ) + "</label>" +
        "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-rain' value='1'" + ( sensorType === 1 ? " checked='checked'" : "" ) + ">" +
        "<label for='o" + index + "-rain'>" + _( "Rain" ) + "</label>" +
"<fieldset data-role='controlgroup' class='ui-mini center sensor-options' data-type='horizontal'>" +
"<legend class='left'>" + _( "Sensor" ) + ( number ? " " + number + " " : " " ) + _( "Type" ) + "</legend>" +
"<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-none' value='0'" + ( sensorType === 0 ? " checked='checked'" : "" ) + ">" +
"<label for='o" + index + "-none'>" + _( "None" ) + "</label>" +
"<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-rain' value='1'" + ( sensorType === 1 ? " checked='checked'" : "" ) + ">" +
"<label for='o" + index + "-rain'>" + _( "Rain" ) + "</label>" +
( index === 52 ? "" : "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-flow' value='2'" + ( sensorType === 2 ? " checked='checked'" : "" ) + ">" +
         "<label for='o" + index + "-flow'>" + _( "Flow" ) + "</label>" ) +
        ( checkOSVersion( 219 ) ? "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-soil' value='3'" + ( sensorType === 3 ? " checked='checked'" : "" ) + ">" +
         "<label for='o" + index + "-soil'>" + _( "Soil" ) + "</label>" : "" ) +
        ( checkOSVersion( 217 ) ? "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-program' value='240'" + ( sensorType === 240 ? " checked='checked'" : "" ) + ">" +
         "<label for='o" + index + "-program'>" + _( "Program Switch" ) + "</label>" : "" ) +
    "</fieldset>" +
"<label for='o" + index + "-flow'>" + _( "Flow" ) + "</label>" ) +
( checkOSVersion( 219 ) ? "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-soil' value='3'" + ( sensorType === 3 ? " checked='checked'" : "" ) + ">" +
"<label for='o" + index + "-soil'>" + _( "Soil" ) + "</label>" : "" ) +
( checkOSVersion( 217 ) ? "<input class='noselect' type='radio' name='o" + index + "' id='o" + index + "-program' value='240'" + ( sensorType === 240 ? " checked='checked'" : "" ) + ">" +
"<label for='o" + index + "-program'>" + _( "Program Switch" ) + "</label>" : "" ) +
"</fieldset>" +
"</div>";
},
submitOptions = function() {
Expand Down

0 comments on commit d1f80e2

Please sign in to comment.