Jump to content

strugglin with my script


dorksville

Recommended Posts

 

Edit: Oops I didnt realise I was in html I thought I was in javascript section moderators please move

 

Hi, this is my first post so I hope ive shown it correctly.

 

I cant find why this is not working correctly in both IE and FF

 

This is what ive got so far......

 

CSS

.left {
    width : 150px;
}

.middle {
}

.right {
}

.right_close {
    background: url(templates/fusion_expanded/images/cat_top_rs_plus.gif) no-repeat;
    width : 150px;
    height : 27px;
}

 

JAVA

/* if you have ajax/core.js included - comment next function */
function addEvent(obj, type, fn) {
if (obj.addEventListener) {
	obj.addEventListener(type, fn, false);
} else if (obj.attachEvent) {
	obj["e"+type+fn] = fn;
	obj[type+fn] = function() {obj["e"+type+fn](window.event); }
	obj.attachEvent("on"+type, obj[type+fn]);
}
}
/* comment to here */

function AppendPlusMinus()
{
var tds = document.getElementsByTagName('td');
for (x in tds)
{
	if (tds[x].className == 'right' || tds[x].className == 'right')
	{
		a = document.createElement('a');
		a.href = '#';
		a.innerHTML = tds[x].innerHTML;
		tds[x].innerHTML = '';;
		tds[x].appendChild(a);
		el = tds[x];
		addEvent(a, 'click', ShowHide);
		name = tds[x].previousSibling;
		while (name.nodeType == 3)
			name = name.previousSibling;
		name = name.innerHTML.replace(/(<([^>]+)>)/ig,"");
		if (CheckCookie(name))
		{
			el.className = el.className + '_close';
			while (el.nodeName != 'TABLE')
				el = el.parentNode;
			el = el.nextSibling;
			while (el.nodeName != 'TABLE')
				el=el.nextSibling;
			el.style.display='none';
		}

	}
}
}

function CheckCookie(name)
{
if (!name) return false;
name = name.replace(/\(\d+\)/, '');
name = escape(name);
cookies = document.cookie.split(/;/);
for (x in cookies)
{
	cookie = cookies[x].split(/=/);
	if (cookie[0].replace(/ /, '') == 'blocks')
	{
		/* edit this one */
		return eval('cookie[1].match(/(^|,)' + name + '(,|$)/);') != null;
	}
}
}

function ShowHide(e)
{
var el;
if (window.event && window.event.srcElement) { el = window.event.srcElement; }
if (e && e.target) { el = e.target; }
if (!el) { return; }
(e.preventDefault) ? e.preventDefault() : (e.returnValue = false);

while (el.nodeName != 'TD') el=el.parentNode; // go to TD
name = el.previousSibling;
while (name.nodeType == 3)
	name = name.previousSibling;

var foldmode = -1;

if (el.className == 'right' || el.className == 'right')
{
	el.className = el.className + '_close';
	el = el.parentNode.parentNode.parentNode.nextSibling;
	while (el.nodeName != 'TABLE')
		el=el.nextSibling;
	el.style.display='none';
	foldmode = 1;
}
else
{
	if (el.className == 'right_close')
		el.className = 'right';
	else
		el.className = 'right_close';
	el = el.parentNode.parentNode.parentNode.nextSibling;
	while (el.nodeName != 'TABLE')
		el=el.nextSibling;
	el.style.display='';
	foldmode = 2;
}

if (foldmode == -1 || !name)
	return;

name = name.innerHTML.replace(/(<([^>]+)>)/ig,"");
name = name.replace(/\(\d+\)/, '');

cookies = document.cookie.split(/;/);
var found = 0;
for (x in cookies)
{
	cookie = cookies[x].split(/=/);
	if (cookie[0].replace(/ /, '') == 'blocks')
	{
		/* edit this one */
		found = 1;

		if (foldmode != 1)
		{
			/* remove */
			cookie[1] = cookie[1].replace(escape(name), '').replace(/(,,)/, ',').replace(/(,$)|(^,)/g, '');
		}
		else
		{
			if (cookie[1].indexOf(escape(name)) != -1)
				return;
			/* add */
			if (cookie[1])
				cookie[1] += ',' + escape(name);
			else
				cookie[1] = escape(name);

			cookie[1] = cookie[1].replace(/(,,)/, ',').replace(/(,$)|(^,)/g, '');
		}
		var exdate=new Date()
		exdate.setDate(exdate.getDate()+31)
		document.cookie = 'blocks=' + cookie[1] + ';expires=' + exdate.toGMTString() + ';';
		break;
	}
}
if (!found)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+31)
	document.cookie = 'blocks=' + escape(name) + ';expires=' + exdate.toGMTString() + ';';
}

}

addEvent(window, 'load', AppendPlusMinus);

 

HTML

     <!-- top table setup -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" background="templates/fusion_expanded/images/cat_back.gif">
  <tr>
    <td class="left" height="27" align="left" valign="bottom">
        <img border="0" src="templates/fusion_expanded/images/cat_top_ls.gif" width="150" height="27">
    </td>
    <td class="middle" width="100%" align="center">
      <span class="cattitle">- |Forum Stats| -</span>
    </td>
    <td class="right" align="right" valign="top">
      <img border="0" src="templates/fusion_expanded/images/cat_top_rs.gif" width="150" height="27">
    </td>
  </tr>
</table>
        <!-- End top table setup -->

 

I really need help with this ive done what I can to get it to work :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.