Skip to content

Commit

Permalink
Fixing conditionals error in adei and calc
Browse files Browse the repository at this point in the history
Signed-off-by: Chin Yi Han <[email protected]>
  • Loading branch information
chinyihan committed Jun 26, 2024
1 parent ae979f5 commit e22277d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 27 deletions.
39 changes: 25 additions & 14 deletions js_plugins/adei.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,31 @@ function parse_adei(key, value, timestamp, invalid) {
value = (Math.round(value * 100) / 100).toFixed(data_decimal_numbers);
}

if (data_smaller_than != undefined && value < data_smaller_than) {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
}

if (data_larger_than != undefined && value > data_larger_than) {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
if (data_smaller_than != undefined && data_larger_than != undefined) {

if (value > data_smaller_than && value < data_larger_than) {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (data_smaller_than == '' && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'black');
$("#" + key + "> .unit-name").css('color', 'black');
} else if (value < data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else if (value > data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (value > data_larger_than && data_smaller_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else if (value < data_larger_than && data_smaller_than == '') {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else {
// value < data_smaller_than && value > data_larger_than
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
}
}

if (data_exp != undefined && data_exp == "true") {
Expand Down
37 changes: 24 additions & 13 deletions js_plugins/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,31 @@ function parse_calc(key, response) {
//console.log("My Value");
//console.log(value);

if (data_smaller_than != undefined && value < data_smaller_than) {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
}
if (data_smaller_than != undefined && data_larger_than != undefined) {

if (data_larger_than != undefined && value > data_larger_than) {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
if (value > data_smaller_than && value < data_larger_than) {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (data_smaller_than == '' && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'black');
$("#" + key + "> .unit-name").css('color', 'black');
} else if (value < data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else if (value > data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (value > data_larger_than && data_smaller_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
} else if (value < data_larger_than && data_smaller_than == '') {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else {
// value < data_smaller_than && value > data_larger_than
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
}
}

$("#" + key + " > .value").text(value);
Expand Down

0 comments on commit e22277d

Please sign in to comment.