Subversion Repositories ALCASAR

Rev

Rev 3100 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3100 Rev 3179
Line 1... Line 1...
1
var langxml = [], langarr = [], current_language = "", plugins = [], blocks = [], plugin_liste = [],
1
var langxml = [], langarr = [], current_language = "", plugins = [], blocks = [], plugin_liste = [],
2
     showCPUListExpanded, showCPUInfoExpanded, showNetworkInfosExpanded, showNetworkActiveSpeed, showCPULoadCompact, oldnetwork = [], refrTimer;
2
     showCPUListExpanded, showCPUInfoExpanded, showNetworkInfosExpanded, showNetworkActiveSpeed, showCPULoadCompact, oldnetwork = [], refrTimer;
3
 
3
 
4
/**
4
/**
-
 
5
 * Fix potential XSS vulnerability in jQuery
-
 
6
 */
-
 
7
jQuery.htmlPrefilter = function( html ) {
-
 
8
	return html;
-
 
9
};
-
 
10
 
-
 
11
/**
5
 * generate a cookie, if not exist, and add an entry to it<br><br>
12
 * 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>
13
 * 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
14
 * @param {String} name name that holds the value
8
 * @param {String} value value that needs to be stored
15
 * @param {String} value value that needs to be stored
9
 * @param {Number} days how many days the entry should be valid in the cookie
16
 * @param {Number} days how many days the entry should be valid in the cookie
Line 229... Line 236...
229
                    $("#errorbutton").css("visibility", "visible");
236
                    $("#errorbutton").css("visibility", "visible");
230
                }
237
                }
231
            }
238
            }
232
        },
239
        },
233
        success: function (data) {
240
        success: function (data) {
-
 
241
            var refrtime;
234
//            console.log(data);
242
//            console.log(data);
235
//            data_dbg = data;
243
//            data_dbg = data;
236
            if ((typeof(initiate) === 'boolean') && (data.Options !== undefined) && (data.Options["@attributes"] !== undefined) && ((refrtime = data.Options["@attributes"].refresh) !== undefined) && (refrtime !== "0")) {
244
            if ((typeof(initiate) === 'boolean') && (data.Options !== undefined) && (data.Options["@attributes"] !== undefined) && ((refrtime = data.Options["@attributes"].refresh) !== undefined) && (refrtime !== "0")) {
237
                    if ((initiate === false) && (typeof(refrTimer) === 'number')) {
245
                    if ((initiate === false) && (typeof(refrTimer) === 'number')) {
238
                        clearInterval(refrTimer);
246
                        clearInterval(refrTimer);
Line 290... Line 298...
290
         url: "xml.php?plugin=" + pluginname + "&json",
298
         url: "xml.php?plugin=" + pluginname + "&json",
291
         pluginname: pluginname,
299
         pluginname: pluginname,
292
         success: function (data) {
300
         success: function (data) {
293
            try {
301
            try {
294
                for (var propertyName in data.Plugins) {
302
                for (var propertyName in data.Plugins) {
295
                    if ((data.Plugins[propertyName]["@attributes"] !== undefined) && 
303
                    if ((data.Plugins[propertyName]["@attributes"] !== undefined) &&
296
                       ((hostname = data.Plugins[propertyName]["@attributes"]["Hostname"]) !== undefined)) {
304
                       ((hostname = data.Plugins[propertyName]["@attributes"].Hostname) !== undefined)) {
297
                        $('span[class=hostname_' + pluginname + ']').html(hostname);
305
                        $('span[class=hostname_' + pluginname + ']').html(hostname);
298
                    }
306
                    }
299
                    break;
307
                    break;
300
                }
308
                }
301
                // dynamic call
309
                // dynamic call
Line 321... Line 329...
321
        $(document).ajaxStop(function () {
329
        $(document).ajaxStop(function () {
322
            $("#loader").css("visibility", "hidden");
330
            $("#loader").css("visibility", "hidden");
323
        });
331
        });
324
    }
332
    }
325
 
333
 
-
 
334
    if ((ua=useragent.match(/Midori\/(\d+)\.?(\d+)?/)) !== null) {
-
 
335
        if ((ua[1]==0) && (ua.length==3) && (ua[2]<=4)) {
-
 
336
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori04.css');
-
 
337
        } else if ((ua[1]==0) && (ua.length==3) && (ua[2]==5)) {
-
 
338
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori05.css');
-
 
339
        }
326
    if ((ua=useragent.match(/Version\/(\d+)\.[\d\.]+ (Mobile\/\S+ )?Safari\//)) !== null) {
340
    } else if ((ua=useragent.match(/\(KHTML, like Gecko\) Version\/(\d+)\.[\d\.]+ (Mobile\/\S+ )?Safari\//)) !== null) {
327
        if (ua[1]<=5) {
341
        if (ua[1]<=5) {
328
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari5.css');
342
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari5.css');
329
        } else if (ua[1]<=8) {
343
        } else if (ua[1]<=8) {
330
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari8.css');
344
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-safari8.css');
331
        }
345
        }
332
    } else if ((ua=useragent.match(/Firefox\/(\d+)\.[\d\.]+/))  !== null) {
346
    } else if ((ua=useragent.match(/Firefox\/(\d+)\.[\d\.]+/)) !== null) {
333
        if (ua[1]<=15) {
347
        if (ua[1]<=15) {
334
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox15.css');
348
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox15.css');
335
        } else if (ua[1]<=20) {
349
        } else if (ua[1]<=20) {
336
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox20.css');
350
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox20.css');
337
        } else if (ua[1]<=27) {
351
        } else if (ua[1]<=27) {
338
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox27.css');
352
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox27.css');
339
        } else if (ua[1]==28) {
353
        } else if (ua[1]==28) {
340
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox28.css');
354
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-firefox28.css');
341
        }
355
        }
342
    } else if ((ua=useragent.match(/Midori\/(\d+)\.?(\d+)?/))  !== null) {
-
 
343
        if ((ua[1]==0) && (ua.length==3) && (ua[2]<=4)) {
-
 
344
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori04.css');
-
 
345
        } else if ((ua[1]==0) && (ua.length==3) && (ua[2]==5)) {
-
 
346
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-midori05.css');
-
 
347
        }
-
 
348
    } else if ((ua=useragent.match(/Chrome\/(\d+)\.[\d\.]+/))  !== null) {
356
    } else if ((ua=useragent.match(/Chrome\/(\d+)\.[\d\.]+/)) !== null) {
349
        if (ua[1]<=25) {
357
        if (ua[1]<=25) {
350
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome25.css');
358
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome25.css');
351
        } else if (ua[1]<=28) {
359
        } else if (ua[1]<=28) {
352
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome28.css');
360
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-chrome28.css');
353
        }
361
        }
-
 
362
    } else if ((ua=useragent.match(/^Opera\/.*Version\/(\d+)\.[\d\.]+$/)) !== null) {
-
 
363
        if (ua[1]<=11) {
-
 
364
            $("#PSI_CSS_Fix")[0].setAttribute('href', 'templates/vendor/bootstrap-opera11.css');
-
 
365
        }
354
    }
366
    }
355
 
367
 
356
    $(window).resize();
368
    $(window).resize();
357
 
369
 
358
    sorttable.init();
370
    sorttable.init();
Line 597... Line 609...
597
                }
609
                }
598
            }
610
            }
599
        },
611
        },
600
        Distro: {
612
        Distro: {
601
            html: function () {
613
            html: function () {
602
                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>';
614
                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="" title="' + this.Distroicon + '" style="width:32px;height:32px;" /></td><td style="vertical-align:middle;">' + this.Distro + '</td></tr></table>';
603
            }
615
            }
604
        },
616
        },
605
        OS: {
617
        OS: {
606
            html: function () {
618
            html: function () {
607
                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>';
619
                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="" title="' + this.OS + '.png" style="width:32px;height:32px;" /></td><td style="vertical-align:middle;">' + this.OS + '</td></tr></table>';
608
            }
620
            }
609
        },
621
        },
610
        LoadAvg: {
622
        LoadAvg: {
611
            html: function () {
623
            html: function () {
612
                if (this.CPULoad !== undefined) {
624
                if (this.CPULoad !== undefined) {
Line 618... Line 630...
618
                }
630
                }
619
            }
631
            }
620
        },
632
        },
621
        Processes: {
633
        Processes: {
622
            html: function () {
634
            html: function () {
623
                var processes = "", p111 = 0, p112 = 0, p113 = 0, p114 = 0, p115 = 0, p116 = 0;
635
                var processes = 0, psarray = [0,0,0,0,0,0];
624
                var not_first = false;
636
                var not_first = false;
625
                processes = parseInt(this.Processes, 10);
637
                processes = parseInt(this.Processes, 10);
626
                if (processes > 0) {
638
                if (processes > 0) {
627
                    if (this.ProcessesRunning !== undefined) {
639
                    if (this.ProcessesRunning !== undefined) {
628
                        p111 = parseInt(this.ProcessesRunning, 10);
640
                        psarray[0] = parseInt(this.ProcessesRunning, 10);
629
                    }
641
                    }
630
                    if (this.ProcessesSleeping !== undefined) {
642
                    if (this.ProcessesSleeping !== undefined) {
631
                        p112 = parseInt(this.ProcessesSleeping, 10);
643
                        psarray[1] = parseInt(this.ProcessesSleeping, 10);
632
                    }
644
                    }
633
                    if (this.ProcessesStopped !== undefined) {
645
                    if (this.ProcessesStopped !== undefined) {
634
                        p113 = parseInt(this.ProcessesStopped, 10);
646
                        psarray[2] = parseInt(this.ProcessesStopped, 10);
635
                    }
647
                    }
636
                    if (this.ProcessesZombie !== undefined) {
648
                    if (this.ProcessesZombie !== undefined) {
637
                        p114 = parseInt(this.ProcessesZombie, 10);
649
                        psarray[3] = parseInt(this.ProcessesZombie, 10);
638
                    }
650
                    }
639
                    if (this.ProcessesWaiting !== undefined) {
651
                    if (this.ProcessesWaiting !== undefined) {
640
                        p115 = parseInt(this.ProcessesWaiting, 10);
652
                        psarray[4] = parseInt(this.ProcessesWaiting, 10);
641
                    }
653
                    }
642
                    if (this.ProcessesOther !== undefined) {
654
                    if (this.ProcessesOther !== undefined) {
643
                        p116 = parseInt(this.ProcessesOther, 10);
655
                        psarray[5] = parseInt(this.ProcessesOther, 10);
644
                    }
656
                    }
645
                    if (p111 || p112 || p113 || p114 || p115 || p116) {
657
                    if (psarray[0] || psarray[1] || psarray[2] || psarray[3] || psarray[4] || psarray[5]) {
646
                        processes += " (";
658
                        processes += " (";
647
                        for (var proc_type in {111:0,112:1,113:2,114:3,115:4,116:5}) {
659
                        var idlist = {0:111,1:112,2:113,3:114,4:115,5:116};
-
 
660
                        for (var proc_type in idlist) {
648
                            if (eval("p" + proc_type)) {
661
                            if (psarray[proc_type]) {
649
                                if (not_first) {
662
                                if (not_first) {
650
                                    processes += ", ";
663
                                    processes += ", ";
651
                                }
664
                                }
652
                                processes += eval("p" + proc_type) + String.fromCharCode(160) + genlang(proc_type);
665
                                processes += psarray[proc_type] + String.fromCharCode(160) + genlang(idlist[proc_type]);
653
                                not_first = true;
666
                                not_first = true;
654
                            }
667
                            }
655
                        }
668
                        }
656
                        processes += ")";
669
                        processes += ")";
657
                    }
670
                    }
Line 726... Line 739...
726
                return formatTemp(this.Cputemp, data.Options["@attributes"].tempFormat);
739
                return formatTemp(this.Cputemp, data.Options["@attributes"].tempFormat);
727
            }
740
            }
728
        },
741
        },
729
        Voltage: {
742
        Voltage: {
730
            html: function() {
743
            html: function() {
731
                return round(this.Voltage, 2) + genlang(82); //V
744
                return round(this.Voltage, 2) + String.fromCharCode(160) + genlang(62); //V
732
            }
745
            }
733
        },
746
        },
734
        Bogomips: {
747
        Bogomips: {
735
            text: function () {
748
            text: function () {
736
                return parseInt(this.Bogomips, 10);
749
                return parseInt(this.Bogomips, 10);
Line 768... Line 781...
768
                return formatMTps(this.Speed);
781
                return formatMTps(this.Speed);
769
            }
782
            }
770
        },
783
        },
771
        Voltage: {
784
        Voltage: {
772
            html: function() {
785
            html: function() {
773
                return round(this.Voltage, 2)  + genlang(82); //V
786
                return round(this.Voltage, 2) + String.fromCharCode(160) + genlang(62); //V
774
            }
787
            }
775
        },
788
        },
776
        Capacity: {
789
        Capacity: {
777
            html: function () {
790
            html: function () {
778
                return formatBytes(this.Capacity, data.Options["@attributes"].byteFormat);
791
                return formatBytes(this.Capacity, data.Options["@attributes"].byteFormat);
Line 793... Line 806...
793
        }
806
        }
794
    };
807
    };
795
 
808
 
796
    var html="";
809
    var html="";
797
 
810
 
798
    if (data.Hardware["@attributes"] !== undefined) { 
811
    if (data.Hardware["@attributes"] !== undefined) {
799
        if (data.Hardware["@attributes"].Name !== undefined) {
812
        if (data.Hardware["@attributes"].Name !== undefined) {
800
            html+="<tr id=\"hardware-Machine\">";
813
            html+="<tr id=\"hardware-Machine\">";
801
            html+="<th style=\"width:8%;\">"+genlang(107)+"</th>"; //Machine
814
            html+="<th style=\"width:8%;\">"+genlang(107)+"</th>"; //Machine
802
            html+="<td colspan=\"2\"><span data-bind=\"Name\"></span></td>";
815
            html+="<td colspan=\"2\"><span data-bind=\"Name\"></span></td>";
803
            html+="</tr>";
816
            html+="</tr>";
Line 860... Line 873...
860
                    html+="<th>" + hw_type + "</th>";
873
                    html+="<th>" + hw_type + "</th>";
861
                    if (hw_type == 'MEM') {
874
                    if (hw_type == 'MEM') {
862
                        html+="<td><span class=\"treegrid-span\">" + genlang('128') + ":</span></td>"; //Number of memories
875
                        html+="<td><span class=\"treegrid-span\">" + genlang('128') + ":</span></td>"; //Number of memories
863
                    } else {
876
                    } else {
864
                        html+="<td><span class=\"treegrid-span\">" + genlang('120') + ":</span></td>"; //Number of devices
877
                        html+="<td><span class=\"treegrid-span\">" + genlang('120') + ":</span></td>"; //Number of devices
865
                    }                    
878
                    }
866
                    html+="<td class=\"rightCell\"><span id=\"" + hw_type + "Count\"></span></td>";
879
                    html+="<td class=\"rightCell\"><span id=\"" + hw_type + "Count\"></span></td>";
867
                    html+="</tr>";
880
                    html+="</tr>";
868
                }
881
                }
869
                html+="<tr id=\"hardware-" + hw_type + "-" + i +"\" class=\"treegrid-" + hw_type + "-" + i +" treegrid-parent-" + hw_type + "\">";
882
                html+="<tr id=\"hardware-" + hw_type + "-" + i +"\" class=\"treegrid-" + hw_type + "-" + i +" treegrid-parent-" + hw_type + "\">";
870
                html+="<th></th>";
883
                html+="<th></th>";
Line 1128... Line 1141...
1128
                return this.Name.replace(/;/g, ";<wbr>") + ((this.MountOptions !== undefined) ? '<br><i>(' + this.MountOptions + ')</i>' : '');
1141
                return this.Name.replace(/;/g, ";<wbr>") + ((this.MountOptions !== undefined) ? '<br><i>(' + this.MountOptions + ')</i>' : '');
1129
            }
1142
            }
1130
        },
1143
        },
1131
        Percent: {
1144
        Percent: {
1132
            html: function () {
1145
            html: function () {
1133
                var used1 = (this.Total != 0) ? Math.ceil((this.Used / this.Total) * 100) : 0;
1146
                var used1 = Math.max(Math.min((this.Total != 0) ? Math.ceil((this.Used / this.Total) * 100) : 0, 100), 0);
1134
                var used2 = Math.ceil(this.Percent);
1147
                var used2 = Math.max(Math.min(Math.ceil(this.Percent), 100), 0);
1135
                var used21= used2 - used1;
1148
                var used21= used2 - used1;
1136
                if (used21 > 0) {
1149
                if (used21 > 0) {
1137
                    return '
' + '
1150
                    return '
' + '
1138
 
1151
 
1139
 
1152
 
1140
 
1153
 
1141
 
1154
 
1142
 
1155
 
1143
 
1156
 
1144
 
1157
 
1145
 
1158
 
1146
 
1159
 
1147
 
1160
 
Line 1159... Line 1172...
1159
 
1172
 
1160
 
1173
 
1161
 
1174
 
1162
 
1175
 
1163
 
1176
 
1164
 
1177
 
1165
 
1178
 
1166
 
1179
 
1167
 
1180
 
1168
 
1181
 
1169
 
1182
 
Line 1198... Line 1211...
1198
 
1211
 
1199
 
1212
 
1200
 
1213
 
1201
 
1214
 
1202
 
1215
 
-
 
1216
 
-
 
1217
 
-
 
1218
 
-
 
1219
 
-
 
1220
 
-
 
1221
 
-
 
1222
 
-
 
1223
 
-
 
1224
 
1203
 
1225
 
1204
 
1226
 
1205
 
1227
 
1206
 
1228
 
1207
 
1229
 
1208
 
1230
 
1209
 
1231
 
1210
 
1232
 
1211
 
1233
 
1212
 
1234
 
1213
 
1235
 
1214
 
1236
 
1215
 
1237
 
1216
 
1238
 
1217
 
1239
 
Line 1315... Line 1337...
1315
 
1337
 
1316
 
1338
 
1317
 
1339
 
1318
 
1340
 
1319
 
1341
 
1320
 
1342
 
1321
 
1343
 
1322
 
1344
 
1323
 
1345
 
1324
 
1346
 
1325
 
1347
 
Line 1407... Line 1429...
1407
 
1429
 
1408
 
1430
 
1409
 
1431
 
1410
 
1432
 
1411
 
1433
 
-
 
1434
 
1412
 
1435
 
1413
 
1436
 
1414
 
1437
 
-
 
1438
 
-
 
1439
 
1415
 
1440
 
1416
 
1441
 
1417
 
1442
 
1418
 
1443
 
1419
 
1444
 
1420
 
1445
 
1421
 
1446
 
Line 1460... Line 1485...
1460
 
1485
 
1461
 
1486
 
1462
 
1487
 
1463
 
1488
 
1464
 
1489
 
1465
 
1490
 
1466
 
1491
 
1467
 
1492
 
1468
 
1493
 
1469
 
1494
 
1470
 
1495
 
Line 1503... Line 1528...
1503
 
1528
 
1504
 
1529
 
1505
 
1530
 
1506
 
1531
 
1507
 
1532
 
1508
 
1533
 
1509
 
1534
 
1510
 
1535
 
1511
 
1536
 
1512
 
1537
 
1513
 
1538
 
Line 1553... Line 1578...
1553
 
1578
 
1554
 
1579
 
1555
 
1580
 
1556
 
1581
 
1557
 
1582
 
-
 
1583
 
1558
 
1584
 
1559
 
1585
 
1560
 
1586
 
-
 
1587
 
1561
 
1588
 
1562
 
1589
 
1563
 
1590
 
1564
 
1591
 
1565
 
1592
 
1566
 
1593