php forum
php mysql forum
php mysql smarty
 
Page 1 of 4 1 2 3 4 >
Topic Options
#313140 - 02/12/07 06:33 PM [7.x] UBB Spoiler Tags
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
NOTE: Spoiler Tags are included in UBB.Threads 7.2.

Author: Gizmo (James of VNC Web Design)

Requirements:
  • Valid UBB.Threads 7.0 install and license


About:
This UBBCode will allow you to hide text in posts from users unless they choose to view it; thus allowing users to post movie, news, etc, spoilers and not have to ruin everyones fun!

Demo:
Please see the attached images:
2361-spoiler-closed.jpg - What people see before the spoiler is revealed.
2362-spoiler-open.jpg - What people see after the spoiler is revealed.

You can also see it in action here.

Install Instructions:
Open libs/ubbthreads.inc.php
Find:
Code:
			array( "#\[email=([+_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))\](.+?)\[/email]#i", '<a href="mailto:\1">\5</a>' ),


Add Under:
Code:
			array( "#\[spoiler\](.+?)\[/spoiler\]#i", "<div class=\"ubbcode-block\"><div class=\"ubbcode-header\">Warning, Spoiler: <input type=\"button\" class=\"form-button\" value=\"Show\" 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'; }\" /></div><div class=\"ubbcode-body\"><div style=\"display: none;\">\\1</div></div></div>" ),


IF you want to add this to the markup panel on the "Full Reply"/"Topic Creation" pages:
Code:
Step 1:
Open templates/default/standardtext_editor.tpl
Find:
<a href="javascript: x()" onclick="DoPrompt('image');" title="{$lang.IMAGE_ALT}" alt="{$lang.IMAGE_ALT}"><img id="image" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/image.gif" /></a>

Add Under:
<a href="javascript: x()" onclick="DoPrompt('spoiler');" title="Spoiler" alt="Spoiler"><img id="spoiler" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/spoiler.gif" /></a>

Step 2:
Open ubb_js/standard_text_editor.js
Find:
	if (action == "image") {
		var thisImage = prompt(enterImage, "http://");
		if (thisImage == null){return;}

		insertAtCaret(document.replier.Body, ' ' + "[img]" + thisImage + "[/img]" + ' ' );
		document.replier.texteditor.focus();
		return;
	}

Add Under:
	if (action == "spoiler") {
		var thisSpoiler = prompt("Enter Spoiler", "");
		if (thisSpoiler == null){return;}

		insertAtCaret(document.replier.Body, ' ' + "[spoiler]" + thisSpoiler + "[/spoiler]" + ' ' );
		document.replier.texteditor.focus();
		return;
	}

Step 3:
You'll need to insert a spoiler.gif into your markup panel directory, I am appending one supplied by Cuervo.


To filter spoilers out of the ActiveTopics system, simply:
Open scripts/activetopics.inc.php
Find:
Code:
		$topics[$i]['forum_id'] = $forum_id;


Add Above:
Code:
		$post_body = preg_replace('/\[spoiler\](.*?)\[\/spoiler\]/si', '', $post_body);
		$post_body = preg_replace('/<div class="ubbcode-block"><div class="ubbcode-header">(.*?)<\/div><div class="ubbcode-body"><div style="display: none;">(.*?)<\/div><\/div><\/div>/si', '', $post_body);


To allow users to specify their own warning:
In libs/ubbthreads.inc.php, add after the [spoiler] tag set:
Code:
			array( "#\[spoiler=(.+?)\](.+?)\[/spoiler\]#i", "<div class=\"ubbcode-block\"><div class=\"ubbcode-header\">\\1 <input type=\"button\" class=\"form-button\" value=\"{$ubbt_lang['SPOILER_SHOW']}\" 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 = '{$ubbt_lang['SPOILER_HIDE']}'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '{$ubbt_lang['SPOILER_SHOW']}'; }\" /></div><div class=\"ubbcode-body\"><div style=\"display: none;\">\\2</div></div></div>" ),


Usage Instructions:
Code:
[spoiler]This text will be hidden[/spoiler]
[spoiler=This will be the warning]This text will be hidden[/spoiler]


NOTE:
Every time a user visits the page, the spoiler text will be hidden again. Also, multi-level spoilers are not a possibility yet; I'll make that the next project wink. Additionally, the classes used are the standard ubb-code ones.


