[Phpsysinfo-subversion] SF.net SVN: phpsysinfo:[164] plugins/psstatus/js/psstatus.js
Brought to you by:
namiltd
From: <big...@us...> - 2009-03-26 13:57:35
|
Revision: 164 http://phpsysinfo.svn.sourceforge.net/phpsysinfo/?rev=164&view=rev Author: bigmichi1 Date: 2009-03-26 13:57:34 +0000 (Thu, 26 Mar 2009) Log Message: ----------- add rows with dataTable function not with append() Modified Paths: -------------- plugins/psstatus/js/psstatus.js Modified: plugins/psstatus/js/psstatus.js =================================================================== --- plugins/psstatus/js/psstatus.js 2009-03-26 12:55:26 UTC (rev 163) +++ plugins/psstatus/js/psstatus.js 2009-03-26 13:57:34 UTC (rev 164) @@ -23,41 +23,44 @@ /*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */ -var psstatus_show = false; +var psstatus_show = false, psstatus_table; /** - * build the table where content is inserted + * insert content into table * @param {jQuery} xml plugin-XML */ -function psstatus_buildTable(xml) { - var html = "", processstatus, name, status; +function psstatus_populate(xml) { + var processstatus, psstatus, plugins, name = "", status = 0, state = ""; - $("ProcessStatus", xml).each(function psstatus_getprocessstatus(id) { - processstatus = $("ProcessStatus", xml).get(id); - name = $("Name", processstatus).text().toString(); - status = parseInt($("Status", processstatus).text().toString(), 10); - - html += " <tr>\n"; - html += " <td><span style=\"display:none;\">" + name + "</span>" + name + "</td>\n"; - if (status === 1) { - html += " <td><span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/online.png\" alt=\"online\" /></td>\n"; - } - else { - html += " <td><span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/offline.png\" alt=\"offline\" /></td>\n"; - } - html += " </tr>\n"; + psstatus_table.fnClearTable(); + + $("Plugins", xml).each(function psstatus_getplugins(idp) { + plugins = $("Plugins", xml).get(idp); + $("Plugin_PSStatus", plugins).each(function psstatus_getplugin(ids) { + psstatus = $("Plugin_PSStatus", plugins).get(ids); + $("ProcessStatus", xml).each(function psstatus_getprocessstatus(idps) { + processstatus = $("ProcessStatus", xml).get(idps); + name = $("Name", processstatus).text().toString(); + status = parseInt($("Status", processstatus).text().toString(), 10); + if (status === 1) { + state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/online.png\" alt=\"online\" />"; + } + else { + state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/offline.png\" alt=\"offline\" />"; + } + psstatus_table.fnAddData(["<span style=\"display:none;\">" + name + "</span>" + name, state]); + }); + }); + psstatus_show = true; }); - return html; } /** - * fill the plugin block with data from xml - * @param {jQuery} xml plugin-XML + * fill the plugin block with table structure */ -function psstatus_populate(xml) { - var plugins, psstatus, html = ""; +function psstatus_buildTable() { + var html = ""; - $("#Plugin_PSStatus div").remove(); html += "<table id=\"Plugin_PSStatusTable\" cellspacing=\"0\">\n"; html += " <thead>\n"; html += " <tr>\n"; @@ -68,30 +71,23 @@ html += " <tbody>\n"; html += " </tbody>\n"; html += "</table>\n"; + $("#Plugin_PSStatus").append(html); - $("Plugins", xml).each(function psstatus_getplugins(id) { - plugins = $("Plugins", xml).get(id); - $("Plugin_PSStatus", plugins).each(function psstatus_getplugin(id) { - psstatus = $("Plugin_PSStatus", plugins).get(id); - $("#Plugin_PSStatusTable tbody").append(psstatus_buildTable(psstatus)); - $("#Plugin_PSStatusTable").dataTable({ - "bPaginate": false, - "bLengthChange": false, - "bFilter": false, - "bSort": true, - "bInfo": false, - "bProcessing": true, - "bAutoWidth": false, - "bStateSave": true, - "aoColumns": [{ - "sType": 'span-string' - }, { - "sType": 'span-number' - }] - }); - psstatus_show = true; - }); + psstatus_table = $("#Plugin_PSStatusTable").dataTable({ + "bPaginate": false, + "bLengthChange": false, + "bFilter": false, + "bSort": true, + "bInfo": false, + "bProcessing": true, + "bAutoWidth": false, + "bStateSave": true, + "aoColumns": [{ + "sType": 'span-string' + }, { + "sType": 'span-number' + }] }); } @@ -119,6 +115,8 @@ $("#footer").before(buildBlock("PSStatus", 1, true)); $("#Plugin_PSStatus").css("width", "915px"); + psstatus_buildTable(); + psstatus_request(); $("#Reload_PSStatusTable").click(function psstatus_reload(id) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |