2785 |
rexy |
1 |
/***************************************************************************
|
|
|
2 |
* Copyright (C) 2008 by phpSysInfo - A PHP System Information Script *
|
|
|
3 |
* http://phpsysinfo.sourceforge.net/ *
|
|
|
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
8 |
* (at your option) any later version. *
|
|
|
9 |
* *
|
|
|
10 |
* This program is distributed in the hope that it will be useful, *
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
13 |
* GNU General Public License for more details. *
|
|
|
14 |
* *
|
|
|
15 |
* You should have received a copy of the GNU General Public License *
|
|
|
16 |
* along with this program; if not, write to the *
|
|
|
17 |
* Free Software Foundation, Inc., *
|
|
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
19 |
***************************************************************************/
|
|
|
20 |
//
|
|
|
21 |
// $Id: pingtest.js 1 2017-09-01 08:23:45Z namiltd $
|
|
|
22 |
//
|
|
|
23 |
|
|
|
24 |
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
|
|
|
25 |
|
|
|
26 |
"use strict";
|
|
|
27 |
|
|
|
28 |
var pingtest_show = false, pingtest_table;
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* insert content into table
|
|
|
33 |
* @param {jQuery} xml plugin-XML
|
|
|
34 |
*/
|
|
|
35 |
function pingtest_populate(xml) {
|
|
|
36 |
var address = "", pingtime = 0, state = "";
|
|
|
37 |
|
|
|
38 |
pingtest_table.fnClearTable();
|
|
|
39 |
|
|
|
40 |
$("Plugins Plugin_PingTest Ping", xml).each(function pingtest_getprocess(idp) {
|
|
|
41 |
address = $(this).attr("Address");
|
|
|
42 |
pingtime = parseInt($(this).attr("PingTime"), 10);
|
|
|
43 |
if (!isNaN(pingtime)) {
|
|
|
44 |
state = "<span style=\"display:none;\">" + pingtime.toString() + "</span>" + pingtime.toString() + " ms";
|
|
|
45 |
}
|
|
|
46 |
else {
|
|
|
47 |
state = "<span style=\"display:none;\">1000000</span>" + genlang(4, "PingTest");
|
|
|
48 |
}
|
|
|
49 |
pingtest_table.fnAddData(["<span style=\"display:none;\">" + address + "</span>" + address, state]);
|
|
|
50 |
pingtest_show = true;
|
|
|
51 |
});
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* fill the plugin block with table structure
|
|
|
56 |
*/
|
|
|
57 |
function pingtest_buildTable() {
|
|
|
58 |
var html = "";
|
|
|
59 |
|
|
|
60 |
html += "<div style=\"overflow-x:auto;\">\n";
|
|
|
61 |
html += " <table id=\"Plugin_PingTestTable\" style=\"border-collapse:collapse;\">\n";
|
|
|
62 |
html += " <thead>\n";
|
|
|
63 |
html += " <tr>\n";
|
|
|
64 |
html += " <th>" + genlang(2, "PingTest") + "</th>\n";
|
|
|
65 |
html += " <th>" + genlang(3, "PingTest") + "</th>\n";
|
|
|
66 |
html += " </tr>\n";
|
|
|
67 |
html += " </thead>\n";
|
|
|
68 |
html += " <tbody>\n";
|
|
|
69 |
html += " </tbody>\n";
|
|
|
70 |
html += " </table>\n";
|
|
|
71 |
html += "</div>\n";
|
|
|
72 |
|
|
|
73 |
$("#Plugin_PingTest").append(html);
|
|
|
74 |
|
|
|
75 |
pingtest_table = $("#Plugin_PingTestTable").dataTable({
|
|
|
76 |
"bPaginate": false,
|
|
|
77 |
"bLengthChange": false,
|
|
|
78 |
"bFilter": false,
|
|
|
79 |
"bSort": true,
|
|
|
80 |
"bInfo": false,
|
|
|
81 |
"bProcessing": true,
|
|
|
82 |
"bAutoWidth": false,
|
|
|
83 |
"bStateSave": true,
|
|
|
84 |
"aoColumns": [{
|
|
|
85 |
"sType": 'span-ip'
|
|
|
86 |
}, {
|
|
|
87 |
"sType": 'span-number'
|
|
|
88 |
}]
|
|
|
89 |
});
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* load the xml via ajax
|
|
|
94 |
*/
|
|
|
95 |
function pingtest_request() {
|
|
|
96 |
$("#Reload_PingTestTable").attr("title", "reload");
|
|
|
97 |
$.ajax({
|
|
|
98 |
url: "xml.php?plugin=PingTest",
|
|
|
99 |
dataType: "xml",
|
|
|
100 |
error: function pingtest_error() {
|
|
|
101 |
$.jGrowl("Error loading XML document for Plugin PingTest!");
|
|
|
102 |
},
|
|
|
103 |
success: function pingtest_buildblock(xml) {
|
|
|
104 |
populateErrors(xml);
|
|
|
105 |
pingtest_populate(xml);
|
|
|
106 |
if (pingtest_show) {
|
|
|
107 |
plugin_translate("PingTest");
|
|
|
108 |
$("#Plugin_PingTest").show();
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
});
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
$(document).ready(function pingtest_buildpage() {
|
|
|
115 |
$("#footer").before(buildBlock("PingTest", 1, true));
|
|
|
116 |
$("#Plugin_PingTest").css("width", "451px");
|
|
|
117 |
|
|
|
118 |
pingtest_buildTable();
|
|
|
119 |
|
|
|
120 |
pingtest_request();
|
|
|
121 |
|
|
|
122 |
$("#Reload_PingTestTable").click(function pingtest_reload(id) {
|
|
|
123 |
pingtest_request();
|
|
|
124 |
$(this).attr("title", datetime());
|
|
|
125 |
});
|
|
|
126 |
});
|