Attachments
2361-spoiler-closed.jpg (148 downloads)
2362-spoiler-open.jpg (148 downloads)
2369-spoiler.gif

2376-spoiler.gif


_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313142 - 02/12/07 06:42 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
gliderdad79 Offline
User

Registered: 03/24/06
Posts: 31
Cool Thanks Giz :wave:

Top
#313147 - 02/12/07 07:52 PM Re: [7.x] UBB Spoiler Tags [Re: gliderdad79]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
If you've already applied this, please update the spoiler ubbcode; there was a bug which would not allow you to quote users when they had a spoiler lol...

And yes, it was some lingering test code wink...


Edited by Gizmo (02/12/07 08:08 PM)
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313148 - 02/12/07 07:55 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
by the way, this also fixed multi-level spoilers lol...

By multi level I mean:
Code:
[spoiler][spoiler][spoiler][spoiler]we hide![/spoiler][/spoiler][/spoiler][/spoiler]
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313152 - 02/12/07 09:51 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Firstone Offline
Junior Member

Registered: 05/08/01
Posts: 11
Just awesome! Thanks a lot Gizmo smile

(I hope Rick find it usefull too ... laugh )

Top
#313155 - 02/12/07 09:58 PM Re: [7.x] UBB Spoiler Tags [Re: Firstone]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
Not a problem... I'm hoping we can get it sneeked into a release as official-ness :crosses fingers:
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313316 - 03/02/07 07:19 AM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
Any chance of making this a markup panel button with a pop up?
_________________________
-Cuervo
zOMG and oNOES

Top
#313331 - 03/02/07 06:15 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
I'll look it up later; in all honesty i had no plans of it being in the markup panel so i never bothered; though if it's wanted i'll poke hehe
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313337 - 03/03/07 02:23 AM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
Most of my users are very bright when it comes to hand typing uBBcode and it is a nice mod!
_________________________
-Cuervo
zOMG and oNOES

Top
#313338 - 03/03/07 02:32 AM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
Completely untested, and taken from the youtube bbcode addon:
Code:
[STEP 1:]
/templates/default/standard_text_editor.tpl

>>FIND
<a href="javascript: x()" onclick="DoPrompt('image');" title="{$lang.IMAGE_ALT}" alt="{$lang.IMAGE_ALT}"><img id="image" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/image.gif" /></a>

>>ADD BELOW
<a href="javascript: x()" onclick="DoPrompt('spoiler');" title="spoiler" alt="spoiler"><img id="spoiler" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/spoiler.gif" /></a>



[STEP 2:]
/ubb_js/standard_text_editor.js

>>FIND
if (action == "image") {
		var thisImage = prompt(enterImage, "http://");
		if (thisImage == null){return;}

		insertAtCaret(document.replier.Body, ' ' + "[img]" + thisImage + "[/img]" + ' ' );
		document.replier.texteditor.focus();
		return;
	}

>>ADD BELOW
if (action == "spoiler") {
		var thisSpoiler = prompt("Enter Spoiler Data", "Spoiler Text");
		if (thisVideo == null){return;}

		insertAtCaret(document.replier.Body, ' ' + "[spoiler]" + thisSpoiler + "[/spoiler]" + ' ' );
		document.replier.texteditor.focus();
		return;
	}

[STEP 3:]
Upload gif to markup panel directory
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313362 - 03/04/07 06:45 AM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
Gizmo,

Should I remove the other spoiler mod stuff before adding this in?

And I guess a Monkey Speak No Evil would make a good spoiler gif.
_________________________
-Cuervo
zOMG and oNOES

Top
#313368 - 03/04/07 03:31 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
The "other spoiler stuff" is the code tags in the lib files; those are completely seperate; the stuff i posted above for the editor is just the javascript that creates the editor entries. Youll slso need to put some sort of spoiler image, wasn't sure what to include...
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313376 - 03/05/07 07:10 AM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
So, are you saying that both of your spoiler mods must be in the code to get the markup part of it to work? Or, you can use either one by itself?
_________________________
-Cuervo
zOMG and oNOES

Top
#313378 - 03/05/07 12:35 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
ADWOFF Offline
Content Queen

Registered: 05/07/01
Posts: 709
Loc: Pennsylvania
Giz, my man, this is way cool! smile

I especially love how you can put a spoiler within a spoiler within a spoiler ...

The only real problem I'm seeing is with Active Topics & the preview. The "spoiler" is revealed ...

