Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2013, 06:13 PM   PM User | #1
Aya85
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Aya85 is an unknown quantity at this point
Spoiler button function, help!

Hi everybody,

so I tried to add a spoiler button code to my invisionboard. All things goes well, but when I want to make a reply and click on the spoiler button, it won't popup. So all my visitors have to write out the "spoiler" tag manually. I want it to popup.
Can anyone check this script out and help me?

Code:
<script type='text/javascript'>
var show_spoil = function (ele, e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}

var j = ele.nextSibling;
if (j.style.display === 'none') {
j.style.display = 'block';
} else {
j.style.display = 'none';
}
};

(function () {
var b = document.getElementsByTagName('div'), c = b.length;
while (c--) {
if (b[c].className.indexOf('postcolor') !== -1 && b[c].innerHTML.indexOf('[spoiler') !== -1) {
b[c].innerHTML = b[c].innerHTML.replace(/\[spoiler(?:=(.+?))?\](.+?)\[\/spoiler\]/gim, function (total, title, inside) {
return "<input type='button' value='" + (title || "Spoiler") + "' class='forminput spoil_button' onclick='show_spoil(this, event)' /><span style='display:none'><hr />" +
inside + "</span>";
});
}
}
})();
</script>

<script type='text/javascript'>
var insert_spoiler = function () {
document.forms['REPLIER'].Post.value += "";
};

(function () {
if (location.href.indexOf('act=Post') !== -1) {
var b = document.getElementsByTagName('input'), c = b.length;
while (c--) {
if (b[c].className === 'codebuttons' && b[c].name === 'LIST') {
/* Why must the DOM be so clunky? */
var i = document.createElement('input');
i.onclick = 'insert_spoiler';
i.value = 'Spoiler'
i.className = 'codebuttons';
i.type = 'button';
i.style.marginLeft = '4px';
b[c].parentNode.insertBefore(i, b[c].nextSibling);
break;
}
}
}
})();
</script>
Aya85 is offline   Reply With Quote
Reply

Bookmarks

Tags
button, spoiler

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:03 AM.


Advertisement
Log in to turn off these ads.