X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fphp-collection%2Fbrowser.js;fp=contrib%2Fphp-collection%2Fbrowser.js;h=9fcdbabe035a5b2146077383587d5ac83cc6f836;hb=a019b6c8144745db63c599680bd693ac02f11666;hp=0000000000000000000000000000000000000000;hpb=32c70908f797633ec7a774c3bec273afda49158f;p=collectd.git diff --git a/contrib/php-collection/browser.js b/contrib/php-collection/browser.js new file mode 100644 index 00000000..9fcdbabe --- /dev/null +++ b/contrib/php-collection/browser.js @@ -0,0 +1,458 @@ +/* + * Copyright (C) 2009 Bruno Prémont + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +// Toggle visibility of a div +function toggleDiv(divID) { + var div = document.getElementById(divID); + var label = document.getElementById(divID+'_sw'); + var label_txt = null; + if (div) { + if (div.style.display == 'none') { + div.style.display = 'block'; + label_txt = 'Hide'; + } else { + div.style.display = 'none'; + label_txt = 'Show'; + } + } + if (label_txt && label) { + var childCnt = label.childNodes.length; + while (childCnt > 0) + label.removeChild(label.childNodes[--childCnt]); + label.appendChild(document.createTextNode(label_txt)); + } +} + +// DHTML helper code to asynchronous loading of content +function loadXMLDoc(url, query) { + if (window.XMLHttpRequest) { + req = new XMLHttpRequest(); + req.onreadystatechange = processReqChange; + req.open('POST', url, true); + req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + req.send(query); + } else if (window.ActiveXObject) { + req = new ActiveXObject("Microsoft.XMLHTTP"); + if (req) { + req.onreadystatechange = processReqChange; + req.open('POST', url, true); + req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + req.send(query); + } + } +} + +// DHTML new-content dispatcher +function processReqChange() { + if (req.readyState == 4) { + if (req.status == 200) { + response = req.responseXML.documentElement; + method = response.getElementsByTagName('method')[0].firstChild.data; + result = response.getElementsByTagName('result')[0]; + eval(method + '(result)'); + } + } +} + +// Update contents of a