Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
2786 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: hyperv.js 679 2012-09-04 10:10:11Z namiltd $
22
//
23
 
24
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
25
 
26
"use strict";
27
 
28
var hyperv_show = false, hyperv_table;
29
 
30
//appendcss("./plugins/hyperv/css/hyperv.css");
31
 
32
/**
33
 * insert content into table
34
 * @param {jQuery} xml plugin-XML
35
 */
36
function hyperv_populate(xml) {
37
    var name = "", status = 0, state = "";
38
 
39
    hyperv_table.fnClearTable();
40
 
41
    $("Plugins Plugin_HyperV Machine", xml).each(function hyperv_getprocess(idp) {
42
        name = $(this).attr("Name");
43
        status = parseInt($(this).attr("State"), 10);
44
        if (!isNaN(status) && (status === 2)) {
45
            state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/hyperv/gfx/online.gif\" alt=\"online\" title=\"\" style=\"width:18px;\" />";
46
        }
47
        else {
48
            state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/hyperv/gfx/offline.gif\" alt=\"offline\" title=\"\" style=\"width:18px;\" />";
49
        }
50
        hyperv_table.fnAddData(["<span style=\"display:none;\">" + name + "</span>" + name, state]);
51
        hyperv_show = true;
52
    });
53
}
54
 
55
/**
56
 * fill the plugin block with table structure
57
 */
58
function hyperv_buildTable() {
59
    var html = "";
60
 
61
    html += "<div style=\"overflow-x:auto;\">\n";
62
    html += "  <table id=\"Plugin_HyperVTable\" style=\"border-collapse:collapse;\">\n";
63
    html += "    <thead>\n";
64
    html += "      <tr>\n";
65
    html += "        <th>" + genlang(2, "HyperV") + "</th>\n";
66
    html += "        <th>" + genlang(3, "HyperV") + "</th>\n";
67
    html += "      </tr>\n";
68
    html += "    </thead>\n";
69
    html += "    <tbody>\n";
70
    html += "    </tbody>\n";
71
    html += "  </table>\n";
72
    html += "</div>\n";
73
 
74
    $("#Plugin_HyperV").append(html);
75
 
76
    hyperv_table = $("#Plugin_HyperVTable").dataTable({
77
        "bPaginate": false,
78
        "bLengthChange": false,
79
        "bFilter": false,
80
        "bSort": true,
81
        "bInfo": false,
82
        "bProcessing": true,
83
        "bAutoWidth": false,
84
        "bStateSave": true,
85
        "aoColumns": [{
86
            "sType": 'span-string'
87
        }, {
88
            "sType": 'span-number'
89
        }]
90
    });
91
}
92
 
93
/**
94
 * load the xml via ajax
95
 */
96
function hyperv_request() {
97
    $("#Reload_HyperVTable").attr("title", "reload");
98
    $.ajax({
99
        url: "xml.php?plugin=HyperV",
100
        dataType: "xml",
101
        error: function hyperv_error() {
102
            $.jGrowl("Error loading XML document for Plugin HyperV!");
103
        },
104
        success: function hyperv_buildblock(xml) {
105
            populateErrors(xml);
106
            hyperv_populate(xml);
107
            if (hyperv_show) {
108
                plugin_translate("HyperV");
109
                $("#Plugin_HyperV").show();
110
            }
111
        }
112
    });
113
}
114
 
115
$(document).ready(function hyperv_buildpage() {
116
    $("#footer").before(buildBlock("HyperV", 1, true));
117
    $("#Plugin_HyperV").css("width", "451px");
118
 
119
    hyperv_buildTable();
120
 
121
    hyperv_request();
122
 
123
    $("#Reload_HyperVTable").click(function hyperv_reload(id) {
124
        hyperv_request();
125
        $(this).attr("title", datetime());
126
    });
127
});