YAFLogo

LazaRuss808
  • LazaRuss808
  • 59% (Neutral)
  • YAF Forumling Topic Starter
13 years ago
I'm not sure if this has already been posted, but I did a quick search and didn't find it here so figured I would post it. I usually post on card trading sites and the ones that have this feature sure do save a lot of scrolling it seems. That and you can post some fun "suspense filled" maildays.

I inserted the following code into the bbcode.cs file after the declarations already there.

static private Regex r_spoiler = new Regex(@"\[spoiler\](?<inner>(.*?))\[/spoiler\]", m_options);

And then this in the makeHTML function.

        
// spoiler
NestedEmbedReplace(ref bbcode, r_spoiler, "<div style=\"margin:0px; margin-top:0px\"><div class=\"quotetitle\"><input type=\"button\" value=\"Spoiler\" style=\"width:55px;font-size:12px;margin:0px;padding:4px;background-color:#C0C0C0;\" 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 = 'Spoiler'; }\" /></div><div class=\"quotecontent\"><div style=\"display: none;\">${inner}</div></div></div>");

The usage is pretty standard.

stuff you want to hide.

Anyways, hopefully this will be useful to someone else. At the very least it will help me not have to look for the code again when I inevitably lose track of my mods! :)

-R.


Sponsor
continienzo
13 years ago
Thanks for sharing your code mate. 🙂

I modified it for the last 1.9.3 version of yaf.

static private readonly string r_spoiler = @"\[spoiler\](?<inner>(.*?))\[/spoiler\]";


            // spoiler
            ruleEngine.AddRule(new CodeRegexReplaceRule(r_spoiler, "<div style=\"margin:0px; margin-top:0px\"><div class=\"quotetitle\"><input type=\"button\" value=\"Spoiler\" style=\"width:55px;font-size:12px;margin:0px;padding:4px;background-color:#C0C0C0;\" 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 = 'Spoiler'; }\" /></div><div class=\"quotecontent\"><div style=\"display: none;\">${inner}</div></div></div>", _options));