@ -21,14 +21,14 @@ var ago = 0;
// -----------------------------------------------------------------------------
function initMessages ( ) {
messages [ 1 ] = "Remote update started" ;
messages [ 2 ] = "OTA update started" ;
messages [ 3 ] = "Error parsing data!" ;
messages [ 4 ] = "The file does not look like a valid configuration backup or is corrupted" ;
messages [ 5 ] = "Changes saved. You should reboot your board now" ;
messages [ 7 ] = "Passwords do not match!" ;
messages [ 8 ] = "Changes saved" ;
messages [ 9 ] = "No changes detected" ;
messages [ 1 ] = "Remote update started" ;
messages [ 2 ] = "OTA update started" ;
messages [ 3 ] = "Error parsing data!" ;
messages [ 4 ] = "The file does not look like a valid configuration backup or is corrupted" ;
messages [ 5 ] = "Changes saved. You should reboot your board now" ;
messages [ 7 ] = "Passwords do not match!" ;
messages [ 8 ] = "Changes saved" ;
messages [ 9 ] = "No changes detected" ;
messages [ 10 ] = "Session expired, please reload page..." ;
}
@ -40,7 +40,7 @@ function sensorName(id) {
"SHT3X I2C" , "BH1750"
] ;
if ( 1 <= id && id <= names . length ) {
return names [ id - 1 ] ;
return names [ id - 1 ] ;
}
return null ;
}
@ -54,7 +54,7 @@ function magnitudeType(type) {
"PM1.0" , "PM2.5" , "PM10" , "CO2" , "Lux"
] ;
if ( 1 <= type && type <= types . length ) {
return types [ type - 1 ] ;
return types [ type - 1 ] ;
}
return null ;
}
@ -75,7 +75,7 @@ function magnitudeError(error) {
// -----------------------------------------------------------------------------
function keepTime ( ) {
if ( now === 0 ) return ;
if ( now === 0 ) { return ; }
var date = new Date ( now * 1000 ) ;
var text = date . toISOString ( ) . substring ( 0 , 19 ) . replace ( "T" , " " ) ;
$ ( "input[name='now']" ) . val ( text ) ;
@ -123,8 +123,7 @@ function loadTimeZones() {
$ ( "select[name='ntpOffset']" ) . append (
$ ( "<option></option>" ) .
attr ( "value" , value ) .
text ( text )
) ;
text ( text ) ) ;
}
}
@ -971,10 +970,10 @@ function processData(data) {
if ( key === "wifi" ) {
for ( i in data . wifi ) {
var line = addNetwork ( ) ;
var nwk_ line = addNetwork ( ) ;
var wifi = data . wifi [ i ] ;
Object . keys ( wifi ) . forEach ( function ( key ) {
$ ( "input[name='" + key + "']" , line ) . val ( wifi [ key ] ) ;
$ ( "input[name='" + key + "']" , nwk_ line) . val ( wifi [ key ] ) ;
} ) ;
}
return ;
@ -994,14 +993,13 @@ function processData(data) {
}
if ( key === "schedule" ) {
var schedule = data . schedule ;
for ( i in schedule ) {
var line = addSchedule ( ) ;
for ( i in data . schedule ) {
var sch_line = addSchedule ( ) ;
var schedule = data . schedule [ i ] ;
Object . keys ( schedule ) . forEach ( function ( key ) {
$ ( "input[name='" + key + "']" , line ) . val ( schedule [ key ] ) ;
$ ( "select[name='" + key + "']" , line ) . prop ( "value" , schedule [ key ] ) ;
$ ( ":checkbox" , line ) . prop ( "checked" , schedule [ key ] ) ;
$ ( "input[name='" + key + "']" , sch_ line) . val ( schedule [ key ] ) ;
$ ( "select[name='" + key + "']" , sch_ line) . prop ( "value" , schedule [ key ] ) ;
$ ( ":checkbox" , sch_ line) . prop ( "checked" , schedule [ key ] ) ;
} ) ;
}
return ;
@ -1113,33 +1111,33 @@ function processData(data) {
var post ;
// Look for INPUTs
var elemen t = $ ( "input[name='" + key + "']" ) ;
if ( elemen t. length > 0 ) {
if ( elemen t. attr ( "type" ) === "checkbox" ) {
elemen t.
var inpu t = $ ( "input[name='" + key + "']" ) ;
if ( inpu t. length > 0 ) {
if ( inpu t. attr ( "type" ) === "checkbox" ) {
inpu t.
prop ( "checked" , data [ key ] ) .
iphoneStyle ( "refresh" ) ;
} else if ( elemen t. attr ( "type" ) === "radio" ) {
elemen t. val ( [ data [ key ] ] ) ;
} else if ( inpu t. attr ( "type" ) === "radio" ) {
inpu t. val ( [ data [ key ] ] ) ;
} else {
pre = elemen t. attr ( "pre" ) || "" ;
post = elemen t. attr ( "post" ) || "" ;
elemen t. val ( pre + data [ key ] + post ) ;
pre = inpu t. attr ( "pre" ) || "" ;
post = inpu t. attr ( "post" ) || "" ;
inpu t. val ( pre + data [ key ] + post ) ;
}
}
// Look for SPANs
var element = $ ( "span[name='" + key + "']" ) ;
if ( element . length > 0 ) {
pre = element . attr ( "pre" ) || "" ;
post = element . attr ( "post" ) || "" ;
element . html ( pre + data [ key ] + post ) ;
var span = $ ( "span[name='" + key + "']" ) ;
if ( span . length > 0 ) {
pre = span . attr ( "pre" ) || "" ;
post = span . attr ( "post" ) || "" ;
span . html ( pre + data [ key ] + post ) ;
}
// Look for SELECTs
var elemen t = $ ( "select[name='" + key + "']" ) ;
if ( elemen t. length > 0 ) {
elemen t. val ( data [ key ] ) ;
var selec t = $ ( "select[name='" + key + "']" ) ;
if ( selec t. length > 0 ) {
selec t. val ( data [ key ] ) ;
}
} ) ;