switch to _var function for setting batteryLevel & batteryRuntime

This commit is contained in:
Justin Brown
2024-07-24 16:57:35 -04:00
parent 36f9e7402c
commit 392cc77a20

View File

@@ -14,11 +14,13 @@ Tag="battery-3"
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
?>
<script>
function getUPSstatus() {
var batteryLevel = "<?= !empty($cfg['BATTERYLEVEL']) ? $cfg['BATTERYLEVEL'] : 0 ?>";
var batteryRuntime = "<?= !empty($cfg['MINUTES']) ? $cfg['MINUTES'] : 0 ?>";
var batteryLevel = "<?= _var($cfg,'BATTERYLEVEL',0) ?>";
var batteryRuntime = "<?= _var($cfg,'MINUTES',0) ?>";
$.post('/plugins/dynamix.apcupsd/include/UPSstatus.php',{level:batteryLevel,runtime:batteryRuntime},function(data) {
data = data.split('\n');