/*
CategoryTree shows the category structure of a MediaWiki
as a dynamic tree.
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 expandNode(cat,node) {
var lnk= document.getElementById('link-'+node);
var div= document.getElementById('content-'+node);
div.style.display= 'block';
lnk.innerHTML= '–';
lnk.title= 'collapse';
lnk.href= 'javascript:collapseNode("'+cat+'","'+node+'")';
if (lnk.className != "loaded") {
var url= sectionLoadURL+'&cat='+encodeURIComponent(cat)+'&node='+encodeURIComponent(node);
loadNode(url,cat,node);
}
}
function collapseNode(cat,node) {
var lnk= document.getElementById('link-'+node);
var div= document.getElementById('content-'+node);
div.style.display= 'none';
lnk.innerHTML= '+';
lnk.title= 'expand';
lnk.href= 'javascript:expandNode("'+cat+'","'+node+'")';
}
function loadNode(url, cat, node) {
var page_request = false;
var lnk= document.getElementById('link-'+node);
var div= document.getElementById('content-'+node);
div.innerHTML= "<i class='loading'>loading...</i>";
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest();
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
else {
div.innerHTML= "<div class='error'>Sorry, your browser does not support loading page snippets dynamically.</div>";
return;
}
page_request.onreadystatechange= function() {
if (page_request.readyState != 4) return;
var html= false;
if ( page_request.status==200 ) html= page_request.responseText;
else html= "failed to load "+url+" (code "+page_request.status+")";
if (lnk) {
div.style.display= 'block';
lnk.className= 'loaded';
lnk.innerHTML= '–';
lnk.title= 'collapse';
lnk.href= 'javascript:collapseNode("'+cat+'","'+node+'")';
}
div.innerHTML= html;
};
page_request.open('GET', url, true);
page_request.send(null);
}
CategoryTree.js
text/javascript, 3147 bytes (load raw)

