diff options
author | Phil Davis <phil.davis@inf.org> | 2015-04-14 14:10:58 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-04-14 14:10:58 +0545 |
commit | f3ec04877ba7ef9aa4e0c43d34cec0f58a53891f (patch) | |
tree | 05bf5b60f03bcba80cdfbe6de0394b09fab8e14e /usr/local/www/widgets | |
parent | 460610b2076ed39fd3f0d36a5c758c2bc9afefb0 (diff) | |
download | pfsense-f3ec04877ba7ef9aa4e0c43d34cec0f58a53891f.zip pfsense-f3ec04877ba7ef9aa4e0c43d34cec0f58a53891f.tar.gz |
Code style for small things in usr-local-www
Diffstat (limited to 'usr/local/www/widgets')
-rw-r--r-- | usr/local/www/widgets/include/thermal_sensors.inc | 1 | ||||
-rw-r--r-- | usr/local/www/widgets/javascript/ipsec.js | 6 | ||||
-rw-r--r-- | usr/local/www/widgets/javascript/thermal_sensors.js | 145 | ||||
-rw-r--r-- | usr/local/www/widgets/javascript/traffic_graph.js | 26 |
4 files changed, 90 insertions, 88 deletions
diff --git a/usr/local/www/widgets/include/thermal_sensors.inc b/usr/local/www/widgets/include/thermal_sensors.inc index a27b1eb..a6e727a 100644 --- a/usr/local/www/widgets/include/thermal_sensors.inc +++ b/usr/local/www/widgets/include/thermal_sensors.inc @@ -7,6 +7,7 @@ Used by: \usr\local\www\widgets\widgets\thermal_sensors.widget.php + */ //set variable for custom title diff --git a/usr/local/www/widgets/javascript/ipsec.js b/usr/local/www/widgets/javascript/ipsec.js index c9d704a..d38f6cd 100644 --- a/usr/local/www/widgets/javascript/ipsec.js +++ b/usr/local/www/widgets/javascript/ipsec.js @@ -1,9 +1,9 @@ -function updateIpsec(){ +function updateIpsec() { selectIntLink = "ipsecDetailed"; ipsecsettings = "ipsecDetail="; ipsecsettings += d.getElementById(selectIntLink).checked; - - selectIntLink = "ipsec-config"; + + selectIntLink = "ipsec-config"; textlink = d.getElementById(selectIntLink); textlink.value = ipsecsettings; }
\ No newline at end of file diff --git a/usr/local/www/widgets/javascript/thermal_sensors.js b/usr/local/www/widgets/javascript/thermal_sensors.js index f244296..7415b01 100644 --- a/usr/local/www/widgets/javascript/thermal_sensors.js +++ b/usr/local/www/widgets/javascript/thermal_sensors.js @@ -1,9 +1,9 @@ /* $Id: thermal_sensors.js - Description: + Description: Javascript functions to get and show thermal sensors data in thermal_sensors.widget.php. NOTE: depends on proper config in System >> Advanced >> Miscellaneous tab >> Thermal Sensors section. - File location: + File location: \usr\local\www\widgets\javascript\ Used by: \usr\local\www\widgets\widgets\thermal_sensors.widget.php @@ -36,7 +36,7 @@ function showThermalSensorsData() { //get data from thermal_sensors.widget.php - url = "/widgets/widgets/thermal_sensors.widget.php?getThermalSensorsData=1" + url = "/widgets/widgets/thermal_sensors.widget.php?getThermalSensorsData=1" //IE fix to disable cache when using http:// , just append timespan + new Date().getTime(); @@ -46,14 +46,14 @@ function showThermalSensorsData() { var thermalSensorsData = data || ""; buildThermalSensorsData(thermalSensorsData); }, - error: function(jqXHR, status, error){ + error: function(jqXHR, status, error) { buildThermalSensorsDataRaw( - "Error getting data from [thermal_sensors.widget.php] - |" + - "status: [" + (status || "") + "]|" + + "Error getting data from [thermal_sensors.widget.php] - |" + + "status: [" + (status || "") + "]|" + "error: [" + (error || "") + "]"); } }); - + //call itself in 11 seconds window.setTimeout(showThermalSensorsData, 11000); } @@ -62,21 +62,20 @@ function buildThermalSensorsData(thermalSensorsData) { //NOTE: variable thermal_sensors_widget_showRawOutput is declared/set in "thermal_sensors.widget.php" if (thermal_sensors_widget_showRawOutput) { buildThermalSensorsDataRaw(thermalSensorsData); - } - else { + } else { buildThermalSensorsDataGraph(thermalSensorsData); } } function buildThermalSensorsDataRaw(thermalSensorsData) { - + var thermalSensorsContent = ""; - + if (thermalSensorsData && thermalSensorsData != "") { thermalSensorsContent = thermalSensorsData.replace(/\|/g, "<br />"); //rawData = thermalSensorsData.split("|").join("<br />"); } - + loadThermalSensorsContainer(thermalSensorsContent); } @@ -88,7 +87,7 @@ function loadThermalSensorsContainer (thermalSensorsContent) { } else { jQuery('#thermalSensorsContainer').html("No Thermal Sensors data available.<br /><br />"); jQuery('<div/>').html( - "<span>* You can configure a proper Thermal Sensor / Module under <br />" + + "<span>* You can configure a proper Thermal Sensor / Module under <br />" + " <a href='system_advanced_misc.php'>System > Advanced > Miscellaneous : Thermal Sensors section</a>.</span>" ).appendTo('#thermalSensorsContainer'); } @@ -100,51 +99,51 @@ function buildThermalSensorsDataGraph(thermalSensorsData) { var normalColor = "LimeGreen"; var normalColorShadowTop = "Lime"; var normalColorShadowBottom = "Green"; - + var warningColor = "Orange"; var warningColorShadowBottom = "Chocolate"; - + var criticalColor = "Red"; var criticalColorShadowBottom = "DarkRed"; - + //local variables var barBgColor = normalColor; //green/normal as default var barBgColorShadowTop = normalColorShadowTop; //green/normal as default var barBgColorShadowBottom = normalColorShadowBottom; //green/normal as default - + var thermalSensorsArray = new Array(); - - if (thermalSensorsData && thermalSensorsData != ""){ + + if (thermalSensorsData && thermalSensorsData != "") { thermalSensorsArray = thermalSensorsData.split("|"); } var thermalSensorsHTMLContent = ""; var itemsToPulsate = new Array(); - + //generate graph for each temperature sensor and append to thermalSensorsHTMLContent string for (var i = 0; i < thermalSensorsArray.length; i++) { - + var sensorDataArray = thermalSensorsArray[i].split(":"); var sensorName = sensorDataArray[0].trim(); var thermalSensorValue = getThermalSensorValue(sensorDataArray[1]); var pulsateTimes = 0; var pulsateDuration = 0; - + var warningTempThresholdPosition = 0; var criticalTempThresholdPosition = 0; - - //NOTE: the following variables are declared/set in "thermal_sensors.widget.php": - // thermal_sensors_widget_coreWarningTempThreshold, thermal_sensors_widget_coreCriticalTempThreshold, + + //NOTE: the following variables are declared/set in "thermal_sensors.widget.php": + // thermal_sensors_widget_coreWarningTempThreshold, thermal_sensors_widget_coreCriticalTempThreshold, // thermal_sensors_widget_zoneWarningTempThreshold, thermal_sensors_widget_zoneCriticalTempThreshold // thermal_sensors_widget_pulsateWarning, thermal_sensors_widget_pulsateCritical - + //set graph color and pulsate parameters if (sensorName.indexOf("cpu") > -1) { //check CPU Threshold config settings - + warningTempThresholdPosition = thermal_sensors_widget_coreWarningTempThreshold; criticalTempThresholdPosition = thermal_sensors_widget_coreCriticalTempThreshold; - + if (thermalSensorValue < thermal_sensors_widget_coreWarningTempThreshold) { barBgColor = normalColor; barBgColorShadowTop = normalColorShadowTop; @@ -165,21 +164,21 @@ function buildThermalSensorsDataGraph(thermalSensorsData) { pulsateDuration = thermal_sensors_widget_pulsateCritical ? 900 : 0; } } else { //assuming sensor is for a zone, check Zone Threshold config settings - + warningTempThresholdPosition = thermal_sensors_widget_zoneWarningTempThreshold; criticalTempThresholdPosition = thermal_sensors_widget_zoneCriticalTempThreshold; if (thermalSensorValue < thermal_sensors_widget_zoneWarningTempThreshold) { - + barBgColor = normalColor; barBgColorShadowTop = normalColorShadowTop; barBgColorShadowBottom = normalColorShadowBottom; pulsateTimes = 0; pulsateDuration = 0; - } else if (thermalSensorValue >= thermal_sensors_widget_zoneWarningTempThreshold - && thermalSensorValue < thermal_sensors_widget_zoneCriticalTempThreshold) { - + } else if (thermalSensorValue >= thermal_sensors_widget_zoneWarningTempThreshold && + thermalSensorValue < thermal_sensors_widget_zoneCriticalTempThreshold) { + barBgColor = warningColor; barBgColorShadowTop = warningColor; barBgColorShadowBottom = warningColorShadowBottom; @@ -187,7 +186,7 @@ function buildThermalSensorsDataGraph(thermalSensorsData) { pulsateDuration = thermal_sensors_widget_pulsateWarning ? 900 : 0; } else { // thermalSensorValue > thermal_sensors_widget_zoneCriticalTempThreshold - + barBgColor = criticalColor; barBgColorShadowTop = criticalColor; barBgColorShadowBottom = criticalColorShadowBottom; @@ -203,44 +202,44 @@ function buildThermalSensorsDataGraph(thermalSensorsData) { //build temperature item/row for a sensor //NOTE: additional styles are set in 'thermal_sensors.widget.php' - var thermalSensorRow = "<div class='thermalSensorRow' id='thermalSensorRow" + i + "' >" + + var thermalSensorRow = "<div class='thermalSensorRow' id='thermalSensorRow" + i + "' >" + //sensor name and temperature value - " <div class='thermalSensorTextShell'><div class='thermalSensorText' id='thermalSensorText" + i + "'>" + sensorName + ": </div><div class='thermalSensorValue' id='thermalSensorValue" + i + "'>" + thermalSensorValue + " °C</div></div>" + + " <div class='thermalSensorTextShell'><div class='thermalSensorText' id='thermalSensorText" + i + "'>" + sensorName + ": </div><div class='thermalSensorValue' id='thermalSensorValue" + i + "'>" + thermalSensorValue + " °C</div></div>" + //temperature bar - " <div class='thermalSensorBarShell' id='thermalSensorBarShell" + i + "' >" + - " <div class='thermalSensorBar' id='thermalSensorBar" + i + "' style='background-color: " + barBgColor + "; border-top-color: " + barBgColorShadowTop + "; border-bottom-color: " + barBgColorShadowBottom + "; width:" + thermalSensorValue + "%;' ></div>" + + " <div class='thermalSensorBarShell' id='thermalSensorBarShell" + i + "' >" + + " <div class='thermalSensorBar' id='thermalSensorBar" + i + "' style='background-color: " + barBgColor + "; border-top-color: " + barBgColorShadowTop + "; border-bottom-color: " + barBgColorShadowBottom + "; width:" + thermalSensorValue + "%;' ></div>" + //threshold targets (warning and critical) - " <div class='thermalSensorWarnThresh' id='thermalSensorWarnThresh" + i + "' style='left:" + warningTempThresholdPosition + "%;' ></div>" + - " <div class='thermalSensorCritThresh' id='thermalSensorCritThresh" + i + "' style='left:" + criticalTempThresholdPosition + "%;' ></div>" + + " <div class='thermalSensorWarnThresh' id='thermalSensorWarnThresh" + i + "' style='left:" + warningTempThresholdPosition + "%;' ></div>" + + " <div class='thermalSensorCritThresh' id='thermalSensorCritThresh" + i + "' style='left:" + criticalTempThresholdPosition + "%;' ></div>" + //temperature scale (max 100 C) - " <div class='thermal_sensors_widget_scale000'></div>" + - " <div class='thermal_sensors_widget_scale010'></div>" + - " <div class='thermal_sensors_widget_scale020'></div>" + - " <div class='thermal_sensors_widget_scale030'></div>" + - " <div class='thermal_sensors_widget_scale040'></div>" + - " <div class='thermal_sensors_widget_scale050'></div>" + - " <div class='thermal_sensors_widget_scale060'></div>" + - " <div class='thermal_sensors_widget_scale070'></div>" + - " <div class='thermal_sensors_widget_scale080'></div>" + - " <div class='thermal_sensors_widget_scale090'></div>" + - " <div class='thermal_sensors_widget_scale100'></div>" + - " <div class='thermal_sensors_widget_mark100'>100°</div>" + - " </div>" + + " <div class='thermal_sensors_widget_scale000'></div>" + + " <div class='thermal_sensors_widget_scale010'></div>" + + " <div class='thermal_sensors_widget_scale020'></div>" + + " <div class='thermal_sensors_widget_scale030'></div>" + + " <div class='thermal_sensors_widget_scale040'></div>" + + " <div class='thermal_sensors_widget_scale050'></div>" + + " <div class='thermal_sensors_widget_scale060'></div>" + + " <div class='thermal_sensors_widget_scale070'></div>" + + " <div class='thermal_sensors_widget_scale080'></div>" + + " <div class='thermal_sensors_widget_scale090'></div>" + + " <div class='thermal_sensors_widget_scale100'></div>" + + " <div class='thermal_sensors_widget_mark100'>100°</div>" + + " </div>" + "</div>"; - + //collect parameters for warning/critical items we need to pulsate if (pulsateTimes > 0) { var params = i + "|" + barBgColor + "|" + pulsateTimes + "|" + pulsateDuration; itemsToPulsate.push(params); } - + //append HTML item thermalSensorsHTMLContent = thermalSensorsHTMLContent + thermalSensorRow; } - + //load generated graph into thermalSensorsContainer (DIV defined in "thermal_sensors.widget.php") loadThermalSensorsContainer(thermalSensorsHTMLContent); - + if (itemsToPulsate.length > 0) { //pulsate/flash warning/critical items we collected pulsateThermalSensorsItems(itemsToPulsate); @@ -248,10 +247,10 @@ function buildThermalSensorsDataGraph(thermalSensorsData) { } function pulsateThermalSensorsItems(itemsToPulsate) { - + //pulsate/flash warning/critical items we collected for (var i = 0; i < itemsToPulsate.length; i++) { - + var pulsateParams = itemsToPulsate[i].split("|"); var rowNum = parseInt(pulsateParams[0]); //var textColor = pulsateParams[1]; @@ -260,36 +259,38 @@ function pulsateThermalSensorsItems(itemsToPulsate) { //pulsate temp Value var divThermalSensorValue = jQuery("#thermalSensorValue" + rowNum); //get temp value by id - divThermalSensorValue.effect("pulsate", { - times: pulsateTimes - ,easing: 'linear' //'easeInExpo' + divThermalSensorValue.effect("pulsate", { + times: pulsateTimes, + easing: 'linear' //'easeInExpo' }, pulsateDuration); ////set Temp Value color - //divThermalSensorValue.css( { color: textColor } ); - + //divThermalSensorValue.css({ color: textColor }); + //pulsate temp Bar var divThermalSensorBar = jQuery("#thermalSensorBar" + rowNum); //get temp bar by id - divThermalSensorBar.effect("pulsate", { - times: pulsateTimes - ,easing: 'linear' //'easeInExpo' + divThermalSensorBar.effect("pulsate", { + times: pulsateTimes, + easing: 'linear' //'easeInExpo' }, pulsateDuration); - + } } -function getSensorFriendlyName(sensorFullName){ +function getSensorFriendlyName(sensorFullName) { var rzone = /^hw\.acpi\.thermal\.tz([0-9]+)\.temperature$/; var rcore = /^dev\.cpu\.([0-9]+)\.temperature$/; - if (rzone.test(sensorFullName)) + if (rzone.test(sensorFullName)) { return "Zone " + rzone.exec(sensorFullName)[1]; + } - if (rcore.test(sensorFullName)) + if (rcore.test(sensorFullName)) { return "Core " + rcore.exec(sensorFullName)[1]; + } return sensorFullName; } -function getThermalSensorValue(stringValue){ +function getThermalSensorValue(stringValue) { return (+parseFloat(stringValue) || 0).toFixed(1); } diff --git a/usr/local/www/widgets/javascript/traffic_graph.js b/usr/local/www/widgets/javascript/traffic_graph.js index dcfd4f3..83fc481 100644 --- a/usr/local/www/widgets/javascript/traffic_graph.js +++ b/usr/local/www/widgets/javascript/traffic_graph.js @@ -1,34 +1,34 @@ -function trafficshowDiv(incDiv,swapButtons){ +function trafficshowDiv(incDiv,swapButtons) { //appear element selectedDiv = incDiv + "graphdiv"; - jQuery('#' + selectedDiv).effect('blind',{mode:'show'},1000); - d = document; - if (swapButtons){ + jQuery('#' + selectedDiv).effect('blind',{mode:'show'},1000); + d = document; + if (swapButtons) { selectIntLink = selectedDiv + "-min"; textlink = d.getElementById(selectIntLink); - textlink.style.display = "inline"; - + textlink.style.display = "inline"; + selectIntLink = selectedDiv + "-open"; textlink = d.getElementById(selectIntLink); textlink.style.display = "none"; } document.iform["shown[" + incDiv + "]"].value = "show"; } - -function trafficminimizeDiv(incDiv,swapButtons){ + +function trafficminimizeDiv(incDiv,swapButtons) { //fade element selectedDiv = incDiv + "graphdiv"; jQuery('#' + selectedDiv).effect('blind',{mode:'hide'},1000); - d = document; - if (swapButtons){ + d = document; + if (swapButtons) { selectIntLink = selectedDiv + "-open"; textlink = d.getElementById(selectIntLink); - textlink.style.display = "inline"; - + textlink.style.display = "inline"; + selectIntLink = selectedDiv + "-min"; textlink = d.getElementById(selectIntLink); textlink.style.display = "none"; - } + } document.iform["shown[" + incDiv + "]"].value = "hide"; } |