MyBB Community Forums

Full Version: [MyCode] Spoiler with names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is a minor edit to ghoku's Spoiler using CSS mod. This mod allows to assign a name to a spoiler. This thing works best in collaboration with his mod.

Regular Expression:
\[spoiler=(.*?)\](.*?)\[/spoiler\]

Replacement:
<div align="left"><div style="margin: 5px 20px 20px; width: 60%;"><div style="text-align: left; padding: 4px; background: #85B1EE; repeat-x scroll 0% 0% transparent; border: 1px solid #6F9DD9; -moz-border-radius:5px; color:#ffffff; text-shadow:0 -1px #6F9DD9; font-weight:bold; ">$1&nbsp;<input type="button" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';        this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }" style="width: 45px; font-size: 10px; margin: 0px; padding: 0px;" value="Show"></div><div class="quotecontent"><div style="border-left: 1px solid #000000; border-width: 0px 1px 1px; border-style: none solid solid; border-color: #6F9DD9; padding: 4px; -moz-border-radius:5px; display: none;">$2</div></div></div></div>

Preview:
[Image: 0iCsu.png]

You can change the style of the spoiler to anything you like, no bounds.
You should place a question-mark after the equals sign to make it also work without the need for a title:

\[spoiler=?(.*?)\](.*?)\[/spoiler\]
I could have done that, but then I am unaware of what variable to put in place of the "?".
(2012-12-12, 10:18 AM)ElectricShock Wrote: [ -> ]I could have done that, but then I am unaware of what variable to put in place of the "?".

What? '?' sets the previous character (or character group) as optional, meaning they can use [spoiler] and [spoiler=...] and it would still show the same result, but at the moment they'd need to type [spoiler=] in order to have a spoiler without a title.

http://www.regular-expressions.info/optional.html
Would adding a "?" before the "=" do it?
I'm not sure, I'll have to go back and reread my first post in this thread where I gave you the answer.
(2012-12-12, 10:33 AM)ElectricShock Wrote: [ -> ]Would adding a "?" before the "=" do it?

To my kowledge you cannot create a spoiler that accepts both non-titled [spoiler] and titled [spoiler=title] spoilers by using a single MyCode.

You can either separate the two separate spoilers into individual MyCodes or use a plugin.
(2012-12-12, 12:51 PM)Wildcard Wrote: [ -> ]To my kowledge you cannot create a spoiler that accepts both non-titled [spoiler] and titled [spoiler=title] spoilers by using a single MyCode.

You can either separate the two separate spoilers into individual MyCodes or use a plugin.

(2012-12-12, 10:00 AM)Beardy Wrote: [ -> ]You should place a question-mark after the equals sign to make it also work without the need for a title:

\[spoiler=?(.*?)\](.*?)\[/spoiler\]

Without a title:
http://imgit.me/i/0F2S7y5.png

With a title:
http://imgit.me/i/9P4J2I7.png

MyCode:
http://imgit.me/i/7r8V5W4.png

Can anybody actually see my first post in this thread or is it simply invisible?
I can see your first post. Your suggestion makes a lot of sense.
(2012-12-12, 12:51 PM)Wildcard Wrote: [ -> ]To my kowledge you cannot create a spoiler that accepts both non-titled [spoiler] and titled [spoiler=title] spoilers by using a single MyCode.

You can either separate the two separate spoilers into individual MyCodes or use a plugin.

Actually it works fine, replaced my exisiting Spoiler code I used with this one and really like it. Wink Changed a format settings but it works fine.

Cheers

Wolfseye
Pages: 1 2