2789 |
rexy |
1 |
/***************************************************************************
|
|
|
2 |
* Copyright (C) 2008 by phpSysInfo - A PHP System Information Script *
|
|
|
3 |
* http://phpsysinfo.sourceforge.net/ *
|
|
|
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
8 |
* (at your option) any later version. *
|
|
|
9 |
* *
|
|
|
10 |
* This program is distributed in the hope that it will be useful, *
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
13 |
* GNU General Public License for more details. *
|
|
|
14 |
* *
|
|
|
15 |
* You should have received a copy of the GNU General Public License *
|
|
|
16 |
* along with this program; if not, write to the *
|
|
|
17 |
* Free Software Foundation, Inc., *
|
|
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
19 |
***************************************************************************/
|
|
|
20 |
//
|
|
|
21 |
// $Id: bat.js 661 2012-08-27 11:26:39Z namiltd $
|
|
|
22 |
//
|
|
|
23 |
|
|
|
24 |
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
|
|
|
25 |
|
|
|
26 |
"use strict";
|
|
|
27 |
|
|
|
28 |
var bat_show = false;
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* build the table where content is inserted
|
|
|
32 |
* @param {jQuery} xml plugin-XML
|
|
|
33 |
*/
|
|
|
34 |
function bat_buildTable(xml) {
|
|
|
35 |
var html = "", tree = [], closed = [], batcount = 0;
|
|
|
36 |
|
|
|
37 |
$("#Plugin_BAT #Plugin_BATTable").remove();
|
|
|
38 |
|
|
|
39 |
html += " <div style=\"overflow-x:auto;\">\n";
|
|
|
40 |
html += " <table id=\"Plugin_BATTable\" class=\"tablemain\">\n";
|
|
|
41 |
html += " <thead>\n";
|
|
|
42 |
html += " <tr>\n";
|
|
|
43 |
html += " <th>" + genlang(6, "BAT") + "</th>\n";
|
|
|
44 |
html += " <th style=\"width:120px;\">" + genlang(7, "BAT") + "</th>\n";
|
|
|
45 |
html += " <th></th>\n";
|
|
|
46 |
html += " </tr>\n";
|
|
|
47 |
html += " </thead>\n";
|
|
|
48 |
html += " <tbody class=\"tree\">\n";
|
|
|
49 |
|
|
|
50 |
var index = 0;
|
|
|
51 |
|
|
|
52 |
$("Plugins Plugin_Bat Bat", xml).each(function bat_getdisks(id) {
|
|
|
53 |
var name = "", DesignCapacity = "", FullCapacity = "", Capacity = "", DesignVoltage = "", BatteryType = "",RemainingCapacity = "", PresentVoltage = "", ChargingState = "", BatteryTemperature = "", BatteryCondition = "", CapacityUnit = "", CycleCount = "", DesignVoltageMax = "", Manufacturer = "", Model = "", SerialNumber = "";
|
|
|
54 |
name = $(this).attr("Name");
|
|
|
55 |
if (name === undefined) {
|
|
|
56 |
name = "Battery"+(batcount++);
|
|
|
57 |
}
|
|
|
58 |
DesignCapacity = $(this).attr("DesignCapacity");
|
|
|
59 |
FullCapacity = $(this).attr("FullCapacity");
|
|
|
60 |
DesignVoltage = $(this).attr("DesignVoltage");
|
|
|
61 |
BatteryType = $(this).attr("BatteryType");
|
|
|
62 |
RemainingCapacity = $(this).attr("RemainingCapacity");
|
|
|
63 |
PresentVoltage = $(this).attr("PresentVoltage");
|
|
|
64 |
ChargingState = $(this).attr("ChargingState");
|
|
|
65 |
BatteryTemperature = $(this).attr("BatteryTemperature");
|
|
|
66 |
BatteryCondition = $(this).attr("BatteryCondition");
|
|
|
67 |
CapacityUnit = $(this).attr("CapacityUnit");
|
|
|
68 |
CycleCount = $(this).attr("CycleCount");
|
|
|
69 |
DesignVoltageMax = $(this).attr("DesignVoltageMax");
|
|
|
70 |
Manufacturer = $(this).attr("Manufacturer");
|
|
|
71 |
Model = $(this).attr("Model");
|
|
|
72 |
SerialNumber = $(this).attr("SerialNumber");
|
|
|
73 |
|
|
|
74 |
html += " <tr><td colspan=\"3\"><div class=\"treediv\"><span class=\"treespanbold\">" + name + "</div></span></td></tr>\n";
|
|
|
75 |
index = tree.push(0);
|
|
|
76 |
|
|
|
77 |
if (Model !== undefined) {
|
|
|
78 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(15, "BAT") + "</div></span></td><td>" + Model +"</td><td></td></tr>\n";
|
|
|
79 |
tree.push(index);
|
|
|
80 |
}
|
|
|
81 |
if (Manufacturer !== undefined) {
|
|
|
82 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(14, "BAT") + "</div></span></td><td>" + Manufacturer +"</td><td></td></tr>\n";
|
|
|
83 |
tree.push(index);
|
|
|
84 |
}
|
|
|
85 |
if (SerialNumber !== undefined) {
|
|
|
86 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(16, "BAT") + "</div></span></td><td>" + SerialNumber +"</td><td></td></tr>\n";
|
|
|
87 |
tree.push(index);
|
|
|
88 |
}
|
|
|
89 |
if (CapacityUnit === undefined) {
|
|
|
90 |
CapacityUnit = "mWh";
|
|
|
91 |
}
|
|
|
92 |
if ((CapacityUnit == "%") && (RemainingCapacity !== undefined)) {
|
|
|
93 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(3, "BAT") + "</div></span></td><td>" + createBar(round(parseInt(RemainingCapacity, 10),0)) +"</td><td></td></tr>\n";
|
|
|
94 |
tree.push(index);
|
|
|
95 |
} else {
|
|
|
96 |
if (DesignCapacity !== undefined) {
|
|
|
97 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(2, "BAT") + "</div></span></td><td>" + DesignCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
|
|
|
98 |
tree.push(index);
|
|
|
99 |
}
|
|
|
100 |
if (FullCapacity === undefined) {
|
|
|
101 |
if (RemainingCapacity !== undefined) {
|
|
|
102 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(3, "BAT") + "</div></span></td><td>" + RemainingCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
|
|
|
103 |
tree.push(index);
|
|
|
104 |
}
|
|
|
105 |
} else {
|
|
|
106 |
if (DesignCapacity === undefined) {
|
|
|
107 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "BAT") + "</div></span></td><td>" + FullCapacity+' '+CapacityUnit +"</td><td></td></tr>\n";
|
|
|
108 |
tree.push(index);
|
|
|
109 |
} else {
|
|
|
110 |
html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "BAT") + "</div></span></td><td>" + FullCapacity+' '+CapacityUnit +"</td><td>" + createBar(parseInt(DesignCapacity, 10) !== 0 ? round(parseInt(FullCapacity, 10) / parseInt(DesignCapacity, 10) * 100, 0) : 0) + "td></tr>\n";
|
|
|
111 |
tree.push(index);
|
|
|
112 |
}
|
|
|
113 |
if (RemainingCapacity !== undefined) {
|
|
|
114 |
html += " " + genlang(3, "BAT") + "div></span>td><td>" + RemainingCapacity+' '+CapacityUnit +"</td> | " + createBar(parseInt(FullCapacity, 10) !== 0 ? round(parseInt(RemainingCapacity, 10) / parseInt(FullCapacity, 10) * 100, 0) : 0) + "</td></tr>\n"; |
|
|
|
115 |
| tree.push(index); |
|
|
|
116 |
| } |
|
|
|
117 |
| } |
|
|
|
118 |
| } |
|
|
|
119 |
| if (ChargingState !== undefined) { |
|
|
|
120 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(8, "BAT") + "</div></span></td><td>" + ChargingState +"</td><td></td></tr>\n"; |
|
|
|
121 |
| tree.push(index); |
|
|
|
122 |
| } |
|
|
|
123 |
| if (DesignVoltage !== undefined) { |
|
|
|
124 |
| if (DesignVoltageMax !== undefined) { |
|
|
|
125 |
| 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"; |
|
|
|
126 |
| tree.push(index); |
|
|
|
127 |
| } else { |
|
|
|
128 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "BAT") + "</div></span></td><td>" + DesignVoltage+' mV' +"</td><td></td></tr>\n"; |
|
|
|
129 |
| tree.push(index); |
|
|
|
130 |
| } |
|
|
|
131 |
| } else if (DesignVoltageMax !== undefined) { |
|
|
|
132 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "BAT") + "</div></span></td><td>" + DesignVoltageMax+' mV' +"</td><td></td></tr>\n"; |
|
|
|
133 |
| tree.push(index); |
|
|
|
134 |
| } |
|
|
|
135 |
| if (PresentVoltage !== undefined) { |
|
|
|
136 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(5, "BAT") + "</div></span></td><td>" + PresentVoltage+' mV' +"</td><td></td></tr>\n"; |
|
|
|
137 |
| tree.push(index); |
|
|
|
138 |
| } |
|
|
|
139 |
| if (BatteryType !== undefined) { |
|
|
|
140 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(9, "BAT") + "</div></span></td><td>" + BatteryType +"</td><td></td></tr>\n"; |
|
|
|
141 |
| tree.push(index); |
|
|
|
142 |
| } |
|
|
|
143 |
| if (BatteryTemperature !== undefined) { |
|
|
|
144 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(10, "BAT") + "</div></span></td><td>" + formatTemp(BatteryTemperature, xml) +"</td><td></td></tr>\n"; |
|
|
|
145 |
| tree.push(index); |
|
|
|
146 |
| } |
|
|
|
147 |
| if (BatteryCondition !== undefined) { |
|
|
|
148 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(11, "BAT") + "</div></span></td><td>" + BatteryCondition +"</td><td></td></tr>\n"; |
|
|
|
149 |
| tree.push(index); |
|
|
|
150 |
| } |
|
|
|
151 |
| if (CycleCount !== undefined) { |
|
|
|
152 |
| html += " <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(12, "BAT") + "</div></span></td><td>" + CycleCount +"</td><td></td></tr>\n"; |
|
|
|
153 |
| tree.push(index); |
|
|
|
154 |
| } |
|
|
|
155 |
|
|
|
156 |
| bat_show = true; |
|
|
|
157 |
| }); |
|
|
|
158 |
|
|
|
159 |
| html += " </tbody>\n"; |
|
|
|
160 |
| html += " </table>\n"; |
|
|
|
161 |
| html += " </div>\n"; |
|
|
|
162 |
|
|
|
163 |
| $("#Plugin_BAT").append(html); |
|
|
|
164 |
|
|
|
165 |
| $("#Plugin_BATTable").jqTreeTable(tree, { |
|
|
|
166 |
| openImg: "./gfx/treeTable/tv-collapsable.gif", |
|
|
|
167 |
| shutImg: "./gfx/treeTable/tv-expandable.gif", |
|
|
|
168 |
| leafImg: "./gfx/treeTable/tv-item.gif", |
|
|
|
169 |
| lastOpenImg: "./gfx/treeTable/tv-collapsable-last.gif", |
|
|
|
170 |
| lastShutImg: "./gfx/treeTable/tv-expandable-last.gif", |
|
|
|
171 |
| lastLeafImg: "./gfx/treeTable/tv-item-last.gif", |
|
|
|
172 |
| vertLineImg: "./gfx/treeTable/vertline.gif", |
|
|
|
173 |
| blankImg: "./gfx/treeTable/blank.gif", |
|
|
|
174 |
| collapse: closed, |
|
|
|
175 |
| column: 0, |
|
|
|
176 |
| striped: true, |
|
|
|
177 |
| highlight: false, |
|
|
|
178 |
| state: false |
|
|
|
179 |
| }); |
|
|
|
180 |
|
|
|
181 |
| } |
|
|
|
182 |
|
|
|
183 |
| /** |
|
|
|
184 |
| * load the xml via ajax |
|
|
|
185 |
| */ |
|
|
|
186 |
| function bat_request() { |
|
|
|
187 |
| $("#Reload_BATTable").attr("title", "reload"); |
|
|
|
188 |
| $.ajax({ |
|
|
|
189 |
| url: "xml.php?plugin=BAT", |
|
|
|
190 |
| dataType: "xml", |
|
|
|
191 |
| error: function bat_error() { |
|
|
|
192 |
| $.jGrowl("Error loading XML document for Plugin BAT!"); |
|
|
|
193 |
| }, |
|
|
|
194 |
| success: function bat_buildblock(xml) { |
|
|
|
195 |
| populateErrors(xml); |
|
|
|
196 |
| bat_buildTable(xml); |
|
|
|
197 |
| if (bat_show) { |
|
|
|
198 |
| plugin_translate("BAT"); |
|
|
|
199 |
| $("#Plugin_BAT").show(); |
|
|
|
200 |
| } |
|
|
|
201 |
| } |
|
|
|
202 |
| }); |
|
|
|
203 |
| } |
|
|
|
204 |
|
|
|
205 |
| $(document).ready(function bat_buildpage() { |
|
|
|
206 |
| $("#footer").before(buildBlock("BAT", 1, true)); |
|
|
|
207 |
| $("#Plugin_BAT").css("width", "451px"); |
|
|
|
208 |
|
|
|
209 |
| bat_request(); |
|
|
|
210 |
|
|
|
211 |
| $("#Reload_BATTable").click(function bat_reload(id) { |
|
|
|
212 |
| bat_request(); |
|
|
|
213 |
| $(this).attr("title", datetime()); |
|
|
|
214 |
| }); |
|
|
|
215 |
| }); |
|