Subversion Repositories ALCASAR

Rev

Rev 2788 | Rev 3037 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2788 rexy 1
var langxml = [], langarr = [], current_language = "", plugins = [], blocks = [], plugin_liste = [],
2
     showCPUListExpanded, showCPUInfoExpanded, showNetworkInfosExpanded, showNetworkActiveSpeed, showCPULoadCompact, oldnetwork = [], refrTimer;
3
 
4
/**
5
 * generate a cookie, if not exist, and add an entry to it<br><br>
6
 * inspired by <a href="http://www.quirksmode.org/js/cookies.html">http://www.quirksmode.org/js/cookies.html</a>
7
 * @param {String} name name that holds the value
8
 * @param {String} value value that needs to be stored
9
 * @param {Number} days how many days the entry should be valid in the cookie
10
 */
11
function createCookie(name, value, days) {
12
    var date = new Date(), expires = "";
13
    if (days) {
14
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
15
        if (typeof(date.toUTCString)==="function") {
16
            expires = "; expires=" + date.toUTCString();
17
        } else {
18
            //deprecated
19
            expires = "; expires=" + date.toGMTString();
20
        }
21
    } else {
22
        expires = "";
23
    }
2976 rexy 24
    document.cookie = name + "=" + value + expires + "; path=/; samesite=strict";
2788 rexy 25
}
26
 
27
/**
28
 * read a value out of a cookie and return the value<br><br>
29
 * inspired by <a href="http://www.quirksmode.org/js/cookies.html">http://www.quirksmode.org/js/cookies.html</a>
30
 * @param {String} name name of the value that should be retrieved
31
 * @return {String}
32
 */
33
function readCookie(name) {
34
    var nameEQ = "", ca = [], c = '';
35
    nameEQ = name + "=";
36
    ca = document.cookie.split(';');
37
    for (var i = 0; i < ca.length; i++) {
38
        c = ca[i];
39
        while (c.charAt(0) === ' ') {
40
            c = c.substring(1, c.length);
41
        }
42
        if (!c.indexOf(nameEQ)) {
43
            return c.substring(nameEQ.length, c.length);
44
        }
45
    }
46
    return null;
47
}
48
 
49
/**
50
 * activates a given style and disables the old one in the document
51
 * @param {String} template template that should be activated
52
 */
53
function switchStyle(template) {
54
    $("#PSI_Template")[0].setAttribute('href', 'templates/' + template + "_bootstrap.css");
55
}
56
 
57
/**
58
 * load the given translation an translate the entire page<br><br>retrieving the translation is done through a
59
 * ajax call
60
 * @private
61
 * @param {String} plugin if plugin is given, the plugin translation file will be read instead of the main translation file
62
 * @param {String} langarrId internal plugin name
63
 * @return {jQuery} translation jQuery-Object
64
 */
