Welcome Guest Search | Active Topics | Log In | Register

[spoiler] bbcode modification Options · View
LazaRuss808
#1 Posted : Tuesday, July 01, 2008 7:38:37 AM
Rank: Member


Joined: 4/20/2007
Posts: 15
Location: Hawaii
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.

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


And then this in the makeHTML function.

Code:
       
// 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.

Code:
[spoiler]stuff you want to hide.[/spoiler]


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! Smile

-R.
continienzo
#2 Posted : Wednesday, July 02, 2008 7:56:07 PM
Rank: Advanced Member


Joined: 1/23/2008
Posts: 68
Location: Italy
Thanks for sharing your code mate. Smile
I modified it for the last 1.9.3 version of yaf.

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



Code:

            // 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));
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.3 RC1 | YAF © 2003-2008, Yet Another Forum.NET
This page was generated in 0.068 seconds.

SourceForge.net Logo Powered by ASP.NET v2.0 411ASP.NET