* Mon May 12 2025 Brian Read <brianr@koozali.org> 11.0.0-1.sme

- Adding SM2 panel [SME: 13004]
- Upgrade to phpsysinfo 3.4.4
- Add code to delete inline styles and add css to make it look better.
- version saved / built uses the static version, which means no drops downs and choices.
This commit is contained in:
2025-05-14 16:14:01 +01:00
parent 80b1da5fa5
commit c8ce77259d
952 changed files with 51341 additions and 28699 deletions

View File

@@ -21,25 +21,48 @@
// $Id: bat.js 661 2012-08-27 11:26:39Z namiltd $
//
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang, createBar */
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
"use strict";
var bat_show = false, bat_table;
var bat_show = false;
/**
* insert content into table
* build the table where content is inserted
* @param {jQuery} xml plugin-XML
*/
function bat_populate(xml) {
function bat_buildTable(xml) {
var html = "", tree = [], closed = [], batcount = 0, index = 0, hostname = "";
bat_table.fnClearTable();
$("#Plugin_BAT #Plugin_BATTable").remove();
$("Plugins Plugin_BAT Bat", xml).each(function bat_getitem(idp) {
var DesignCapacity = "", DesignVoltage = "", BatteryType = "",RemainingCapacity = "", PresentVoltage = "", ChargingState = "", BatteryTemperature = "", BatteryCondition = "", CapacityUnit = "", CycleCount = "", DesignVoltageMax = "";
DesignCapacity = $(this).attr("DesignCapacity");
hostname = $("Plugins Plugin_BAT", xml).attr('Hostname');
if (hostname !== undefined) {
$('span[class=Hostname_BAT]').html(hostname);
}
html += " <div style=\"overflow-x:auto;\">\n";
html += " <table id=\"Plugin_BATTable\" class=\"tablemain\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(6, "BAT") + "</th>\n";
html += " <th style=\"width:31%;\">" + genlang(7, "BAT") + "</th>\n";
html += " <th></th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody class=\"tree\">\n";
$("Plugins Plugin_Bat Bat", xml).each(function bat_getbats(id) {
var name = "", DesignCapacity = 0, FullCapacity = 0, DesignVoltage = "", BatteryType = "", RemainingCapacity = 0, PresentVoltage = "", ChargingState = "", BatteryTemperature = "", BatteryCondition = "", CapacityUnit = "", CycleCount = "", DesignVoltageMax = "", Manufacturer = "", Model = "", SerialNumber = "";
name = $(this).attr("Name");
if (name === undefined) {
name = "Battery"+(batcount++);
}
DesignCapacity = parseInt($(this).attr("DesignCapacity"), 10);
FullCapacity = parseInt($(this).attr("FullCapacity"), 10);
DesignVoltage = $(this).attr("DesignVoltage");
BatteryType = $(this).attr("BatteryType");
RemainingCapacity = $(this).attr("RemainingCapacity");
RemainingCapacity = parseInt($(this).attr("RemainingCapacity"), 10);
PresentVoltage = $(this).attr("PresentVoltage");
ChargingState = $(this).attr("ChargingState");
BatteryTemperature = $(this).attr("BatteryTemperature");
@@ -47,77 +70,126 @@ function bat_populate(xml) {
CapacityUnit = $(this).attr("CapacityUnit");
CycleCount = $(this).attr("CycleCount");
DesignVoltageMax = $(this).attr("DesignVoltageMax");
Manufacturer = $(this).attr("Manufacturer");
Model = $(this).attr("Model");
SerialNumber = $(this).attr("SerialNumber");
if (CapacityUnit == undefined) {
html += " <tr><td colspan=\"3\"><div class=\"treediv\"><span class=\"treespanbold\">" + name + "</div></span></td></tr>\n";
index = tree.push(0);
if (Model !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(15, "BAT") + "</div></span></td><td>" + Model +"</td><td></td></tr>\n";
tree.push(index);
}
if (Manufacturer !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(14, "BAT") + "</div></span></td><td>" + Manufacturer +"</td><td></td></tr>\n";
tree.push(index);
}
if (SerialNumber !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(16, "BAT") + "</div></span></td><td>" + SerialNumber +"</td><td></td></tr>\n";
tree.push(index);
}
if (CapacityUnit === undefined) {
CapacityUnit = "mWh";
}
if ((CapacityUnit == "%") && (RemainingCapacity != undefined)) {
bat_table.fnAddData([genlang(4, true, "BAT"), createBar(round(parseInt(RemainingCapacity, 10),0)), '&nbsp;']);
} else if (DesignCapacity == undefined) {
if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' '+CapacityUnit, '&nbsp;']);
} else {
bat_table.fnAddData([genlang(3, true, "BAT"), DesignCapacity+' '+CapacityUnit, '&nbsp;']);
if (RemainingCapacity != undefined) bat_table.fnAddData([genlang(4, true, "BAT"), RemainingCapacity+' '+CapacityUnit, createBar(parseInt(DesignCapacity, 10) != 0 ? round(parseInt(RemainingCapacity, 10) / parseInt(DesignCapacity, 10) * 100, 0) : 0)]);
}
if (ChargingState != undefined) {
bat_table.fnAddData([genlang(9, true, "BAT"), ChargingState, '&nbsp;']);
}
if (DesignVoltage != undefined) {
if (DesignVoltageMax != undefined) {
bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltage+' mV', DesignVoltageMax+' mV']);
} else {
bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltage+' mV', '&nbsp;']);
if ((CapacityUnit == "%") && ($(this).attr("RemainingCapacity") !== undefined)) {
if (!isNaN(RemainingCapacity)) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(3, "BAT") + "</div></span></td><td>" + createBar(RemainingCapacity) +"</td><td></td></tr>\n";
tree.push(index);
}
} else {
if (!isNaN(DesignCapacity)) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(2, "BAT") + "</div></span></td><td>" + DesignCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
tree.push(index);
}
if (isNaN(FullCapacity)) {
if (!isNaN(RemainingCapacity)) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(3, "BAT") + "</div></span></td><td>" + RemainingCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
tree.push(index);
}
} else {
if (isNaN(DesignCapacity)) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "BAT") + "</div></span></td><td>" + FullCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
tree.push(index);
} else {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "BAT") + "</div></span></td><td>" + FullCapacity+' '+CapacityUnit +"</td><td>" + createBar(DesignCapacity !== 0 ? round(FullCapacity / DesignCapacity * 100, 0) : 0) + "</td></tr>\n";
tree.push(index);
}
if (!isNaN(RemainingCapacity)) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(3, "BAT") + "</div></span></td><td>" + RemainingCapacity+' '+CapacityUnit +"</td><td>" + createBar(FullCapacity !== 0 ? round(RemainingCapacity / FullCapacity * 100, 0) : 0) + "</td></tr>\n";
tree.push(index);
}
}
} else if (DesignVoltageMax != undefined) {
bat_table.fnAddData([genlang(5, true, "BAT"), DesignVoltageMax+' mV', '&nbsp;']);
}
if (PresentVoltage != undefined) {
bat_table.fnAddData([genlang(6, true, "BAT"), PresentVoltage+' mV', '&nbsp;']);
if (ChargingState !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(8, "BAT") + "</div></span></td><td>" + ChargingState +"</td><td></td></tr>\n";
tree.push(index);
}
if (BatteryType != undefined) {
bat_table.fnAddData([genlang(10, true, "BAT"), BatteryType, '&nbsp;']);
if (DesignVoltage !== undefined) {
if (DesignVoltageMax !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "BAT") + "</div></span></td><td>" + DesignVoltage+' mV' +"</td><td>" + DesignVoltageMax+' mV'+ "</td></tr>\n";
tree.push(index);
} else {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "BAT") + "</div></span></td><td>" + DesignVoltage+' mV' +"</td><td></td></tr>\n";
tree.push(index);
}
} else if (DesignVoltageMax !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "BAT") + "</div></span></td><td>" + DesignVoltageMax+' mV' +"</td><td></td></tr>\n";
tree.push(index);
}
if (BatteryTemperature != undefined) {
bat_table.fnAddData([genlang(11, true, "BAT"), formatTemp(BatteryTemperature, xml), '&nbsp;']);
if (PresentVoltage !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(5, "BAT") + "</div></span></td><td>" + PresentVoltage+' mV' +"</td><td></td></tr>\n";
tree.push(index);
}
if (BatteryCondition != undefined) {
bat_table.fnAddData([genlang(12, true, "BAT"), BatteryCondition, '&nbsp;']);
if (BatteryType !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(9, "BAT") + "</div></span></td><td>" + BatteryType +"</td><td></td></tr>\n";
tree.push(index);
}
if (CycleCount != undefined) {
bat_table.fnAddData([genlang(13, true, "BAT"), CycleCount, '&nbsp;']);
if (BatteryTemperature !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(10, "BAT") + "</div></span></td><td>" + formatTemp(BatteryTemperature, xml) +"</td><td></td></tr>\n";
tree.push(index);
}
if (BatteryCondition !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(11, "BAT") + "</div></span></td><td>" + BatteryCondition +"</td><td></td></tr>\n";
tree.push(index);
}
if (CycleCount !== undefined) {
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(12, "BAT") + "</div></span></td><td>" + CycleCount +"</td><td></td></tr>\n";
tree.push(index);
}
bat_show = true;
});
}
/**
* fill the plugin block with table structure
*/
function bat_buildTable() {
var html = "";
html += "<table id=\"Plugin_BATTable\" style=\"border-spacing:0;\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(7, true, "BAT") + "</th>\n";
html += " <th>" + genlang(8, true, "BAT") + "</th>\n";
html += " <th>&nbsp;</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody>\n";
html += " </tbody>\n";
html += "</table>\n";
html += " </tbody>\n";
html += " </table>\n";
html += " </div>\n";
$("#Plugin_BAT").append(html);
$("#Plugin_BATTable").jqTreeTable(tree, {
openImg: "./gfx/treeTable/tv-collapsable.gif",
shutImg: "./gfx/treeTable/tv-expandable.gif",
leafImg: "./gfx/treeTable/tv-item.gif",
lastOpenImg: "./gfx/treeTable/tv-collapsable-last.gif",
lastShutImg: "./gfx/treeTable/tv-expandable-last.gif",
lastLeafImg: "./gfx/treeTable/tv-item-last.gif",
vertLineImg: "./gfx/treeTable/vertline.gif",
blankImg: "./gfx/treeTable/blank.gif",
collapse: closed,
column: 0,
striped: true,
highlight: false,
state: false
});
}
/**
* load the xml via ajax
*/
function bat_request() {
$("#Reload_BATTable").attr("title", "reload");
$.ajax({
url: "xml.php?plugin=BAT",
dataType: "xml",
@@ -126,7 +198,7 @@ function bat_request() {
},
success: function bat_buildblock(xml) {
populateErrors(xml);
bat_populate(xml);
bat_buildTable(xml);
if (bat_show) {
plugin_translate("BAT");
$("#Plugin_BAT").show();
@@ -137,32 +209,12 @@ function bat_request() {
$(document).ready(function bat_buildpage() {
$("#footer").before(buildBlock("BAT", 1, true));
$("#Plugin_BAT").css("width", "451px");
bat_buildTable();
bat_table = $("#Plugin_BATTable").dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bProcessing": true,
"bAutoWidth": false,
"bStateSave": true,
"aoColumns": [{
"sType": 'span-string'
}, {
"sType": 'span-string'
}, {
"sType": 'span-string'
}]
});
$("#Plugin_BAT").addClass("halfsize");
bat_request();
$("#Reload_BATTable").click(function bat_reload(id) {
bat_request();
$("#Reload_BATTable").attr("title",datetime());
$(this).attr("title", datetime());
});
});

View File

@@ -1,29 +1,47 @@
function renderPlugin_bat(data) {
var batcount = 0;
var directives = {
RemainingCapacity: {
html: function () {
var CapacityUnit = (this["CapacityUnit"] !== undefined) ? this["CapacityUnit"] : 'mWh';
if ( CapacityUnit === "%" ) {
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width: ' + round(this["RemainingCapacity"],0) + '%;"></div>' +
'</div><div class="percent">' + round(this["RemainingCapacity"],0) + '%</div>';
} else {
return this["RemainingCapacity"] + String.fromCharCode(160) + CapacityUnit;
}
Name: {
text: function () {
return (this.Name !== undefined) ? this.Name : 'Battery'+(batcount++);
}
},
DesignCapacity: {
html: function () {
var CapacityUnit = (this["CapacityUnit"] !== undefined) ? this["CapacityUnit"] : 'mWh';
return this["DesignCapacity"] + String.fromCharCode(160) + CapacityUnit;
return this.DesignCapacity + String.fromCharCode(160) + this.CapacityUnit;
}
},
FullCapacity: {
html: function () {
return this.FullCapacity + String.fromCharCode(160) + this.CapacityUnit;
}
},
FullCapacityBar: {
html: function () {
if (( this.CapacityUnit !== "%" ) && (this.DesignCapacity !== undefined)){
var percent = (this.DesignCapacity > 0) ? round(100*this.FullCapacity/this.DesignCapacity, 0) : 0;
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width:' + percent + '%;"></div>' +
'</div><div class="percent">' + percent + '%</div>';
} else {
return '';
}
}
},
RemainingCapacity: {
html: function () {
if ( this.CapacityUnit === "%" ) {
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width:' + this.RemainingCapacity + '%;"></div>' +
'</div><div class="percent">' + this.RemainingCapacity + '%</div>';
} else {
return this.RemainingCapacity + String.fromCharCode(160) + this.CapacityUnit;
}
}
},
RemainingCapacityBar: {
html: function () {
var CapacityUnit = (this["CapacityUnit"] !== undefined) ? this["CapacityUnit"] : 'mWh';
if (( CapacityUnit !== "%" ) && (this["DesignCapacity"] !== undefined)){
var percent = (this["DesignCapacity"] != 0) ? round(100*this["RemainingCapacity"]/this["DesignCapacity"],0) : 0;
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width: ' + percent + '%;"></div>' +
if (( this.CapacityUnit !== "%" ) && (this.FullCapacity !== undefined)){
var percent = (this.FullCapacity > 0) ? round(100*this.RemainingCapacity/this.FullCapacity, 0) : 0;
return '<div class="progress"><div class="progress-bar progress-bar-info" style="width:' + percent + '%;"></div>' +
'</div><div class="percent">' + percent + '%</div>';
} else {
return '';
@@ -32,38 +50,106 @@ function renderPlugin_bat(data) {
},
PresentVoltage: {
text: function () {
return this['PresentVoltage'] + String.fromCharCode(160) + 'mV';
return this.PresentVoltage + String.fromCharCode(160) + 'mV';
}
},
BatteryTemperature: {
text: function () {
return formatTemp(this["BatteryTemperature"], data["Options"]["@attributes"]["tempFormat"]);
html: function () {
return formatTemp(this.BatteryTemperature, data.Options["@attributes"].tempFormat);
}
},
DesignVoltage: {
text: function () {
return this['DesignVoltage']+String.fromCharCode(160) + 'mV';
return this.DesignVoltage + String.fromCharCode(160) + 'mV';
}
},
DesignVoltageMax: {
text: function () {
return (this["DesignVoltageMax"] !== undefined) ? this['DesignVoltageMax']+String.fromCharCode(160) + 'mV' : '';
return (this.DesignVoltageMax !== undefined) ? this.DesignVoltageMax + String.fromCharCode(160) + 'mV' : '';
}
}
};
if ((data['Plugins']['Plugin_BAT'] !== undefined) && (data['Plugins']['Plugin_BAT']["Bat"] !== undefined) && (data['Plugins']['Plugin_BAT']["Bat"]["@attributes"] !== undefined)){
$('#bat').render(data['Plugins']['Plugin_BAT']["Bat"]["@attributes"], directives);
var attr = data['Plugins']['Plugin_BAT']["Bat"]["@attributes"];
for (bat_param in {DesignCapacity:0,RemainingCapacity:1,ChargingState:2,DesignVoltage:3,PresentVoltage:4,BatteryType:5,BatteryTemperature:6,BatteryCondition:7,CycleCount:8}) {
if (attr[bat_param] !== undefined) {
$('#bat_' + bat_param).show();
if (data.Plugins.Plugin_BAT !== undefined) {
var bats = items(data.Plugins.Plugin_BAT.Bat);
if (bats.length > 0) {
var html = "";
var paramlist = {Model:15,Manufacturer:14,SerialNumber:16,DesignCapacity:2,FullCapacity:13,RemainingCapacity:3,ChargingState:8,DesignVoltage:4,PresentVoltage:5,BatteryType:9,BatteryTemperature:10,BatteryCondition:11,CycleCount:12};
var paramlis2 = {FullCapacity:'FullCapacityBar',RemainingCapacity:'RemainingCapacityBar',DesignVoltage:'DesignVoltageMax'};
var i, proc_param;
for (i = 0; i < bats.length; i++) {
if (bats[i]["@attributes"].CapacityUnit === undefined) {
bats[i]["@attributes"].CapacityUnit = 'mWh';
} else if ((bats[i]["@attributes"].CapacityUnit === '%') && (bats[i]["@attributes"].RemainingCapacity !== undefined)) {
if (bats[i]["@attributes"].DesignCapacity !== undefined) {
delete bats[i]["@attributes"].DesignCapacity;
}
if (bats[i]["@attributes"].FullCapacity !== undefined) {
delete bats[i]["@attributes"].FullCapacity;
}
}
if ((bats[i]["@attributes"].DesignCapacity !== undefined) && isNaN(bats[i]["@attributes"].DesignCapacity = parseInt(bats[i]["@attributes"].DesignCapacity, 10))) {
delete bats[i]["@attributes"].DesignCapacity;
}
if ((bats[i]["@attributes"].FullCapacity !== undefined) && isNaN(bats[i]["@attributes"].FullCapacity = parseInt(bats[i]["@attributes"].FullCapacity, 10))) {
delete bats[i]["@attributes"].FullCapacity;
}
if ((bats[i]["@attributes"].RemainingCapacity !== undefined) && isNaN(bats[i]["@attributes"].RemainingCapacity = parseInt(bats[i]["@attributes"].RemainingCapacity, 10))) {
delete bats[i]["@attributes"].RemainingCapacity;
}
try {
html+="<tr id=\"bat-" + i + "\" class=\"treegrid-bat-" + i + "\" style=\"display:none;\" >";
html+="<td colspan=\"3\"><span class=\"treegrid-spanbold\" data-bind=\"Name\"></span></td>";
html+="</tr>";
for (proc_param in paramlist) {
if (bats[i]["@attributes"][proc_param] !== undefined) {
html+="<tr id=\"bat-" + i + "-" + proc_param + "\" class=\"treegrid-parent-bat-" + i + "\">";
html+="<td><span class=\"treegrid-spanbold\">" + genlang(paramlist[proc_param], 'bat') + "</span></td>";
html+="<td><span data-bind=\"" + proc_param + "\"></span></td>";
if (paramlis2[proc_param] !== undefined) {
html+="<td class=\"rightCell\"><span data-bind=\"" + paramlis2[proc_param] + "\"></span></td>";
} else {
html+="<td></td>";
}
html+="</tr>";
}
}
}
catch (err) {
$("#bat-" + i).hide();
}
}
$("#bat-data").empty().append(html);
for (i = 0; i < bats.length; i++) {
try {
$('#bat-'+ i).render(bats[i]["@attributes"], directives);
$("#bat-" + i).show();
for (proc_param in paramlist) {
if (bats[i]["@attributes"][proc_param] !== undefined) {
$('#bat-'+ i+ "-" + proc_param).render(bats[i]["@attributes"], directives);
}
}
}
catch (err) {
$("#bat-" + i).hide();
}
}
$('#bat').treegrid({
initialState: 'expanded',
expanderExpandedClass: 'normalicon normalicon-down',
expanderCollapsedClass: 'normalicon normalicon-right'
});
$('#block_bat').show();
} else {
$('#block_bat').hide();
}
if (attr["CapacityUnit"] === "%") {
$('#bat_DesignCapacity').hide();
}
$('#block_bat').show();
} else {
$('#block_bat').hide();
}