65
function getLanguage(plugin, langarrId) {
66
    var getLangUrl = "";
67
    if (current_language) {
68
        getLangUrl = 'language/language.php?lang=' + current_language;
69
        if (plugin) {
70
            getLangUrl += "&plugin=" + plugin;
71
        }
72
    } else {
73
        getLangUrl = 'language/language.php';
74
        if (plugin) {
75
            getLangUrl += "?plugin=" + plugin;
76
        }
77
    }
78
    $.ajax({
79
        url: getLangUrl,
80
        type: 'GET',
81
        dataType: 'xml',
82
        timeout: 100000,
83
        error: function error() {
84
            $("#errors").append("<li><b>Error loading language</b> - " + getLangUrl + "</li><br>");
85
            $("#errorbutton").attr('data-toggle', 'modal');
86
            $("#errorbutton").css('cursor', 'pointer');
87
            $("#errorbutton").css("visibility", "visible");
88
        },
89
        success: function buildblocks(xml) {
90
            var idexp;
91
            langxml[langarrId] = xml;
92
            if (langarr[langarrId] === undefined) {
93
                langarr.push(langarrId);
94
                langarr[langarrId] = [];
95
            }
96
            $("expression", langxml[langarrId]).each(function langstore(id) {
97
                idexp = $("expression", xml).get(id);
98
                langarr[langarrId][this.getAttribute('id')] = $("exp", idexp).text().toString().replace(/\//g, "/<wbr>");
99
            });
100
            changeSpanLanguage(plugin);
101
        }
102
    });
103
}
104
 
105
/**
106
 * generate a span tag
107
 * @param {Number} id translation id in the xml file
108
 * @param {String} [plugin] name of the plugin for which the tag should be generated
109
 * @return {String} string which contains generated span tag for translation string
110
 */
111
function genlang(id, plugin) {
112
    var html = "", idString = "", plugname = "",
113
        langarrId = current_language + "_";
114
 
115
    if (plugin === undefined) {
116
        plugname = "";
117
        langarrId += "phpSysInfo";
118
    } else {
119
        plugname = plugin.toLowerCase();
120
        langarrId += plugname;
121
    }
122
 
123
    if (id < 100) {
124
        if (id < 10) {
125
            idString = "00" + id.toString();
126
        } else {
127
            idString = "0" + id.toString();
128
        }
129
    } else {
130
        idString = id.toString();
131
    }
132
    if (plugin) {
133
        idString = "plugin_" + plugname + "_" + idString;
134
    }
135
 
136
    html += "<span class=\"lang_" + idString + "\">";
137
 
138
    if ((langxml[langarrId] !== undefined) && (langarr[langarrId] !== undefined)) {
139
        html += langarr[langarrId][idString];
140
    }
141
 
142
    html += "</span>";
143
 
144
    return html;
145
}
146
 
147
/**
148
 * translates all expressions based on the translation xml file<br>
149
 * translation expressions must be in the format &lt;span class="lang_???"&gt;&lt;/span&gt;, where ??? is
150
 * the number of the translated expression in the xml file<br><br>if a translated expression is not found in the xml
151
 * file nothing would be translated, so the initial value which is inside the span tag is displayed
152
 * @param {String} [plugin] name of the plugin
153
 */
154
function changeLanguage(plugin) {
155
    var langarrId = current_language + "_";
156
 
157
    if (plugin === undefined) {
158
        langarrId += "phpSysInfo";
159
    } else {
160
        langarrId += plugin;
161
    }
162
 
163
    if (langxml[langarrId] !== undefined) {
164
        changeSpanLanguage(plugin);
165
    } else {
166
        langxml.push(langarrId);
167
        getLanguage(plugin, langarrId);
168
    }
169
}
170
 
171
function changeSpanLanguage(plugin) {
172
    var langId = "", langStr = "", langarrId = current_language + "_";
173
 
174
    if (plugin === undefined) {
175
        langarrId += "phpSysInfo";
176
        $('span[class*=lang_]').each(function translate(i) {
177
            langId = this.className.substring(5);
178
            if (langId.indexOf('plugin_') !== 0) { //does not begin with plugin_
179
                langStr = langarr[langarrId][langId];
180
                if (langStr !== undefined) {
181
                    if (langStr.length > 0) {
182
                        this.innerHTML = langStr;
183
                    }
184
                }
185
            }
186
        });
187
        $("#select").css( "display", "table-cell" ); //show if any language loaded
188
        $("#output").show();
189
    } else {
190
        langarrId += plugin;
191
        $('span[class*=lang_plugin_'+plugin.toLowerCase()+'_]').each(function translate(i) {
192
            langId = this.className.substring(5);
193
            langStr = langarr[langarrId][langId];
194
            if (langStr !== undefined) {
195
                if (langStr.length > 0) {
196
                    this.innerHTML = langStr;
197
                }
198
            }
199
        });
200
        $('#panel_'+plugin.toLowerCase()).show(); //show plugin if any language loaded
201
    }
202
}
203
 
204
function reload(initiate) {
205
    $("#errorbutton").css("visibility", "hidden");
206
    $("#errorbutton").css('cursor', 'default');
207
    $("#errorbutton").attr('data-toggle', '');
208
    $("#errors").empty();
209
    $.ajax({
210
        dataType: "json",
211
        url: "xml.php?json",
212
        error: function(jqXHR, status, thrownError) {
213
            if ((status === "parsererror") && (typeof(xmlDoc = $.parseXML(jqXHR.responseText)) === "object")) {
214
                var errs = 0;
215
                try {
216
                    $(xmlDoc).find("Error").each(function() {
217
                        $("#errors").append("<li><b>"+$(this)[0].attributes.Function.nodeValue+"</b> - "+$(this)[0].attributes.Message.nodeValue.replace(/\n/g, "<br>")+"</li><br>");
218
                        errs++;
219
                    });
220
                }
221
                catch (err) {
222
                }
223
                if (errs > 0) {
224
                    $("#errorbutton").attr('data-toggle', 'modal');
225
                    $("#errorbutton").css('cursor', 'pointer');
226
                    $("#errorbutton").css("visibility", "visible");
227
                }
228
            }
229
        },
230
        success: function (data) {
231
//            console.log(data);
232
//            data_dbg = data;
233
            if ((typeof(initiate) === 'boolean') && (data.Options !== undefined) && (data.Options["@attributes"] !== undefined) && ((refrtime = data.Options["@attributes"].refresh) !== undefined) && (refrtime !== "0")) {
234
                    if ((initiate === false) && (typeof(refrTimer) === 'number')) {
235
                        clearInterval(refrTimer);
236
                    }
237
                    refrTimer = setInterval(reload, refrtime);
238
            }
239
            renderErrors(data);
240
            renderVitals(data);
241
            renderHardware(data);
242
            renderMemory(data);
243
            renderFilesystem(data);
244
            renderNetwork(data);
245
            renderVoltage(data);
246
            renderTemperature(data);
247
            renderFans(data);
248
            renderPower(data);
249
            renderCurrent(data);
250
            renderOther(data);
251
            renderUPS(data);
252
            changeLanguage();
253
        }
254
    });
255
 
256
    for (var i = 0; i < plugins.length; i++) {
257
        plugin_request(plugins[i]);
258
        if ($("#reload_"+plugins[i]).length > 0) {
259
            $("#reload_"+plugins[i]).attr("title", "reload");
260
        }
261
 
262
    }
263
 
264
    if ((typeof(initiate) === 'boolean') && (initiate === true)) {
265
        for (var j = 0; j < plugins.length; j++) {
266
            if ($("#reload_"+plugins[j]).length > 0) {
267
                $("#reload_"+plugins[j]).click(clickfunction());
268
            }
269
        }
270
    }
271
}
272
 
273
function clickfunction(){
274
    return function(){
275
        plugin_request(this.id.substring(7)); //cut "reload_" from name
276
        $(this).attr("title", datetime());
277
    };
278
}
279
 
280
/**
281
 * load the plugin json via ajax
282
 */
283
function plugin_request(pluginname) {
284
 
285
    $.ajax({
286
         dataType: "json",
287
         url: "xml.php?plugin=" + pluginname + "&json",
288
         pluginname: pluginname,
289
         success: function (data) {
290
            try {
2976 rexy 291
                for (var propertyName in data.Plugins) {
292
                    if ((data.Plugins[propertyName]["@attributes"] !== undefined) && 
293
                       ((hostname = data.Plugins[propertyName]["@attributes"]["Hostname"]) !== undefined)) {
294
                        $('span[class=hostname_' + pluginname + ']').html(hostname);
295
                    }
296
                    break;
297
                }
2788 rexy 298
                // dynamic call
299
                window['renderPlugin_' + this.pluginname](data);
300
                changeLanguage(this.pluginname);
301
                plugin_liste.pushIfNotExist(this.pluginname);
302
            }
303
            catch (err) {
304
            }
305
            renderErrors(data);
306
        }
307
    });
308
}
309
 
310
 
311
$(document).ready(function () {
312
    var old_template = null, cookie_template = null, cookie_language = null, plugtmp = "", blocktmp = "", ua = null, useragent = navigator.userAgent;
313
 
314
    if ($("#hideBootstrapLoader").val().toString()!=="true") {
315
        $(document).ajaxStart(function () {
316
            $("#loader").css("visibility", "visible");
317
        });
318
        $(document).ajaxStop(function () {
319
            $("#loader").css("visibility", "hidden");
320
        });
321
    }
322
 
2976 rexy 323
    if ((ua=useragent.match(/Version\/(\d+)\.[\d\.]+ (Mobile\/\S+ )?Safari\//)) !== null) {
324
        if (ua[1]<=5) {
325
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari5.css');
326
        } else if (ua[1]<=8) {
327
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari8.css');
328
        }
329
    } else if ((ua=useragent.match(/Firefox\/(\d+)\.[\d\.]+/))  !== null) {
2788 rexy 330
        if (ua[1]<=15) {
331
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox15.css');
332
        } else if (ua[1]<=20) {
333
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox20.css');
334
        } else if (ua[1]<=27) {
335
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox27.css');
336
        } else if (ua[1]==28) {
337
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox28.css');
338
        }
2976 rexy 339
    } else if ((ua=useragent.match(/Midori\/(\d+)\.?(\d+)?/))  !== null) {
340
        if ((ua[1]==0) && (ua.length==3) && (ua[2]<=4)) {
341
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori04.css');
342
        } else if ((ua[1]==0) && (ua.length==3) && (ua[2]==5)) {
343
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori05.css');
344
        }
345
    } else if ((ua=useragent.match(/Chrome\/(\d+)\.[\d\.]+/))  !== null) {
346
        if (ua[1]<=25) {
347
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome25.css');
348
        } else if (ua[1]<=28) {
349
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome28.css');
350
        }
2788 rexy 351
    }
352
 
353
    $(window).resize();
354
 
355
    sorttable.init();
356
 
357
    showCPUListExpanded = $("#showCPUListExpanded").val().toString()==="true";
358
    showCPUInfoExpanded = $("#showCPUInfoExpanded").val().toString()==="true";
359
    showNetworkInfosExpanded = $("#showNetworkInfosExpanded").val().toString()==="true";
360
    showCPULoadCompact = $("#showCPULoadCompact").val().toString()==="true";
361
    switch ($("#showNetworkActiveSpeed").val().toString()) {
362
        case "bps":  showNetworkActiveSpeed = 2;
363
                      break;
364
        case "true": showNetworkActiveSpeed = 1;
365
                      break;
366
        default:     showNetworkActiveSpeed = 0;
367
    }
368
 
369
    blocktmp = $("#blocks").val().toString();
370
    if (blocktmp.length >0 ){
371
        if (blocktmp === "true") {
372
            blocks[0] = "true";
373
        } else {
374
            blocks = blocktmp.split(',');
375
            var j = 0;
376
            for (var i = 0; i < blocks.length; i++) {
377
                if ($("#block_"+blocks[i]).length > 0) {
378
                    $("#output").children().eq(j).before($("#block_"+blocks[i]));
379
                    j++;
380
                }
381
            }
382
        }
383
    }
384
 
385
    plugtmp = $("#plugins").val().toString();
386
    if (plugtmp.length >0 ){
387
        plugins = plugtmp.split(',');
388
    }
389
 
390
 
391
    if ($("#language option").length < 2) {
392
        current_language = $("#language").val().toString();
393
/* not visible any objects
394
        changeLanguage();
395
*/
396
/* plugin_liste not initialized yet
397
        for (var i = 0; i < plugin_liste.length; i++) {
398
            changeLanguage(plugin_liste[i]);
399
        }
400
*/
401
    } else {
402
        cookie_language = readCookie("psi_language");
403
        if (cookie_language !== null) {
404
            current_language = cookie_language;
405
            $("#language").val(current_language);
406
        } else {
407
            current_language = $("#language").val().toString();
408
        }
409
/* not visible any objects
410
        changeLanguage();
411
*/
412
/* plugin_liste not initialized yet
413
        for (var i = 0; i < plugin_liste.length; i++) {
414
            changeLanguage(plugin_liste[i]);
415
        }
416
*/
417
        $("#langblock").css( "display", "inline-block" );
418
 
419
        $("#language").change(function changeLang() {
420
            current_language = $("#language").val().toString();
421
            createCookie('psi_language', current_language, 365);
422
            changeLanguage();
423
            for (var i = 0; i < plugin_liste.length; i++) {
424
                changeLanguage(plugin_liste[i]);
425
            }
426
            return false;
427
        });
428
    }
429
    if ($("#template option").length < 2) {
430
        switchStyle($("#template").val().toString());
431
    } else {
432
        cookie_template = readCookie("psi_bootstrap_template");
433
        if (cookie_template !== null) {
434
            old_template = $("#template").val();
435
            $("#template").val(cookie_template);
436
            if ($("#template").val() === null) {
437
                $("#template").val(old_template);
438
            }
439
        }
440
        switchStyle($("#template").val().toString());
441
 
442
        $("#tempblock").css( "display", "inline-block" );
443
 
444
        $("#template").change(function changeTemplate() {
445
            switchStyle($("#template").val().toString());
446
            createCookie('psi_bootstrap_template', $("#template").val().toString(), 365);
447
            return false;
448
        });
449
    }
450
 
451
    reload(true);
452
 
453
    $(".logo").click(function () {
454
        reload(false);
455
    });
456
});
457
 
458
Array.prototype.push_attrs=function(element) {
459
    for (var i = 0; i < element.length ; i++) {
460
        this.push(element[i]["@attributes"]);
461
    }
462
    return i;
463
};
464
 
465
function full_addr(ip_string) {
466
    var wrongvalue = false;
467
    ip_string = $.trim(ip_string).toLowerCase();
468
    // ipv4 notation
469
    if (ip_string.match(/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$)/)) {
470
        ip_string ='::ffff:' + ip_string;
471
    }
472
    // replace ipv4 address if any
473
    var ipv4 = ip_string.match(/(.*:)([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$)/);
474
    if (ipv4) {
475
        ip_string = ipv4[1];
476
        ipv4 = ipv4[2].match(/[0-9]+/g);
477
        for (var i = 0;i < 4;i ++) {
2976 rexy 478
            var byte = parseInt(ipv4[i], 10);
2788 rexy 479
            if (byte<256) {
480
                ipv4[i] = ("0" + byte.toString(16)).substr(-2);
481
            } else {
482
                wrongvalue = true;
483
                break;
484
            }
485
        }
486
        if (wrongvalue) {
487
            ip_string = '';
488
        } else {
489
            ip_string += ipv4[0] + ipv4[1] + ':' + ipv4[2] + ipv4[3];
490
        }
491
    }
492
 
493
    if (ip_string === '') {
494
        return '';
495
    }
496
    // take care of leading and trailing ::
497
    ip_string = ip_string.replace(/^:|:$/g, '');
498
 
499
    var ipv6 = ip_string.split(':');
500
 
501
    for (var li = 0; li < ipv6.length; li ++) {
502
        var hex = ipv6[li];
503
        if (hex !== "") {
504
            if (!hex.match(/^[0-9a-f]{1,4}$/)) {
505
                wrongvalue = true;
506
                break;
507
            }
508
            // normalize leading zeros
509
            ipv6[li] = ("0000" + hex).substr(-4);
510
        }
511
        else {
512
            // normalize grouped zeros ::
513
            hex = [];
514
            for (var j = ipv6.length; j <= 8; j ++) {
515
                hex.push('0000');
516
            }
517
            ipv6[li] = hex.join(':');
518
        }
519
    }
520
    if (!wrongvalue) {
521
        var out = ipv6.join(':');
522
        if (out.length == 39) {
523
            return out;
524
        } else {
525
            return '';
526
        }
527
    } else {
528
        return '';
529
    }
530
}
531
 
532
sorttable.sort_ip=function(a,b) {
533
    var x = full_addr(a[0]);
534
    var y = full_addr(b[0]);
535
    if ((x === '') || (y === '')) {
536
        x = a[0];
537
        y = b[0];
538
    }
539
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
540
};
541
 
542
function items(data) {
543
    if (data !== undefined) {
544
        if ((data.length > 0) &&  (data[0] !== undefined) && (data[0]["@attributes"] !== undefined)) {
545
            return data;
546
        } else if (data["@attributes"] !== undefined ) {
547
            return [data];
548
        } else {
549
            return [];
550
        }
551
    } else {
552
        return [];
553
    }
554
}
555
 
556
function renderVitals(data) {
557
    var hostname = "", ip = "";
558
 
559
    if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('vitals', blocks) < 0))) {
560
        $("#block_vitals").remove();
561
        if ((data.Vitals !== undefined) && (data.Vitals["@attributes"] !== undefined) && ((hostname = data.Vitals["@attributes"].Hostname) !== undefined) && ((ip = data.Vitals["@attributes"].IPAddr) !== undefined)) {
562
            document.title = "System information: " + hostname + " (" + ip + ")";
563
        }
564
        return;
565
    }
566
 
567
    var directives = {
568
        Uptime: {
569
            html: function () {
570
                return formatUptime(this.Uptime);
571
            }
572
        },
573
        LastBoot: {
574
            text: function () {
575
                var lastboot;
576
                var timestamp = 0;
577
                var datetimeFormat;
578
                if ((data.Generation !== undefined) && (data.Generation["@attributes"] !== undefined) && (data.Generation["@attributes"].timestamp !== undefined) ) {
2976 rexy 579
                    timestamp = parseInt(data.Generation["@attributes"].timestamp, 10) * 1000; //server time
2788 rexy 580
                    if (isNaN(timestamp)) timestamp = Number(new Date()); //client time
581
                } else {
582
                    timestamp = Number(new Date()); //client time
583
                }
2976 rexy 584
                lastboot = new Date(timestamp - (parseInt(this.Uptime, 10) * 1000));
2788 rexy 585
                if (((datetimeFormat = data.Options["@attributes"].datetimeFormat) !== undefined) && (datetimeFormat.toLowerCase() === "locale")) {
586
                    return lastboot.toLocaleString();
587
                } else {
588
                    if (typeof(lastboot.toUTCString) === "function") {
589
                        return lastboot.toUTCString();
590
                    } else {
591
                    //deprecated
592
                        return lastboot.toGMTString();
593
                    }
594
                }
595
            }
596
        },
597
        Distro: {
598
            html: function () {
599
                return '<table class="borderless table-hover table-nopadding" style="width:100%;"><tr><td style="padding-right:4px!important;width:32px;"><img src="gfx/images/' + this.Distroicon + '" alt="" style="width:32px;height:32px;" /></td><td style="vertical-align:middle;">' + this.Distro + '</td></tr></table>';
600
            }
601
        },
602
        OS: {
603
            html: function () {
604
                return '<table class="borderless table-hover table-nopadding" style="width:100%;"><tr><td style="padding-right:4px!important;width:32px;"><img src="gfx/images/' + this.OS + '.png" alt="" style="width:32px;height:32px;" /></td><td style="vertical-align:middle;">' + this.OS + '</td></tr></table>';
605
            }
606
        },
607
        LoadAvg: {
608
            html: function () {
609
                if (this.CPULoad !== undefined) {
610
                    return '<table class="borderless table-hover table-nopadding" style="width:100%;"><tr><td style="padding-right:4px!important;width:50%;">'+this.LoadAvg + '</td><td><div class="progress">' +
611
                        '<div class="progress-bar progress-bar-info" style="width:' + round(this.CPULoad,0) + '%;"></div>' +
612
                        '</div><div class="percent">' + round(this.CPULoad,0) + '%</div></td></tr></table>';
613
                } else {
614
                    return this.LoadAvg;
615
                }
616
            }
617
        },
618
        Processes: {
619
            html: function () {
620
                var processes = "", p111 = 0, p112 = 0, p113 = 0, p114 = 0, p115 = 0, p116 = 0;
621
                var not_first = false;
2976 rexy 622
                processes = parseInt(this.Processes, 10);
2788 rexy 623
                if (this.ProcessesRunning !== undefined) {
2976 rexy 624
                    p111 = parseInt(this.ProcessesRunning, 10);
2788 rexy 625
                }
626
                if (this.ProcessesSleeping !== undefined) {
2976 rexy 627
                    p112 = parseInt(this.ProcessesSleeping, 10);
2788 rexy 628
                }
629
                if (this.ProcessesStopped !== undefined) {
2976 rexy 630
                    p113 = parseInt(this.ProcessesStopped, 10);
2788 rexy 631
                }
632
                if (this.ProcessesZombie !== undefined) {
2976 rexy 633
                    p114 = parseInt(this.ProcessesZombie, 10);
2788 rexy 634
                }
635
                if (this.ProcessesWaiting !== undefined) {
2976 rexy 636
                    p115 = parseInt(this.ProcessesWaiting, 10);
2788 rexy 637
                }
638
                if (this.ProcessesOther !== undefined) {
2976 rexy 639
                    p116 = parseInt(this.ProcessesOther, 10);
2788 rexy 640
                }
641
                if (p111 || p112 || p113 || p114 || p115 || p116) {
642
                    processes += " (";
643
                    for (var proc_type in {111:0,112:1,113:2,114:3,115:4,116:5}) {
644
                        if (eval("p" + proc_type)) {
645
                            if (not_first) {
646
                                processes += ", ";
647
                            }
648
                            processes += eval("p" + proc_type) + String.fromCharCode(160) + genlang(proc_type);
649
                            not_first = true;
650
                        }
651
                    }
652
                    processes += ")";
653
                }
654
                return processes;
655
            }
656
        }
657
    };
658
 
659
    if (data.Vitals["@attributes"].SysLang === undefined) {
660
        $("#tr_SysLang").hide();
661
    }
662
    if (data.Vitals["@attributes"].CodePage === undefined) {
663
        $("#tr_CodePage").hide();
664
    }
665
    if (data.Vitals["@attributes"].Processes === undefined) {
666
        $("#tr_Processes").hide();
667
    }
668
    $('#vitals').render(data.Vitals["@attributes"], directives);
669
 
670
    if ((data.Vitals !== undefined) && (data.Vitals["@attributes"] !== undefined) && ((hostname = data.Vitals["@attributes"].Hostname) !== undefined) && ((ip = data.Vitals["@attributes"].IPAddr) !== undefined)) {
671
        document.title = "System information: " + hostname + " (" + ip + ")";
672
    }
673
 
674
    $("#block_vitals").show();
675
}
676
 