~Sue
adwoff.com

Top
#313382 - 03/05/07 04:01 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
Originally Posted By: Cuervo
So, are you saying that both of your spoiler mods must be in the code to get the markup part of it to work? Or, you can use either one by itself?
I'm saying, they're both seperate...

The first, lib file addition, HAS TO BE applied for ANYTHING to work; the second, the markup panel crap, can be added IF YOU WANT it...

Sue: sub spoilers rule lol...

As for search engine, Not sure how to suppress it there... I do however believe that if spoilers are critical to your community, they should be posted wiht a description above them, as to filter them out of any search results.
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313384 - 03/05/07 04:05 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
Originally Posted By: Gizmo
Originally Posted By: Cuervo
So, are you saying that both of your spoiler mods must be in the code to get the markup part of it to work? Or, you can use either one by itself?
I'm saying, they're both seperate...

The first, lib file addition, HAS TO BE applied for ANYTHING to work; the second, the markup panel crap, can be added IF YOU WANT it...



Thanks, I understand now.
_________________________
-Cuervo
zOMG and oNOES

Top
#313386 - 03/05/07 04:07 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
A lot of people don't care if it's in the markup panel or not, myself included; I only supplied that as a request, and quite frankly, I have no idea if it even works as I never tested it.

The other, the spoiler tags in the lib, has been heavily tested.
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313388 - 03/05/07 06:04 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
I did find something while I was trying to install this. I think the part of find:

Code:
<a href="javascript: x()" onclick="DoPrompt('image');" title="{$lang.IMAGE_ALT}" alt="{$lang.IMAGE_ALT}"><img id="image" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/image.gif" /></a>


should read

Code:
<a href="javascript: void(0)" onclick="DoPrompt('image');" title="{$lang.IMAGE_ALT}" alt="{$lang.IMAGE_ALT}"><img id="image" onmouseover="raiseButton(this.id);" onmouseout="normalButton(this.id);" onmousedown="lowerButton(this.id);" class="markup_panel_normal_button" src="{$config.BASE_URL}/images/{$style_array.markup_panel}/image.gif" /></a>


The "javascript: x() is javascript void(0)

I'm not sure on this, but it's what I found in my file.

Something of importance; when you click the markup button it brings up the add spoiler box and lets you add the text, but when you click the ok button it doesn't add the text to the post.

Any ideas on that one, Gizmo?


Edited by Cuervo (03/05/07 07:06 PM)
_________________________
-Cuervo
zOMG and oNOES

Top
#313391 - 03/05/07 06:49 PM Re: [7.x] UBB Spoiler Tags [Re: Cuervo]
Gizmo Offline

Wizard

Registered: 01/10/00
Posts: 5352
Loc: Portland, OR, USA
Yeh, I think some of the javascripts got updated in 7.1; the code I took the "add" line from was for 7.0.2, so it'd make sense wink... good find.

Does the markup option work? (I ask as I haven't applied it as I don't even like using the advanced editor, I mainly only use the quick reply).
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design & Development President
UBB.Threads: My UBBSkins, UBB.Sitemaps

Top
#313395 - 03/05/07 07:08 PM Re: [7.x] UBB Spoiler Tags [Re: Gizmo]
Cuervo Offline
User

Registered: 11/10/01
Posts: 29
I was testing it out just now.

It seems that once you add the text to the popup and click ok it doesn't add the text back to the post.

I'm not sure what needs to change to get the text back in there.


Edited by Cuervo (03/05/07 07:27 PM)
Edit Reason: trying to clear up my post lol
_________________________
-Cuervo
zOMG and oNOES

Top
Page 1 of 4 1 2 3 4 >



Moderator:  sirdude 
Latest Posts
Shout Box

(Views)Popular Topics
Known public proxy servers 1636135
Integrated Index Page (IIP) 5.3.1 528187
Finished-[6.5.2] Games Arcade Deluxe v1.9 486016
Integrated Index Page (IIP) 5.1.1 401388
TLD Bv2.1 Released - Threads Links Directory 382774
[6.0x] Who's Online 4.0.0 [Finished] 374847
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 318709
Q & A 264276
[6.3.x] [beta] Hit Hack 2.0 225221
[7.x] Gizmo's Embedding BBCode (Pre UBB.T7.3) 202973
Forum Stats
13620 Members
59 Forums
37189 Topics
295701 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks