Flip/flop tables
Posted: Mon Aug 16, 2004 5:46 pm
Hi all....it's been a long time..
Eventualy I had to come back for something...
I'm trying to make my cute tables to fold up/down like on this page: http://nhdp.nl/
I managed to gracefully steal the code, and include it into my page,...
But their are just 2 problems remaining.
See http://redhair.nl.nu/news
As you might notice, the menu's are folding great, but here is the catch: The minus image does not get changed to a plus image (..while it is there), and also the cookies dont seem to work (...which will remember the last folding state of a particular menu.).
Here is the javascript:
Maybe one of you can see the problem....
I am getting rather dizzy..
And I only had 2 beers....
Eventualy I had to come back for something...
I'm trying to make my cute tables to fold up/down like on this page: http://nhdp.nl/
I managed to gracefully steal the code, and include it into my page,...
But their are just 2 problems remaining.
See http://redhair.nl.nu/news
As you might notice, the menu's are folding great, but here is the catch: The minus image does not get changed to a plus image (..while it is there), and also the cookies dont seem to work (...which will remember the last folding state of a particular menu.).
Here is the javascript:
Code: Select all
function GetCookie(name) {
var arg=name+"=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i,j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == 1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie (name, value, expires) {
var exp = new Date();
var expiro = (exp.getTime() + (24 * 60 * 60 * 1000 * expires));
exp.setTime(expiro);
var expstr = "; expires=" + exp.toGMTString();
document.cookie = name + "=" + escape(value) + expstr + "; path=/;";
// "domain=webmonkey.com;";
}
function DeleteCookie(name){
if (GetCookie(name)) {
document.cookie = name + "=:; expires = Thu, 01-Jan-70 00:00:01 GMT; path=/;";
}
}
var imagepath = "../img/paneel/";
////////////////////////////////////
blockarray = new Array();
var blockarrayint = -1;
function doblocks(imgpath) {
if (imgpath != null) imagepath = imgpath;
for (var q = 0; q < blockarray.length; q++) {
xyzswitch(blockarrayїq]);
}
}
function xswitch(listID) {
if(listID.style.display=="none") {
listID.style.display="";
} else {
listID.style.display="none";
}
}
function icoswitch(bid) {
icoID = document.getElementById('pic'+bid);
if(icoID.src.indexOf("close") != -1) {
icoID.src = imagepath+"open.png";
SetCookie('block'+bid,'yes',365);
} else {
icoID.src = imagepath+"close.png";
DeleteCookie('block'+bid);
}
}
function xyzswitch(bid) {
xswitch(document.getElementById('pe'+bid));
xswitch(document.getElementById('ph'+bid));
icoswitch(bid);
}
function addblock(bid) {
var blockopen=GetCookie('block'+bid);
if (blockopen != null) {
blockarrayint += 1;
blockarrayїblockarrayint] = bid;
}
}
////////////////////////////////////
var hiddenblocks = new Array();
var blocks = GetCookie('hiddenblocks');
if (blocks != null) {
var hidden = blocks.split(":");
for (var loop = 0; loop < hidden.length; loop++) {
var hiddenblock = hiddenїloop];
hiddenblocksїhiddenblock] = hiddenblock;
}
}
function blockswitch(bid) {
var bpe = document.getElementById('pe'+bid);
var bph = document.getElementById('ph'+bid);
var bico = document.getElementById('pic'+bid);
if (bpe.style.display=="none") {
if (bph) { bph.style.display="none"; }
bpe.style.display="";
hiddenblocksїbid] = null;
bico.src = imagepath+"close.png";
} else {
if (bph) { bph.style.display=""; }
bpe.style.display="none";
hiddenblocksїbid] = bid;
bico.src = imagepath+"open.png";
}
var cookie = null;
for (var q = 0; q < hiddenblocks.length; q++) {
if (hiddenblocksїq] != null) {
if (cookie != null) {
cookie = (cookie+":"+hiddenblocksїq]);
} else {
cookie = hiddenblocksїq];
}
}
}
if (cookie != null) {
SetCookie('hiddenblocks', cookie, 365);
} else {
DeleteCookie('hiddenblocks');
}
}I am getting rather dizzy..
And I only had 2 beers....