677
function renderHardware(data) {
678
    var hw_type, datas, proc_param, i;
679
 
680
    if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('hardware', blocks) < 0))) {
681
        $("#block_hardware").remove();
682
        return;
683
    }
684
 
685
    var directives = {
686
        Model: {
687
            text: function () {
688
                return this.Model;
689
            }
690
        },
691
        CpuSpeed: {
692
            html: function () {
693
                return formatHertz(this.CpuSpeed);
694
            }
695
        },
696
        CpuSpeedMax: {
697
            html: function () {
698
                return formatHertz(this.CpuSpeedMax);
699
            }
700
        },
701
        CpuSpeedMin: {
702
            html: function () {
703
                return formatHertz(this.CpuSpeedMin);
704
            }
705
        },
706
        Cache: {
707
            html: function () {
708
                return formatBytes(this.Cache, data.Options["@attributes"].byteFormat);
709
            }
710
        },
711
        BusSpeed: {
712
            html: function () {
713
                return formatHertz(this.BusSpeed);
714
            }
715
        },
716
        Cputemp: {
717
            html: function () {
718
                return formatTemp(this.Cputemp, data.Options["@attributes"].tempFormat);
719
            }
720
        },
721
        Bogomips: {
722
            text: function () {
2976 rexy 723
                return parseInt(this.Bogomips, 10);
2788 rexy 724
            }
725
        },
726
        Load: {
727
            html: function () {
728
                return '<div class="progress">' +
729
                        '<div class="progress-bar progress-bar-info" style="width:' + round(this.Load,0) + '%;"></div>' +
730
                        '</div><div class="percent">' + round(this.Load,0) + '%</div>';
731
            }
732
        }
733
    };
734
 
735
    var hw_directives = {
736
        hwName: {
737
            html: function() {
738
                return this.Name;
739
            }
740
        },
741
        hwCount: {
742
            text: function() {
2976 rexy 743
                if ((this.Count !== undefined) && !isNaN(this.Count) && (parseInt(this.Count, 10)>1)) {
744
                    return parseInt(this.Count, 10);
2788 rexy 745
                } else {
746
                    return "";
747
                }
748
            }
749
        }
750
    };
751
 
2976 rexy 752
    var mem_directives = {
753
        Speed: {
754
            html: function() {
755
                return formatMTps(this.Speed);
756
            }
757
        },
758
        Voltage: {
759
            html: function() {
760
                return round(this.Voltage, 2) + ' V';
761
            }
762
        },
763
        Capacity: {
764
            html: function () {
765
                return formatBytes(this.Capacity, data.Options["@attributes"].byteFormat);
766
            }
767
        }
768
    };
769
 
2788 rexy 770
    var dev_directives = {
2976 rexy 771
        Speed: {
772
            html: function() {
773
                return formatBPS(1000000*this.Speed);
774
            }
775
        },
2788 rexy 776
        Capacity: {
777
            html: function () {
778
                return formatBytes(this.Capacity, data.Options["@attributes"].byteFormat);
779
            }
780
        }
781
    };
782
 
783
    var html="";
784
 
785
    if ((data.Hardware["@attributes"] !== undefined) && (data.Hardware["@attributes"].Name !== undefined)) {
786
        html+="<tr id=\"hardware-Machine\">";
787
        html+="<th style=\"width:8%;\">"+genlang(107)+"</th>"; //Machine
788
        html+="<td colspan=\"2\"><span data-bind=\"Name\"></span></td>";
789
        html+="</tr>";
790
    }
791
 
792
    var paramlist = {CpuSpeed:13,CpuSpeedMax:100,CpuSpeedMin:101,Cache:15,Virt:94,BusSpeed:14,Bogomips:16,Cputemp:51,Manufacturer:122,Load:9};
793
    try {
794
        datas = items(data.Hardware.CPU.CpuCore);
795
        for (i = 0; i < datas.length; i++) {
796
             if (i === 0) {
797
                html+="<tr id=\"hardware-CPU\" class=\"treegrid-CPU\">";
798
                html+="<th>CPU</th>";
799
                html+="<td><span class=\"treegrid-span\">" + genlang(119) + ":</span></td>"; //Number of processors
800
                html+="<td class=\"rightCell\"><span id=\"CPUCount\"></span></td>";
801
                html+="</tr>";
802
            }
803
            html+="<tr id=\"hardware-CPU-" + i +"\" class=\"treegrid-CPU-" + i +" treegrid-parent-CPU\">";
804
            html+="<th></th>";
805
            if (showCPULoadCompact && (datas[i]["@attributes"].Load !== undefined)) {
806
                html+="<td><span class=\"treegrid-span\" data-bind=\"Model\"></span></td>";
807
                html+="<td style=\"width:15%;\" class=\"rightCell\"><span data-bind=\"Load\"></span></td>";
808
            } else {
809
                html+="<td colspan=\"2\"><span class=\"treegrid-span\" data-bind=\"Model\"></span></td>";
810
            }
811
            html+="</tr>";
812
            for (proc_param in paramlist) {
813
                if (((proc_param !== 'Load') || !showCPULoadCompact) && (datas[i]["@attributes"][proc_param] !== undefined)) {
814
                    html+="<tr id=\"hardware-CPU-" + i + "-" + proc_param + "\" class=\"treegrid-parent-CPU-" + i +"\">";
815
                    html+="<th></th>";
816
                    html+="<td><span class=\"treegrid-span\">" + genlang(paramlist[proc_param]) + "<span></td>";
817
                    html+="<td class=\"rightCell\"><span data-bind=\"" + proc_param + "\"></span></td>";
818
                    html+="</tr>";
819
                }
820
            }
821
 
822
        }
823
    }
