Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2781 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: stablebit.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 stablebit_show = false;
29
 
30
/**
31
 * build the table where content is inserted
32
 * @param {jQuery} xml plugin-XML
33
 */
34
function stablebit_buildTable(xml) {
35
    var html = "", tree = [], closed = [];
36
 
37
    $("#Plugin_StableBit #Plugin_StableBitTable").remove();
38
 
39
    html += "  <div style=\"overflow-x:auto;\">\n";
40
    html += "    <table id=\"Plugin_StableBitTable\" class=\"tablemain\">\n";
41
    html += "     <thead>\n";
42
    html += "      <tr>\n";
43
    html += "       <th>" + genlang(2, "StableBit") + "</th>\n";
44
    html += "       <th style=\"width:120px;\">" + genlang(3, "StableBit") + "</th>\n";
45
    html += "      </tr>\n";
46
    html += "     </thead>\n";
47
    html += "     <tbody class=\"tree\">\n";
48
 
49
    var index = 0;
50
 
51
    $("Plugins Plugin_StableBit Disk", xml).each(function stablebit_getdisks(id) {
52
        var name = "";
53
        name = $(this).attr("Name");
54
        if (name !== undefined) {
55
            var serialnumber = "", firmware = "", size = 0, powerstate = "", temperaturec = "",
56
            ishot = 0, issmartwarning = 0, issmartpastthresholds = 0, issmartpastadvisorythresholds = 0, 
57
            issmartfailurepredicted = 0, isdamaged = 0;
58
 
59
            html += "      <tr><td colspan=\"2\"><div class=\"treediv\"><span class=\"treespanbold\">" + name + "</div></span></td></tr>\n";
60
            index = tree.push(0);
61
 
62
            serialnumber = $(this).attr("SerialNumber");
63
            if (serialnumber !== undefined) {
64
                html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(4, "StableBit") + "</div></span></td><td>" + serialnumber +"</td></tr>\n";
65
                tree.push(index);
66
            }
67
            firmware = $(this).attr("Firmware");
68
            if (firmware !== undefined) {
69
                html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(5, "StableBit") + "</div></span></td><td>" + firmware +"</td></tr>\n";
70
                tree.push(index);
71
            }
72
            size = parseInt($(this).attr("Size"), 10);
73
            if (!isNaN(size)) {
74
                html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(6, "StableBit") + "</div></span></td><td>" + formatBytes(size, xml) +"</td></tr>\n";
75
                tree.push(index);
76
            }        
77
            powerstate = $(this).attr("PowerState");
78
            if (powerstate !== undefined) {
79
                html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(7, "StableBit") + "</div></span></td><td>" + powerstate +"</td></tr>\n";
80
                tree.push(index);
81
            }
82
            temperaturec = $(this).attr("TemperatureC");
83
            if (temperaturec !== undefined) {
84
                html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(8, "StableBit") + "</div></span></td><td>" + formatTemp(temperaturec, xml) +"</td></tr>\n";
85
                tree.push(index);
86
            }
87
            if ($(this).attr("IsHot") !== undefined) {
88
                ishot = parseInt($(this).attr("IsHot"), 10);
89
                if (!isNaN(ishot) && (ishot === 1)) {
90
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(9, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
91
                }
92
                else {
93
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(9, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
94
                }
95
                tree.push(index);
96
            }
97
            if ($(this).attr("IsSmartWarning") !== undefined) {
98
                issmartwarning = parseInt($(this).attr("IsSmartWarning"), 10);
99
                if (!isNaN(issmartwarning) && (issmartwarning === 1)) {
100
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(10, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
101
                }
102
                else {
103
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(10, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
104
                }
105
                tree.push(index);
106
            }
107
            if ($(this).attr("IsSmartPastThresholds") !== undefined) {
108
                issmartpastthresholds = parseInt($(this).attr("IsSmartPastThresholds"), 10);
109
                if (!isNaN(issmartpastthresholds) && (issmartpastthresholds === 1)) {
110
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(11, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
111
                }
112
                else {
113
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(11, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
114
                }
115
                tree.push(index);
116
            }
117
            if ($(this).attr("IsSmartPastAdvisoryThresholds") !== undefined) {
118
                issmartpastadvisorythresholds = parseInt($(this).attr("IsSmartPastAdvisoryThresholds"), 10);
119
                if (!isNaN(issmartpastadvisorythresholds) && (issmartpastadvisorythresholds === 1)) {
120
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(12, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
121
                }
122
                else {
123
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(12, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
124
                }
125
                tree.push(index);
126
            }
127
            if ($(this).attr("IsSmartFailurePredicted") !== undefined) {
128
                issmartfailurepredicted = parseInt($(this).attr("IsSmartFailurePredicted"), 10);
129
                if (!isNaN(issmartfailurepredicted) && (issmartfailurepredicted === 1)) {
130
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
131
                }
132
                else {
133
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(13, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
134
                }
135
                tree.push(index);
136
            }
137
            if ($(this).attr("IsDamaged") !== undefined) {
138
                isdamaged = parseInt($(this).attr("IsDamaged"), 10);
139
                if (!isNaN(isdamaged) && (isdamaged === 1)) {
140
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(14, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/on.gif\" alt=\"on\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
141
                }
142
                else {
143
                    html += "      <tr><td><div class=\"treediv\"><span class=\"treespan\">" + genlang(14, "StableBit") + "</div></span></td><td><img src=\"./plugins/stablebit/gfx/off.gif\" alt=\"off\" title=\"\" style=\"width:18px;\" /></td></tr>\n";
144
                }
145
                tree.push(index);
146
            }
147
 
148
            stablebit_show = true;
149
        }
150
    });
151
 
152
    html += "     </tbody>\n";
153
    html += "    </table>\n";
154
    html += "  </div>\n";
155
 
156
    $("#Plugin_StableBit").append(html);
157
 
158
    $("#Plugin_StableBitTable").jqTreeTable(tree, {
159
        openImg: "./gfx/treeTable/tv-collapsable.gif",
160
        shutImg: "./gfx/treeTable/tv-expandable.gif",
161
        leafImg: "./gfx/treeTable/tv-item.gif",
162
        lastOpenImg: "./gfx/treeTable/tv-collapsable-last.gif",
163
        lastShutImg: "./gfx/treeTable/tv-expandable-last.gif",
164
        lastLeafImg: "./gfx/treeTable/tv-item-last.gif",
165
        vertLineImg: "./gfx/treeTable/vertline.gif",
166
        blankImg: "./gfx/treeTable/blank.gif",
167
        collapse: closed,
168
        column: 0,
169
        striped: true,
170
        highlight: false,
171
        state: false
172
    });
173
 
174
}
175
 
176
/**
177
 * load the xml via ajax
178
 */
179
function stablebit_request() {
180
    $("#Reload_StableBitTable").attr("title", "reload");
181
    $.ajax({
182
        url: "xml.php?plugin=StableBit",
183
        dataType: "xml",
184
        error: function stablebit_error() {
185
            $.jGrowl("Error loading XML document for Plugin StableBit!");
186
        },
187
        success: function stablebit_buildblock(xml) {
188
            populateErrors(xml);
189
            stablebit_buildTable(xml);
190
            if (stablebit_show) {
191
                plugin_translate("StableBit");
192
                $("#Plugin_StableBit").show();
193
            }
194
        }
195
    });
196
}
197
 
198
$(document).ready(function stablebit_buildpage() {
199
    $("#footer").before(buildBlock("StableBit", 1, true));
200
    $("#Plugin_StableBit").css("width", "451px");
201
 
202
    stablebit_request();
203
 
204
    $("#Reload_StableBitTable").click(function stablebit_reload(id) {
205
        stablebit_request();
206
        $(this).attr("title", datetime());
207
    });
208
});