/*
CategorySelector provides a convenient way to select a category.
Copyright (C) 2005, Daniel Kinzler, brightbyte.de
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; either version 2
of the License, or (at your option) any later version.
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.
*/
function bonsaiLoad(block, wiki, category) {
if (window.XMLHttpRequest) // if Mozilla, Safari etc
request = new XMLHttpRequest();
else if (window.ActiveXObject){ // if IE
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
else {
block.className = 'error';
block.innerHTML= "Sorry, your browser does not support loading page snippets dynamically.";
return;
}
request.onreadystatechange= function() {
if (request.readyState != 4) return;
if ( request.status==200 ) html= request.responseText;
else html= "failed to load "+url+" (code "+request.status+")";
block.innerHTML= html;
};
var url = "Bonsai.php?wiki="+escape(wiki)+"&cat="+escape(category);
request.open('GET', url, true);
request.send(null);
}
function bonsaiExpand(link, wiki, category) {
category = unescape(category);
if (link.innerHTML == '+') {
if (link.className != "loaded") {
link.className = "loaded";
var block = document.createElement('div');
block.innerHTML = '...loading...';
block.style.padding = '0 0 0 1em';
link.parentNode.insertBefore(block, null);
bonsaiLoad(block, wiki, category);
}
var e = link.nextSibling;
while (e) {
if (e.tagName == 'DIV' || e.tagName == 'UL') e.style.display = 'block';
e = e.nextSibling;
}
link.innerHTML = '–';
}
else {
var e = link.nextSibling;
while (e) {
if (e.tagName == 'DIV' || e.tagName == 'UL') e.style.display = 'none';
e = e.nextSibling;
}
link.innerHTML = '+';
}
}
Bonsai.js
text/javascript, 2562 bytes (load raw)