824
    catch (err) {
825
        $("#hardware-CPU").hide();
826
    }
827
 
2976 rexy 828
    var devparamlist = {Capacity:43,Manufacturer:122,Product:123,Speed:129,Voltage:52,Serial:124};
829
    for (hw_type in {MEM:0,PCI:1,IDE:2,SCSI:3,NVMe:4,USB:5,TB:6,I2C:7}) {
2788 rexy 830
        try {
2976 rexy 831
            if (hw_type == 'MEM') {
832
                datas = items(data.Hardware[hw_type].Chip);
833
            } else {
834
                datas = items(data.Hardware[hw_type].Device);
835
            }
2788 rexy 836
            for (i = 0; i < datas.length; i++) {
837
                if (i === 0) {
838
                    html+="<tr id=\"hardware-" + hw_type + "\" class=\"treegrid-" + hw_type + "\">";
839
                    html+="<th>" + hw_type + "</th>";
2976 rexy 840
                    if (hw_type == 'MEM') {
841
                        html+="<td><span class=\"treegrid-span\">" + genlang('128') + ":</span></td>"; //Number of memories
842
                    } else {
843
                        html+="<td><span class=\"treegrid-span\">" + genlang('120') + ":</span></td>"; //Number of devices
844
                    }                    
2788 rexy 845
                    html+="<td class=\"rightCell\"><span id=\"" + hw_type + "Count\"></span></td>";
846
                    html+="</tr>";
847
                }
848
                html+="<tr id=\"hardware-" + hw_type + "-" + i +"\" class=\"treegrid-" + hw_type + "-" + i +" treegrid-parent-" + hw_type + "\">";
849
                html+="<th></th>";
850
                html+="<td><span class=\"treegrid-span\" data-bind=\"hwName\"></span></td>";
851
                html+="<td class=\"rightCell\"><span data-bind=\"hwCount\"></span></td>";
852
                html+="</tr>";
853
                for (proc_param in devparamlist) {
854
                    if (datas[i]["@attributes"][proc_param] !== undefined) {
855
                        html+="<tr id=\"hardware-" + hw_type +"-" + i + "-" + proc_param + "\" class=\"treegrid-parent-" + hw_type +"-" + i +"\">";
856
                        html+="<th></th>";
857
                        html+="<td><span class=\"treegrid-span\">" + genlang(devparamlist[proc_param]) + "<span></td>";
858
                        html+="<td class=\"rightCell\"><span data-bind=\"" + proc_param + "\"></span></td>";
859
                        html+="</tr>";
860
                    }
861
                }
862
            }
863
        }
864
        catch (err) {
865
            $("#hardware-data"+hw_type).hide();
866
        }
867
    }
868
    $("#hardware-data").empty().append(html);
869
 
870
 
871
    if ((data.Hardware["@attributes"] !== undefined) && (data.Hardware["@attributes"].Name !== undefined)) {
872
        $('#hardware-Machine').render(data.Hardware["@attributes"]);
873
    }
874
 
875
    try {
876
        datas = items(data.Hardware.CPU.CpuCore);
877
        for (i = 0; i < datas.length; i++) {
878
            $('#hardware-CPU-'+ i).render(datas[i]["@attributes"], directives);
879
            for (proc_param in paramlist) {
880
                if (((proc_param !== 'Load') || !showCPULoadCompact) && (datas[i]["@attributes"][proc_param] !== undefined)) {
881
                    $('#hardware-CPU-'+ i +'-'+proc_param).render(datas[i]["@attributes"], directives);
882
                }
883
            }
884
        }
885
        if (i > 0) {
886
            $("#CPUCount").html(i);
887
        }
888
    }
889
    catch (err) {
890
        $("#hardware-CPU").hide();
891
    }
892
 
893
    var licz;
2976 rexy 894
    for (hw_type in {MEM:0,PCI:1,IDE:2,SCSI:3,NVMe:4,USB:5,TB:6,I2C:7}) {
2788 rexy 895
        try {
896
            licz = 0;
2976 rexy 897
            if (hw_type == 'MEM') {
898
                datas = items(data.Hardware[hw_type].Chip);
899
            } else {
900
                datas = items(data.Hardware[hw_type].Device);
901
            }
2788 rexy 902
            for (i = 0; i < datas.length; i++) {
903
                $('#hardware-'+hw_type+'-'+ i).render(datas[i]["@attributes"], hw_directives);
2976 rexy 904
                if ((datas[i]["@attributes"].Count !== undefined) && !isNaN(datas[i]["@attributes"].Count) && (parseInt(datas[i]["@attributes"].Count, 10)>1)) {
905
                    licz += parseInt(datas[i]["@attributes"].Count, 10);
2788 rexy 906
                } else {
907
                    licz++;
908
                }
2976 rexy 909
                if (hw_type == 'MEM') {
910
                    for (proc_param in devparamlist) {
911
                        if ((datas[i]["@attributes"][proc_param] !== undefined)) {
912
                            $('#hardware-'+hw_type+'-'+ i +'-'+proc_param).render(datas[i]["@attributes"], mem_directives);
913
                        }
2788 rexy 914
                    }
2976 rexy 915
                } else {
916
                    for (proc_param in devparamlist) {
917
                        if ((datas[i]["@attributes"][proc_param] !== undefined)) {
918
                            $('#hardware-'+hw_type+'-'+ i +'-'+proc_param).render(datas[i]["@attributes"], dev_directives);
919
                        }
920
                    }
2788 rexy 921
                }
922
            }
923
            if (i > 0) {
924
                $("#" + hw_type + "Count").html(licz);
925
            }
926
        }
927
        catch (err) {
928
            $("#hardware-"+hw_type).hide();
929
        }
930
    }
931
    $('#hardware').treegrid({
932
        initialState: 'collapsed',
933
        expanderExpandedClass: 'normalicon normalicon-down',
934
        expanderCollapsedClass: 'normalicon normalicon-right'
935
    });
936
    if (showCPUListExpanded) {
937
        try {
938
            $('#hardware-CPU').treegrid('expand');
939
        }
940
        catch (err) {
941
        }
942
    }
943
    if (showCPUInfoExpanded && showCPUListExpanded) {
944
        try {
945
            datas = items(data.Hardware.CPU.CpuCore);
946
            for (i = 0; i < datas.length; i++) {
947
                $('#hardware-CPU-'+i).treegrid('expand');
948
            }
949
        }
950
        catch (err) {
951
        }
952
    }
953
    $("#block_hardware").show();
954
}
955
 
956
function renderMemory(data) {
957
    if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('memory', blocks) < 0))) {
958
        $("#block_memory").remove();
959
        return;
960
    }
961
 
962
    var directives = {
963
        Total: {
964
            html: function () {
965
                return formatBytes(this["@attributes"].Total, data.Options["@attributes"].byteFormat);
966
            }
967
        },
968
        Free: {
969
            html: function () {
970
                return formatBytes(this["@attributes"].Free, data.Options["@attributes"].byteFormat);
971
            }
972
        },
973
        Used: {
974
            html: function () {
975
                return formatBytes(this["@attributes"].Used, data.Options["@attributes"].byteFormat);
976
            }
977
        },
978
        Usage: {
979
            html: function () {
980
                if ((this.Details === undefined) || (this.Details["@attributes"] === undefined)) {
981
                    return '<div class="progress">' +
982
                        '<div class="progress-bar progress-bar-info" style="width:' + this["@attributes"].Percent + '%;"></div>' +
983
                        '</div><div class="percent">' + this["@attributes"].Percent + '%</div>';
984
                } else {
2976 rexy 985
                    var rest = parseInt(this["@attributes"].Percent, 10);
2788 rexy 986
                    var html = '<div class="progress">';
987
                    if ((this.Details["@attributes"].AppPercent !== undefined) && (this.Details["@attributes"].AppPercent > 0)) {
988
                        html += '<div class="progress-bar progress-bar-info" style="width:' + this.Details["@attributes"].AppPercent + '%;"></div>';
2976 rexy 989
                        rest -= parseInt(this.Details["@attributes"].AppPercent, 10);
2788 rexy 990
                    }
991
                    if ((this.Details["@attributes"].CachedPercent !== undefined) && (this.Details["@attributes"].CachedPercent > 0)) {
992
                        html += '<div class="progress-bar progress-bar-warning" style="width:' + this.Details["@attributes"].CachedPercent + '%;"></div>';
2976 rexy 993
                        rest -= parseInt(this.Details["@attributes"].CachedPercent, 10);
2788 rexy 994
                    }
995
                    if ((this.Details["@attributes"].BuffersPercent !== undefined) && (this.Details["@attributes"].BuffersPercent > 0)) {
996
                        html += '<div class="progress-bar progress-bar-danger" style="width:' + this.Details["@attributes"].BuffersPercent + '%;"></div>';
2976 rexy 997
                        rest -= parseInt(this.Details["@attributes"].BuffersPercent, 10);
2788 rexy 998
                    }
999
                    if (rest > 0) {
1000
                        html += '<div class="progress-bar progress-bar-success" style="width:' + rest + '%;"></div>';
1001
                    }
1002
                    html += '</div>';
1003
                    html += '<div class="percent">' + 'Total: ' + this["@attributes"].Percent + '% ' + '<i>(';
1004
                    var not_first = false;
1005
                    if (this.Details["@attributes"].AppPercent !== undefined) {
1006
                        html += genlang(64) + ': '+ this.Details["@attributes"].AppPercent + '%'; //Kernel + apps
1007
                        not_first = true;
1008
                    }
1009
                    if (this.Details["@attributes"].CachedPercent !== undefined) {
1010
                        if (not_first) html += ' - ';
1011
                        html += genlang(66) + ': ' + this.Details["@attributes"].CachedPercent + '%'; //Cache
1012
                        not_first = true;
1013
                    }
1014
                    if (this.Details["@attributes"].BuffersPercent !== undefined) {
1015
                        if (not_first) html += ' - ';
1016
                        html += genlang(65) + ': ' + this.Details["@attributes"].BuffersPercent + '%'; //Buffers
1017
                    }
1018
                    html += ')</i></div>';
1019
                    return html;
1020
                }
1021
            }
1022
        },
1023
        Type: {
1024
            html: function () {
1025
                return genlang(28); //Physical Memory
1026
            }
1027
        }
1028
    };
