Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
<script type="text/Javascript">
// Open/Close Categories Without Refresh (Partial) by Chris
// Do not redistribute without permission of the creator

var hideIcon = "http://hyperboards.com/v2images/home__expand_category.gif"; // Will hide the category
var showIcon = "http://hyperboards.com/v2images/home__collapse_category.gif"; // Will show the category

// Don't edit
function _sendReq(url){
if(!document.all){
var Req = new XMLHttpRequest();
Req.open("GET", url, true);
Req.send("");
} else {
// Workaround since IE is extremely stupid. =/
var s = document.createElement("script");
s.type = "text/Javascript"
s.src = url;
document.getElementsByTagName("head")[0].appendChild(s);
}
}

function hs(){
var e = this;
var i = e.parentNode.parentNode.parentNode.parentNode.parentNode;
if(!i.rows[1]){
location.href = e.id;
return;
}
_sendReq(e.id);
n = 0;
while(i.rows[n+1]){
n++;
i.rows[n].style.display = (i.rows[n].style.display == "none"?"":"none");
}
e.src = (e.src == hideIcon?showIcon:hideIcon);
var rep = "type="+(e.id.match(/type=e/)?"c":"e");
e.id = e.id.replace(/type=(e|c)/, rep);
}

if(!location.href.match(/action=/i) || location.href.match(/action=home/i)){
var aIM = document.images;
for(a=0;a<aIM.length;a++){
if(aIM[a].alt && aIM[a].alt.match(/(Expand|Collapse)\sCat/i)){
aIM[a].id = aIM[a].parentNode.href;
aIM[a].parentNode.href = "javascript:void(0)";
aIM[a].onclick = hs;
}
}
}
</script>


What this code does is it makes it so you can hide/show categories without refreshing the page. It uses the default HB hide/show system so it'll remember your members' settings if you ever remove the hack. However, the reason the title says "Partial" is because when you visit the main page and show a hidden category, the data isn't there to be shown. Thus, it MUST refresh in that case so the data can be shown.

The module should go in your main footers. :)

newBookmarkLockedFalling