From 225ea5746d83b6e79b96904e3f3dfb7c7b7defd4 Mon Sep 17 00:00:00 2001 From: SunStroke74 Date: Mon, 10 Nov 2014 23:59:41 +0500 Subject: [PATCH] Add function to update NUT widget content Discussion at https://forum.pfsense.org/index.php?topic=80981.0 --- usr/local/www/javascript/index/ajax.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 2fc6ab6d620..1226cbf220d 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -46,6 +46,7 @@ function stats(x) { updateMbuf(values[11]); updateMbufMeter(values[12]); updateStateMeter(values[13]); + updateNutStats(values[14]); } function updateMemory(x) { @@ -171,6 +172,27 @@ function updateInterfaces(x){ } } +function updateNutStats(x) { + if (widgetActive("ups")){ + upsdata_array = x.split(":"); + if(upsdata_array.length > 1) { + if(jQuery('#monitoring')) jQuery("#monitoring").html(upsdata_array[0]); + if(jQuery('#model')) jQuery("#model").html(upsdata_array[1]); + if(jQuery('#status')) jQuery("#status").html(upsdata_array[2]); + if(jQuery('#batwidtha')) jQuery("#batwidtha").css('width', upsdata_array[3] + 'px'); + if(jQuery('#batwidthb')) jQuery("#batwidthb").css('width', upsdata_array[4] + 'px'); + if(jQuery('#batmeter')) jQuery("#batmeter").html(upsdata_array[5]); + if(jQuery('#runtime')) jQuery("#runtime").html(upsdata_array[6]); + if(jQuery('#bvoltage')) jQuery("#bvoltage").html(upsdata_array[7]); + if(jQuery('#loadwidtha')) jQuery("#loadwidtha").css('width', upsdata_array[8] + 'px'); + if(jQuery('#loadwidthb')) jQuery("#loadwidthb").css('width', upsdata_array[9] + 'px'); + if(jQuery('#loadmeter')) jQuery("#loadmeter").html(upsdata_array[10]); + if(jQuery('#InputV')) jQuery("#InputV").html(upsdata_array[11]); + if(jQuery('#OutputV')) jQuery("#OutputV").html(upsdata_array[12]); + } + } +} + function widgetActive(x) { var widget = jQuery('#' + x + '-container'); if ((widget != null) && (widget.css('display') != null) && (widget.css('display') != "none"))