1029
 
1030
    var directive_swap = {
1031
        Total: {
1032
            html: function () {
1033
                return formatBytes(this.Total, data.Options["@attributes"].byteFormat);
1034
            }
1035
        },
1036
        Free: {
1037
            html: function () {
1038
                return formatBytes(this.Free, data.Options["@attributes"].byteFormat);
1039
            }
1040
        },
1041
        Used: {
1042
            html: function () {
1043
                return formatBytes(this.Used, data.Options["@attributes"].byteFormat);
1044
            }
1045
        },
1046
        Usage: {
1047
            html: function () {
1048
                return '<div class="progress">' +
1049
                    '<div class="progress-bar progress-bar-info" style="width:' + this.Percent + '%;"></div>' +
1050
                    '</div><div class="percent">' + this.Percent + '%</div>';
1051
            }
1052
        },
1053
        Name: {
1054
            html: function () {
1055
                return this.Name + '<br>' + ((this.MountPoint !== undefined) ? this.MountPoint : this.MountPointID);
1056
            }
1057
        }
1058
    };
1059
 
1060
    var data_memory = [];
1061
    if (data.Memory.Swap !== undefined) {
1062
        var datas = items(data.Memory.Swap.Mount);
1063
        data_memory.push_attrs(datas);
1064
        $('#swap-data').render(data_memory, directive_swap);
1065
        $('#swap-data').show();
1066
    } else {
1067
        $('#swap-data').hide();
1068
    }
1069
    $('#memory-data').render(data.Memory, directives);
1070
    $("#block_memory").show();
1071
}
1072
 
1073
function renderFilesystem(data) {
1074
    if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('filesystem', blocks) < 0))) {
1075
        $("#block_filesystem").remove();
1076
        return;
1077
    }
1078
 
1079
    var directives = {
1080
        Total: {
1081
            html: function () {
2976 rexy 1082
                return formatBytes(this.Total, data.Options["@attributes"].byteFormat, (this.Ignore !== undefined) && (this.Ignore > 0) && showtotals);
2788 rexy 1083
            }
1084
        },
1085
        Free: {
1086
            html: function () {
2976 rexy 1087
                return formatBytes(this.Free, data.Options["@attributes"].byteFormat, (this.Ignore !== undefined) && (this.Ignore > 0) && showtotals);
2788 rexy 1088
            }
1089
        },
1090
        Used: {
1091
            html: function () {
2976 rexy 1092
                return formatBytes(this.Used, data.Options["@attributes"].byteFormat, (this.Ignore !== undefined) && (this.Ignore >= 3) && showtotals);
2788 rexy 1093
            }
1094
        },
1095
        MountPoint: {
1096
            text: function () {
1097
                return ((this.MountPoint !== undefined) ? this.MountPoint : this.MountPointID);
1098
            }
1099
        },
1100
        Name: {
1101
            html: function () {
1102
                return this.Name.replace(/;/g, ";<wbr>") + ((this.MountOptions !== undefined) ? '<br><i>(' + this.MountOptions + ')</i>' : '');
1103
            }
1104
        },
1105
        Percent: {
1106
            html: function () {
2976 rexy 1107
                var used1 = (this.Total != 0) ? Math.ceil((this.Used / this.Total) * 100) : 0;
1108
                var used2 = Math.ceil(this.Percent);
1109
                var used21= used2 - used1;
1110
                if (used21 > 0) {
1111
                    return '
' + '
1112
1113
= parseInt(data.Options["@attributes"].threshold, 10))) ) ? 'progress-bar progress-bar-danger' : 'progress-bar progress-bar-info' ) +
1114
div>' +
1115
'<div class="progress-bar progress-bar-warning" style="width:' + used21 + '% ;"></div>'
1116
+'div><div class="percent">' + this.Percent + '% ' + ((this.Inodes !== undefined) ? '<i>(' + this.Inodes + '%)</i>' : '') + 'div>';
1117
} else {
1118
return '<div class="progress">' + '<div class="' +
1119
( ( ((this.Ignore == undefined) || (this.Ignore < 4)) && ((data.Options["@attributes"].threshold !== undefined) &&
1120
(parseInt(this.Percent, 10) >= parseInt(data.Options["@attributes"].threshold, 10))) ) ? 'progress-bar progress-bar-danger' : 'progress-bar progress-bar-info' ) +
1121
'" style="width:' + used2 + '% ;"></div>' +
1122
'div>' + '<div class="percent">' + this.Percent + '% ' + ((this.Inodes !== undefined) ? '<i>(' + this.Inodes + '%)</i>' : '') + 'div>';
1123
}
2788 rexy 1124
}
1125
}
1126
};
1127
 
1128
try {
1129
var fs_data = [];
1130
var datas = items(data.FileSystem.Mount);
1131
var total = {Total:0,Free:0,Used:0};
2976 rexy 1132
var showtotals = $("#hideTotals").val().toString()!=="true";
2788 rexy 1133
for (var i = 0; i < datas.length; i++) {
1134
fs_data.push(datas[i]["@attributes"]);
2976 rexy 1135
if (showtotals) {
1136
if ((datas[i]["@attributes"].Ignore !== undefined) && (datas[i]["@attributes"].Ignore > 0)) {
1137
if (datas[i]["@attributes"].Ignore == 2) {
1138
total.Used += parseInt(datas[i]["@attributes"].Used, 10);
1139
} else if (datas[i]["@attributes"].Ignore == 1) {
1140
total.Total += parseInt(datas[i]["@attributes"].Used, 10);
1141
total.Used += parseInt(datas[i]["@attributes"].Used, 10);
1142
}
1143
} else {
1144
total.Total += parseInt(datas[i]["@attributes"].Total, 10);
1145
total.Free += parseInt(datas[i]["@attributes"].Free, 10);
1146
total.Used += parseInt(datas[i]["@attributes"].Used, 10);
2788 rexy 1147
}
2976 rexy 1148
total.Percent = (total.Total != 0) ? round(100 - (total.Free / total.Total) * 100, 2) : 0;
2788 rexy 1149
}
1150
}
1151
if (i > 0) {
1152
$('#filesystem-data').render(fs_data, directives);
2976 rexy 1153
if (showtotals) {
1154
$('#filesystem-foot').render(total, directives);
1155
$('#filesystem-foot').show();
1156
}
2788 rexy 1157
$('#filesystem_MountPoint').removeClass("sorttable_sorted"); //reset sort order
1158
// sorttable.innerSortFunction.apply(document.getElementById('filesystem_MountPoint'), []);
1159
sorttable.innerSortFunction.apply($('#filesystem_MountPoint')[0], []);
1160
$("#block_filesystem").show();
1161
} else {
1162
$("#block_filesystem").hide();
1163
}
1164
}
1165
catch (err) {
1166
$("#block_filesystem").hide();
1167
}
1168
}
1169
 
1170
function renderNetwork(data) {
1171
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('network', blocks) < 0))) {
1172
$("#block_network").remove();
1173
return;
1174
}
1175
 
1176
var directives = {
1177
RxBytes: {
1178
html: function () {
1179
var htmladd = '';
1180
if (showNetworkActiveSpeed && ($.inArray(this.Name, oldnetwork) >= 0)) {
1181
var diff, difftime;
1182
if (((diff = this.RxBytes - oldnetwork[this.Name].RxBytes) > 0) && ((difftime = data.Generation["@attributes"].timestamp - oldnetwork[this.Name].timestamp) > 0)) {
1183
if (showNetworkActiveSpeed == 2) {
1184
htmladd ="<br><i>("+formatBPS(round(8*diff/difftime, 2))+")</i>";
1185
} else {
1186
htmladd ="<br><i>("+formatBytes(round(diff/difftime, 2), data.Options["@attributes"].byteFormat)+"/s)</i>";
1187
}
1188
}
1189
}
1190
return formatBytes(this.RxBytes, data.Options["@attributes"].byteFormat) + htmladd;
1191
}
1192
},
1193
TxBytes: {
1194
html: function () {
1195
var htmladd = '';
1196
if (showNetworkActiveSpeed && ($.inArray(this.Name, oldnetwork) >= 0)) {
1197
var diff, difftime;
1198
if (((diff = this.TxBytes - oldnetwork[this.Name].TxBytes) > 0) && ((difftime = data.Generation["@attributes"].timestamp - oldnetwork[this.Name].timestamp) > 0)) {
1199
if (showNetworkActiveSpeed == 2) {
1200
htmladd ="<br><i>("+formatBPS(round(8*diff/difftime, 2))+")</i>";
1201
} else {
1202
htmladd ="<br><i>("+formatBytes(round(diff/difftime, 2), data.Options["@attributes"].byteFormat)+"/s)</i>";
1203
}
1204
}
1205
}
1206
return formatBytes(this.TxBytes, data.Options["@attributes"].byteFormat) + htmladd;
1207
}
1208
},
1209
Drops: {
1210
html: function () {
1211
return this.Err + "/<wbr>" + this.Drops;
1212
}
1213
}
1214
};
1215
 
1216
var html = "";
1217
var preoldnetwork = [];
1218
 
1219
try {
1220
var datas = items(data.Network.NetDevice);
1221
for (var i = 0; i < datas.length; i++) {
1222
html+="<tr id=\"network-" + i +"\" class=\"treegrid-network-" + i + "\">";
1223
html+="<td><span class=\"treegrid-spanbold\" data-bind=\"Name\"></span></td>";
1224
html+="<td class=\"rightCell\"><span data-bind=\"RxBytes\"></span></td>";
1225
html+="<td class=\"rightCell\"><span data-bind=\"TxBytes\"></span></td>";
1226
html+="<td class=\"rightCell\"><span data-bind=\"Drops\"></span></td>";
1227
html+="</tr>";
1228
 
1229
var info = datas[i]["@attributes"].Info;
1230
if ( (info !== undefined) && (info !== "") ) {
1231
var infos = info.replace(/:/g, "<wbr>:").split(";"); /* split long addresses */
1232
for (var j = 0; j < infos.length; j++){
1233
html +="<tr class=\"treegrid-parent-network-" + i + "\"><td colspan=\"4\"><span class=\"treegrid-span\">" + infos[j] + "</span></td></tr>";
1234
}
1235
}
1236
}
1237
$("#network-data").empty().append(html);
1238
if (i > 0) {
1239
for (var k = 0; k < datas.length; k++) {
1240
$('#network-' + k).render(datas[k]["@attributes"], directives);
1241
if (showNetworkActiveSpeed) {
1242
preoldnetwork.pushIfNotExist(datas[k]["@attributes"].Name);
1243
preoldnetwork[datas[k]["@attributes"].Name] = {timestamp:data.Generation["@attributes"].timestamp, RxBytes:datas[k]["@attributes"].RxBytes, TxBytes:datas[k]["@attributes"].TxBytes};
1244
}
1245
}
1246
$('#network').treegrid({
1247
initialState: showNetworkInfosExpanded?'expanded':'collapsed',
1248
expanderExpandedClass: 'normalicon normalicon-down',
1249
expanderCollapsedClass: 'normalicon normalicon-right'
1250
});
1251
$("#block_network").show();
1252
} else {
1253
$("#block_network").hide();
1254
}
1255
}
1256
catch (err) {
1257
$("#block_network").hide();
1258
}
1259
 
1260
if (showNetworkActiveSpeed) {
1261
while (oldnetwork.length > 0) {
1262
delete oldnetwork[oldnetwork.length-1]; //remove last object
1263
oldnetwork.pop(); //remove last object reference from array
1264
}
1265
oldnetwork = preoldnetwork;
1266
}
1267
}
1268
 
1269
function renderVoltage(data) {
1270
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('voltage', blocks) < 0))) {
1271
$("#block_voltage").remove();
1272
return;
1273
}
1274
 
1275
var directives = {
1276
Value: {
1277
text: function () {
1278
return round(this.Value,2) + String.fromCharCode(160) + "V";
1279
}
1280
},
1281
Min: {
1282
text: function () {
1283
if (this.Min !== undefined)
1284
return round(this.Min,2) + String.fromCharCode(160) + "V";
1285
}
1286
},
1287
Max: {
1288
text: function () {
1289
if (this.Max !== undefined)
1290
return round(this.Max,2) + String.fromCharCode(160) + "V";
1291
}
1292
},
1293
Label: {
1294
html: function () {
1295
if (this.Event === undefined)
1296
return this.Label;
1297
else
1298
return this.Label + " <img style=\"vertical-align:middle;width:20px;\" src=\"./gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1299
}
1300
}
1301
};
1302
try {
1303
var voltage_data = [];
1304
var datas = items(data.MBInfo.Voltage.Item);
1305
if (voltage_data.push_attrs(datas) > 0) {
1306
$('#voltage-data').render(voltage_data, directives);
1307
$("#block_voltage").show();
1308
} else {
1309
$("#block_voltage").hide();
1310
}
1311
}
1312
catch (err) {
1313
$("#block_voltage").hide();
1314
}
1315
}
1316
 
1317
function renderTemperature(data) {
1318
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('temperature', blocks) < 0))) {
1319
$("#block_temperature").remove();
1320
return;
1321
}
1322
 
1323
var directives = {
1324
Value: {
1325
html: function () {
1326
return formatTemp(this.Value, data.Options["@attributes"].tempFormat);
1327
}
1328
},
1329
Max: {
1330
html: function () {
1331
if (this.Max !== undefined)
1332
return formatTemp(this.Max, data.Options["@attributes"].tempFormat);
1333
}
1334
},
1335
Label: {
1336
html: function () {
1337
if (this.Event === undefined)
1338
return this.Label;
1339
else
1340
return this.Label + " <img style=\"vertical-align:middle;width:20px;\" src=\"./gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1341
}
1342
}
1343
};
1344
 
1345
try {
1346
var temperature_data = [];
1347
var datas = items(data.MBInfo.Temperature.Item);
1348
if (temperature_data.push_attrs(datas) > 0) {
1349
$('#temperature-data').render(temperature_data, directives);
1350
$("#block_temperature").show();
1351
} else {
1352
$("#block_temperature").hide();
1353
}
1354
}
1355
catch (err) {
1356
$("#block_temperature").hide();
1357
}
1358
}
1359
 
1360
function renderFans(data) {
1361
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('fans', blocks) < 0))) {
1362
$("#block_fans").remove();
1363
return;
1364
}
1365
 
1366
var directives = {
1367
Value: {
1368
html: function () {
2976 rexy 1369
if (this.Unit === "%") {
1370
return '<div class="progress">' +
1371
'<div class="progress-bar progress-bar-info" style="width:' + round(this.Value,0) + '%;"></div>' +
1372
'div><div class="percent">' + round(this.Value,0) + '%</div>';
1373
} else {
1374
return round(this.Value,0) + String.fromCharCode(160) + genlang(63); //RPM
1375
}
2788 rexy 1376
}
1377
},
1378
Min: {
1379
html: function () {
2976 rexy 1380
if (this.Min !== undefined) {
1381
if (this.Unit === "%") {
1382
return round(this.Min,0) + "%";
1383
} else {
1384
return round(this.Min,0) + String.fromCharCode(160) + genlang(63); //RPM
1385
}
1386
}
2788 rexy 1387
}
1388
},
1389
Label: {
1390
html: function () {
1391
if (this.Event === undefined)
1392
return this.Label;
1393
else
1394
return this.Label + " gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1395
}
1396
}
1397
};
1398
 
1399
try {
1400
var fans_data = [];
1401
var datas = items(data.MBInfo.Fans.Item);
1402
if (fans_data.push_attrs(datas) > 0) {
1403
$('#fans-data').render(fans_data, directives);
1404
$("#block_fans").show();
1405
} else {
1406
$("#block_fans").hide();
1407
}
1408
}
1409
catch (err) {
1410
$("#block_fans").hide();
1411
}
1412
}
1413
 
1414
function renderPower(data) {
1415
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('power', blocks) < 0))) {
1416
$("#block_power").remove();
1417
return;
1418
}
1419
 
1420
var directives = {
1421
Value: {
1422
text: function () {
1423
return round(this.Value,2) + String.fromCharCode(160) + "W";
1424
}
1425
},
1426
Max: {
1427
text: function () {
1428
if (this.Max !== undefined)
1429
return round(this.Max,2) + String.fromCharCode(160) + "W";
1430
}
1431
},
1432
Label: {
1433
html: function () {
1434
if (this.Event === undefined)
1435
return this.Label;
1436
else
1437
return this.Label + " <img style=\"vertical-align:middle;width:20px;\" src=\"./gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1438
}
1439
}
1440
};
1441
 
1442
try {
1443
var power_data = [];
1444
var datas = items(data.MBInfo.Power.Item);
1445
if (power_data.push_attrs(datas) > 0) {
1446
$('#power-data').render(power_data, directives);
1447
$("#block_power").show();
1448
} else {
1449
$("#block_power").hide();
1450
}
1451
}
1452
catch (err) {
1453
$("#block_power").hide();
1454
}
1455
}
1456
 
1457
function renderCurrent(data) {
1458
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('current', blocks) < 0))) {
1459
$("#block_current").remove();
1460
return;
1461
}
1462
 
1463
var directives = {
1464
Value: {
1465
text: function () {
1466
return round(this.Value,2) + String.fromCharCode(160) + "A";
1467
}
1468
},
1469
Min: {
1470
text: function () {
1471
if (this.Min !== undefined)
1472
return round(this.Min,2) + String.fromCharCode(160) + "A";
1473
}
1474
},
1475
Max: {
1476
text: function () {
1477
if (this.Max !== undefined)
1478
return round(this.Max,2) + String.fromCharCode(160) + "A";
1479
}
1480
},
1481
Label: {
1482
html: function () {
1483
if (this.Event === undefined)
1484
return this.Label;
1485
else
1486
return this.Label + " <img style=\"vertical-align:middle;width:20px;\" src=\"./gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1487
}
1488
}
1489
};
1490
 
1491
try {
1492
var current_data = [];
1493
var datas = items(data.MBInfo.Current.Item);
1494
if (current_data.push_attrs(datas) > 0) {
1495
$('#current-data').render(current_data, directives);
1496
$("#block_current").show();
1497
} else {
1498
$("#block_current").hide();
1499
}
1500
}
1501
catch (err) {
1502
$("#block_current").hide();
1503
}
1504
}
1505
 
1506
function renderOther(data) {
1507
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('other', blocks) < 0))) {
1508
$("#block_other").remove();
1509
return;
1510
}
1511
 
1512
var directives = {
2976 rexy 1513
Value: {
1514
html: function () {
1515
if (this.Unit === "%") {
1516
return '<div class="progress">' +
1517
'<div class="progress-bar progress-bar-info" style="width:' + round(this.Value,0) + '%;"></div>' +
1518
'</div><div class="percent">' + round(this.Value,0) + '%</div>';
1519
// return round(this.Value,0) + "%";
1520
} else {
1521
return this.Value;
1522
}
1523
}
1524
},
2788 rexy 1525
Label: {
1526
html: function () {
1527
if (this.Event === undefined)
1528
return this.Label;
1529
else
1530
return this.Label + " <img style=\"vertical-align:middle;width:20px;\" src=\"./gfx/attention.gif\" alt=\"!\" title=\"" + this.Event + "\"/>";
1531
}
1532
}
1533
};
1534
 
1535
try {
1536
var other_data = [];
1537
var datas = items(data.MBInfo.Other.Item);
1538
if (other_data.push_attrs(datas) > 0) {
1539
$('#other-data').render(other_data, directives);
1540
$("#block_other").show();
1541
} else {
1542
$("#block_other").hide();
1543
}
1544
}
1545
catch (err) {
1546
$("#block_other").hide();
1547
}
1548
}
1549
 
1550
function renderUPS(data) {
1551
if ((blocks.length <= 0) || ((blocks[0] !== "true") && ($.inArray('ups', blocks) < 0))) {
1552
$("#block_ups").remove();
1553
return;
1554
}
1555
 
1556
var i, datas, proc_param;
1557
var directives = {
1558
Name: {
1559
text: function () {
1560
return this.Name + ((this.Mode !== undefined) ? " (" + this.Mode + ")" : "");
1561
}
1562
},
1563
LineVoltage: {
1564
html: function () {
1565
return this.LineVoltage + String.fromCharCode(160) + genlang(82); //V
1566
}
1567
},
1568
LineFrequency: {
1569
html: function () {
1570
return this.LineFrequency + String.fromCharCode(160) + genlang(109); //Hz
1571
}
1572
},
1573
BatteryVoltage: {
1574
html: function () {
1575
return this.BatteryVoltage + String.fromCharCode(160) + genlang(82); //V
1576
}
1577
},
1578
TimeLeftMinutes: {
1579
html: function () {
1580
return this.TimeLeftMinutes + String.fromCharCode(160) + genlang(83); //minutes
1581
}
1582
},
1583
LoadPercent: {
1584
html: function () {
1585
return '<div class="progress">' +
1586
'<div class="progress-bar progress-bar-info" style="width:' + round(this.LoadPercent,0) + '%;"></div>' +
1587
'</div><div class="percent">' + round(this.LoadPercent,0) + '%</div>';
1588
}
1589
},
1590
BatteryChargePercent: {
1591
html: function () {
1592
return '<div class="progress">' +
1593
'<div class="progress-bar progress-bar-info" style="width:' + round(this.BatteryChargePercent,0) + '%;"></div>' +
1594
'</div><div class="percent">' + round(this.BatteryChargePercent,0) + '%</div>';
1595
}
1596
}
1597
};
1598
 
1599
if ((data.UPSInfo !== undefined) && (items(data.UPSInfo.UPS).length > 0)) {
1600
var html="";
1601
var paramlist = {Model:70,StartTime:72,Status:73,Temperature:84,OutagesCount:74,LastOutage:75,LastOutageFinish:76,LineVoltage:77,LineFrequency:108,LoadPercent:78,BatteryDate:104,BatteryVoltage:79,BatteryChargePercent:80,TimeLeftMinutes:81};
1602
 
1603
try {
1604
datas = items(data.UPSInfo.UPS);
1605
for (i = 0; i < datas.length; i++) {
1606
html+="<tr id=\"ups-" + i +"\" class=\"treegrid-UPS-" + i+ "\">";
1607
html+="<td colspan=\"2\"><span class=\"treegrid-spanbold\" data-bind=\"Name\"></span></td>";
1608
html+="</tr>";
1609
for (proc_param in paramlist) {
1610
if (datas[i]["@attributes"][proc_param] !== undefined) {
1611
html+="<tr id=\"ups-" + i + "-" + proc_param + "\" class=\"treegrid-parent-UPS-" + i +"\">";
1612
html+="<td style=\"width:60%;\"><span class=\"treegrid-spanbold\">" + genlang(paramlist[proc_param]) + "</span></td>";
1613
html+="<td class=\"rightCell\"><span data-bind=\"" + proc_param + "\"></span></td>";
1614
html+="</tr>";
1615
}
1616
}
1617
 
1618
}
1619
}
1620
catch (err) {
1621
}
1622
 
1623
if ((data.UPSInfo["@attributes"] !== undefined) && (data.UPSInfo["@attributes"].ApcupsdCgiLinks === "1")) {
1624
html+="<tr>";
1625
html+="<td colspan=\"2\">(<a title='details' href='/cgi-bin/apcupsd/multimon.cgi' target='apcupsdcgi'>"+genlang(99)+"</a>)</td>";
1626
html+="</tr>";
1627
}
1628
 
1629
$("#ups-data").empty().append(html);
1630
 
1631
try {
1632
datas = items(data.UPSInfo.UPS);
1633
for (i = 0; i < datas.length; i++) {
1634
$('#ups-'+ i).render(datas[i]["@attributes"], directives);
1635
for (proc_param in paramlist) {
1636
if (datas[i]["@attributes"][proc_param] !== undefined) {
1637
$('#ups-'+ i +'-'+proc_param).render(datas[i]["@attributes"], directives);
1638
}
1639
}
1640
}
1641
}
1642
catch (err) {
1643
}
1644
 
1645
$('#ups').treegrid({
1646
initialState: 'expanded',
1647
expanderExpandedClass: 'normalicon normalicon-down',
1648
expanderCollapsedClass: 'normalicon normalicon-right'
1649
});
1650
 
1651
$("#block_ups").show();
1652
} else {
1653
$("#block_ups").hide();
1654
}
1655
}
1656
 
1657
function renderErrors(data) {
1658
try {
1659
var datas = items(data.Errors.Error);
1660
for (var i = 0; i < datas.length; i++) {
1661
$("#errors").append("<li><b>"+datas[i]["@attributes"].Function+"</b> - "+datas[i]["@attributes"].Message.replace(/\n/g, "<br>")+"</li><br>");
1662
}
1663
if (i > 0) {
1664
$("#errorbutton").attr('data-toggle', 'modal');
1665
$("#errorbutton").css('cursor', 'pointer');
1666
$("#errorbutton").css("visibility", "visible");
1667
}
1668
}
1669
catch (err) {
1670
$("#errorbutton").css("visibility", "hidden");
1671
$("#errorbutton").css('cursor', 'default');
1672
$("#errorbutton").attr('data-toggle', '');
1673
}
1674
}
1675
 
1676
/**
1677
* format seconds to a better readable statement with days, hours and minutes
1678
* @param {Number} sec seconds that should be formatted
1679
* @return {String} html string with no breaking spaces and translation statemen
1680
*/
1681
function formatUptime(sec) {
1682
var txt = "", intMin = 0, intHours = 0, intDays = 0;
1683
intMin = sec / 60;
1684
intHours = intMin / 60;
1685
intDays = Math.floor(intHours / 24);
1686
intHours = Math.floor(intHours - (intDays * 24));
1687
intMin = Math.floor(intMin - (intDays * 60 * 24) - (intHours * 60));
1688
if (intDays) {
1689
txt += intDays.toString() + String.fromCharCode(160) + genlang(48) + String.fromCharCode(160); //days
1690
}
1691
if (intHours) {
1692
txt += intHours.toString() + String.fromCharCode(160) + genlang(49) + String.fromCharCode(160); //hours
1693
}
1694
return txt + intMin.toString() + String.fromCharCode(160) + genlang(50); //Minutes
1695
}
1696
 
1697
/**
1698
* format a celcius temperature to fahrenheit and also append the right suffix
1699
* @param {String} degreeC temperature in celvius
1700
* @param {jQuery} xml phpSysInfo-XML
1701
* @return {String} html string with no breaking spaces and translation statements
1702
*/
1703
function formatTemp(degreeC, tempFormat) {
1704
var degree = 0;
1705
if (tempFormat === undefined) {
1706
tempFormat = "c";
1707
}
1708
degree = parseFloat(degreeC);
1709
if (isNaN(degreeC)) {
1710
return "---";
1711
} else {
1712
switch (tempFormat.toLowerCase()) {
1713
case "f":
1714
return round((((9 * degree) / 5) + 32), 1) + String.fromCharCode(160) + genlang(61);
1715
case "c":
1716
return round(degree, 1) + String.fromCharCode(160) + genlang(60);
1717
case "c-f":
1718
return round(degree, 1) + String.fromCharCode(160) + genlang(60) + "<br><i>(" + round((((9 * degree) / 5) + 32), 1) + String.fromCharCode(160) + genlang(61) + ")i>";
1719
case "f-c":
1720
return round((((9 * degree) / 5) + 32), 1) + String.fromCharCode(160) + genlang(61) + "<br><i>(" + round(degree, 1) + String.fromCharCode(160) + genlang(60) + ")</i>";
1721
}
1722
}
1723
}
1724
 
1725
/**
1726
* format a given MHz value to a better readable statement with the right suffix
1727
* @param {Number} mhertz mhertz value that should be formatted
1728
* @return {String} html string with no breaking spaces and translation statements
1729
*/
1730
function formatHertz(mhertz) {
1731
if ((mhertz >= 0) && (mhertz < 1000)) {
1732
< 1000)) { return mhertz.toString() + String.fromCharCode(160) + genlang(92);
1733
< 1000)) { } else {
1734
< 1000)) { if (mhertz >= 1000) {
1735
< 1000)) { return round(mhertz / 1000, 2) + String.fromCharCode(160) + genlang(93);
1736
< 1000)) { } else {
1737
< 1000)) { return "";
1738
< 1000)) { }
1739
< 1000)) { }
1740
< 1000)) {}
1741
 
1742
< 1000)) {/**
2976 rexy 1743
< 1000)) { * format a given MT/s value to a better readable statement with the right suffix
1744
< 1000)) { * @param {Number} mtps mtps value that should be formatted
1745
< 1000)) { * @return {String} html string with no breaking spaces and translation statements
1746
< 1000)) { */
1747
< 1000)) {function formatMTps(mtps) {
1748
< 1000)) { if ((mtps >= 0) && (mtps < 1000)) {
1749
< 1000)) { return mtps.toString() + String.fromCharCode(160) + genlang(131);
1750
< 1000)) { } else {
1751
< 1000)) { if (mtps >= 1000) {
1752
< 1000)) { return round(mtps / 1000, 2) + String.fromCharCode(160) + genlang(132);
1753
< 1000)) { } else {
1754
< 1000)) { return "";
1755
< 1000)) { }
1756
< 1000)) { }
1757
< 1000)) {}
1758
 
1759
< 1000)) {/**
2788 rexy 1760
< 1000)) { * format the byte values into a user friendly value with the corespondenting unit expression<br>support is included
1761
< 1000)) { * for binary and decimal output<br>user can specify a constant format for all byte outputs or the output is formated
1762
< 1000)) { * automatically so that every value can be read in a user friendly way
1763
< 1000)) { * @param {Number} bytes value that should be converted in the corespondenting format, which is specified in the phpsysinfo.ini
1764
< 1000)) { * @param {jQuery} xml phpSysInfo-XML
1765
< 1000)) { * @param {parenths} if true then add parentheses
1766
< 1000)) { * @return {String} string of the converted bytes with the translated unit expression
1767
< 1000)) { */
1768
< 1000)) {function formatBytes(bytes, byteFormat, parenths) {
1769
< 1000)) { var show = "";
1770
 
1771
< 1000)) { if (byteFormat === undefined) {
1772
< 1000)) { byteFormat = "auto_binary";
1773
< 1000)) { }
1774
 
1775
< 1000)) { switch (byteFormat.toLowerCase()) {
1776
< 1000)) { case "pib":
1777
< 1000)) { show += round(bytes / Math.pow(1024, 5), 2);
1778
< 1000)) { show += String.fromCharCode(160) + genlang(90);
1779
< 1000)) { break;
1780
< 1000)) { case "tib":
1781
< 1000)) { show += round(bytes / Math.pow(1024, 4), 2);
1782
< 1000)) { show += String.fromCharCode(160) + genlang(86);
1783
< 1000)) { break;
1784
< 1000)) { case "gib":
1785
< 1000)) { show += round(bytes / Math.pow(1024, 3), 2);
1786
< 1000)) { show += String.fromCharCode(160) + genlang(87);
1787
< 1000)) { break;
1788
< 1000)) { case "mib":
1789
< 1000)) { show += round(bytes / Math.pow(1024, 2), 2);
1790
< 1000)) { show += String.fromCharCode(160) + genlang(88);
1791
< 1000)) { break;
1792
< 1000)) { case "kib":
1793
< 1000)) { show += round(bytes / Math.pow(1024, 1), 2);
1794
< 1000)) { show += String.fromCharCode(160) + genlang(89);
1795
< 1000)) { break;
1796
< 1000)) { case "pb":
1797
< 1000)) { show += round(bytes / Math.pow(1000, 5), 2);
1798
< 1000)) { show += String.fromCharCode(160) + genlang(91);
1799
< 1000)) { break;
1800
< 1000)) { case "tb":
1801
< 1000)) { show += round(bytes / Math.pow(1000, 4), 2);
1802
< 1000)) { show += String.fromCharCode(160) + genlang(85);
1803
< 1000)) { break;
1804
< 1000)) { case "gb":
1805
< 1000)) { show += round(bytes / Math.pow(1000, 3), 2);
1806
< 1000)) { show += String.fromCharCode(160) + genlang(41);
1807
< 1000)) { break;
1808
< 1000)) { case "mb":
1809
< 1000)) { show += round(bytes / Math.pow(1000, 2), 2);
1810
< 1000)) { show += String.fromCharCode(160) + genlang(40);
1811
< 1000)) { break;
1812
< 1000)) { case "kb":
1813
< 1000)) { show += round(bytes / Math.pow(1000, 1), 2);
1814
< 1000)) { show += String.fromCharCode(160) + genlang(39);
1815
< 1000)) { break;
1816
< 1000)) { case "b":
1817
< 1000)) { show += bytes;
1818
< 1000)) { show += String.fromCharCode(160) + genlang(96);
1819
< 1000)) { break;
1820
< 1000)) { case "auto_decimal":
1821
< 1000)) { if (bytes > Math.pow(1000, 5)) {
1822
< 1000)) { show += round(bytes / Math.pow(1000, 5), 2);
1823
< 1000)) { show += String.fromCharCode(160) + genlang(91);
1824
< 1000)) { } else {
1825
< 1000)) { if (bytes > Math.pow(1000, 4)) {
1826
< 1000)) { show += round(bytes / Math.pow(1000, 4), 2);
1827
< 1000)) { show += String.fromCharCode(160) + genlang(85);
1828
< 1000)) { } else {
1829
< 1000)) { if (bytes > Math.pow(1000, 3)) {
1830
< 1000)) { show += round(bytes / Math.pow(1000, 3), 2);
1831
< 1000)) { show += String.fromCharCode(160) + genlang(41);
1832
< 1000)) { } else {
1833
< 1000)) { if (bytes > Math.pow(1000, 2)) {
1834
< 1000)) { show += round(bytes / Math.pow(1000, 2), 2);
1835
< 1000)) { show += String.fromCharCode(160) + genlang(40);
1836
< 1000)) { } else {
1837
< 1000)) { if (bytes > Math.pow(1000, 1)) {
1838
< 1000)) { show += round(bytes / Math.pow(1000, 1), 2);
1839
< 1000)) { show += String.fromCharCode(160) + genlang(39);
1840
< 1000)) { } else {
1841
< 1000)) { show += bytes;
1842
< 1000)) { show += String.fromCharCode(160) + genlang(96);
1843
< 1000)) { }
1844
< 1000)) { }
1845
< 1000)) { }
1846
< 1000)) { }
1847
< 1000)) { }
1848
< 1000)) { break;
1849
< 1000)) { default:
1850
< 1000)) { if (bytes > Math.pow(1024, 5)) {
1851
< 1000)) { show += round(bytes / Math.pow(1024, 5), 2);
1852
< 1000)) { show += String.fromCharCode(160) + genlang(90);
1853
< 1000)) { } else {
1854
< 1000)) { if (bytes > Math.pow(1024, 4)) {
1855
< 1000)) { show += round(bytes / Math.pow(1024, 4), 2);
1856
< 1000)) { show += String.fromCharCode(160) + genlang(86);
1857
< 1000)) { } else {
1858
< 1000)) { if (bytes > Math.pow(1024, 3)) {
1859
< 1000)) { show += round(bytes / Math.pow(1024, 3), 2);
1860
< 1000)) { show += String.fromCharCode(160) + genlang(87);
1861
< 1000)) { } else {
1862
< 1000)) { if (bytes > Math.pow(1024, 2)) {
1863
< 1000)) { show += round(bytes / Math.pow(1024, 2), 2);
1864
< 1000)) { show += String.fromCharCode(160) + genlang(88);
1865
< 1000)) { } else {
1866
< 1000)) { if (bytes > Math.pow(1024, 1)) {
1867
< 1000)) { show += round(bytes / Math.pow(1024, 1), 2);
1868
< 1000)) { show += String.fromCharCode(160) + genlang(89);
1869
< 1000)) { } else {
1870
< 1000)) { show += bytes;
1871
< 1000)) { show += String.fromCharCode(160) + genlang(96);
1872
< 1000)) { }
1873
< 1000)) { }
1874
< 1000)) { }
1875
< 1000)) { }
1876
< 1000)) { }
1877
< 1000)) { }
1878
< 1000)) { if (parenths === true) {
1879
< 1000)) { show = "(" + show + ")i>";
1880
< 1000)) { }
1881
< 1000)) { return "<span style='display:none'>" + round(bytes,0) + ".</span>" + show; //span for sorting
1882
< 1000)) {}
1883
 
1884
< 1000)) {function formatBPS(bps) {
1885
< 1000)) { var show = "";
1886
 
1887
< 1000)) { if (bps > Math.pow(1000, 5)) {
1888
< 1000)) { show += round(bps / Math.pow(1000, 5), 2);
1889
< 1000)) { show += String.fromCharCode(160) + 'Pb/s';
1890
< 1000)) { } else {
1891
< 1000)) { if (bps > Math.pow(1000, 4)) {
1892
< 1000)) { show += round(bps / Math.pow(1000, 4), 2);
1893
< 1000)) { show += String.fromCharCode(160) + 'Tb/s';
1894
< 1000)) { } else {
1895
< 1000)) { if (bps > Math.pow(1000, 3)) {
1896
< 1000)) { show += round(bps / Math.pow(1000, 3), 2);
1897
< 1000)) { show += String.fromCharCode(160) + 'Gb/s';
1898
< 1000)) { } else {
1899
< 1000)) { if (bps > Math.pow(1000, 2)) {
1900
< 1000)) { show += round(bps / Math.pow(1000, 2), 2);
1901
< 1000)) { show += String.fromCharCode(160) + 'Mb/s';
1902
< 1000)) { } else {
1903
< 1000)) { if (bps > Math.pow(1000, 1)) {
1904
< 1000)) { show += round(bps / Math.pow(1000, 1), 2);
1905
< 1000)) { show += String.fromCharCode(160) + 'Kb/s';
1906
< 1000)) { } else {
1907
< 1000)) { show += bps;
1908
< 1000)) { show += String.fromCharCode(160) + 'b/s';
1909
< 1000)) { }
1910
< 1000)) { }
1911
< 1000)) { }
1912
< 1000)) { }
1913
< 1000)) { }
1914
< 1000)) { return show;
1915
< 1000)) {}
1916
 
1917
< 1000)) {Array.prototype.pushIfNotExist = function(val) {
1918
< 1000)) { if (typeof(val) == 'undefined' || val === '') {
1919
< 1000)) { return;
1920
< 1000)) { }
1921
< 1000)) { val = $.trim(val);
1922
< 1000)) { if ($.inArray(val, this) == -1) {
1923
< 1000)) { this.push(val);
1924
< 1000)) { }
1925
< 1000)) {};
1926
 
1927
< 1000)) {/**
1928
< 1000)) { * generate a formatted datetime string of the current datetime
1929
< 1000)) { * @return {String} formatted datetime string
1930
< 1000)) { */
1931
< 1000)) {function datetime() {
1932
< 1000)) { var date, day = 0, month = 0, year = 0, hour = 0, minute = 0, days = "", months = "", years = "", hours = "", minutes = "";
1933
< 1000)) { date = new Date();
1934
< 1000)) { day = date.getDate();
1935
< 1000)) { month = date.getMonth() + 1;
1936
< 1000)) { year = date.getFullYear();
1937
< 1000)) { hour = date.getHours();
1938
< 1000)) { minute = date.getMinutes();
1939
 
1940
< 1000)) { // format values smaller that 10 with a leading 0
1941
< 1000)) { days = (day < 10) ? "0" + day.toString() : day.toString();
1942
< 1000)) {< 10) ? "0" + day.toString() : day.toString(); months = (month < 10) ? "0" + month.toString() : month.toString();
1943
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString(); years = (year < 1000) ? year.toString() : year.toString();
1944
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString(); minutes = (minute < 10) ? "0" + minute.toString() : minute.toString();
1945
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString(); hours = (hour < 10) ? "0" + hour.toString() : hour.toString();
1946
 
1947
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); return days + "." + months + "." + years + " - " + hours + ":" + minutes;
1948
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();}
1949
 
1950
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();/**
1951
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); * round a given value to the specified precision, difference to Math.round() is that there
1952
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); * will be appended Zeros to the end if the precision is not reached (0.1 gets rounded to 0.100 when precision is set to 3)
1953
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); * @param {Number} x value to round
1954
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); * @param {Number} n precision
1955
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); * @return {String}
1956
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); */
1957
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();function round(x, n) {
1958
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); var e = 0, k = "";
1959
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString(); if (n < 0 || n > 14) {
1960
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > return 0;
1961
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > }
1962
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > if (n === 0) {
1963
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > return Math.round(x);
1964
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > } else {
1965
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > e = Math.pow(10, n);
1966
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > k = (Math.round(x * e) / e).toString();
1967
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > if (k.indexOf('.') === -1) {
1968
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > k += '.';
1969
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > }
1970
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > k += e.toString().substring(1);
1971
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > return k.substring(0, k.indexOf('.') + n + 1);
1972
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n > }
1973
< 1000)) {< 10) ? "0" + day.toString() : day.toString();< 10) ? "0" + month.toString() : month.toString();< 1000) ? year.toString() : year.toString();< 10) ? "0" + minute.toString() : minute.toString();< 10) ? "0" + hour.toString() : hour.toString();< 0 || n >}