Previous Thread
Next Thread
Print Thread
Rate Thread
#313140 02/12/2007 7:33 PM
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
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, ' ' + "
" + thisSpoiler + "
" + ' ' );
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\]#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
(This will be the warning)
This text will be hidden

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 (31.43 KB, 151 downloads)
2362-spoiler-open.jpg (39.63 KB, 151 downloads)
2369-spoiler.gif (73 Bytes, 43 downloads)
2376-spoiler.gif (467 Bytes, 41 downloads)


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Sponsored Links
Entire Thread
Subject Posted By Posted
[7.x] UBB Spoiler Tags Gizmo 02/13/2007 2:33 AM
Re: [7.x] UBB Spoiler Tags gliderdad 02/13/2007 2:42 AM
Re: [7.x] UBB Spoiler Tags Gizmo 02/13/2007 3:52 AM
Re: [7.x] UBB Spoiler Tags Gizmo 02/13/2007 3:55 AM
Re: [7.x] UBB Spoiler Tags Firstone 02/13/2007 5:51 AM
Re: [7.x] UBB Spoiler Tags Gizmo 02/13/2007 5:58 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/02/2007 3:19 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/03/2007 2:15 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/03/2007 10:23 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/03/2007 10:32 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/04/2007 2:45 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/04/2007 11:31 PM
Re: [7.x] UBB Spoiler Tags Cuervo 03/05/2007 3:10 PM
Re: [7.x] UBB Spoiler Tags ADWOFF 03/05/2007 8:35 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 12:01 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/06/2007 12:05 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 12:07 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/06/2007 2:04 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 2:49 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/06/2007 3:08 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/06/2007 3:50 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/06/2007 3:55 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 6:37 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 6:42 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 6:43 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 6:53 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 7:24 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/08/2007 10:12 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 10:03 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 11:13 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/18/2007 2:07 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/18/2007 3:23 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/18/2007 8:57 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/18/2007 11:25 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/18/2007 6:54 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/18/2007 11:17 PM
Re: [7.x] UBB Spoiler Tags jgeoff 03/19/2007 7:08 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 8:27 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 8:33 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 10:10 PM
Re: [7.x] UBB Spoiler Tags jgeoff 03/19/2007 10:39 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 10:46 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 10:57 PM
Re: [7.x] UBB Spoiler Tags jgeoff 03/19/2007 11:02 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/19/2007 11:11 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/19/2007 11:21 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/19/2007 11:23 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/20/2007 12:22 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 12:40 AM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/20/2007 12:47 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 1:53 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/20/2007 2:32 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 2:41 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 3:23 AM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/20/2007 4:30 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 4:37 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/20/2007 8:04 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/20/2007 12:22 PM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/20/2007 3:02 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/21/2007 12:11 AM
Re: [7.x] UBB Spoiler Tags Fred Johnson 03/21/2007 3:42 PM
Re: [7.x] UBB Spoiler Tags Cuervo 03/21/2007 11:20 PM
Re: [7.x] UBB Spoiler Tags Cuervo 03/21/2007 11:26 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/22/2007 12:14 AM
Re: [7.x] UBB Spoiler Tags jgeoff 03/29/2007 9:00 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/30/2007 12:17 AM
Re: [7.x] UBB Spoiler Tags sirdude 06/04/2007 9:55 PM
Re: [7.x] UBB Spoiler Tags Gizmo 06/05/2007 1:20 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/06/2007 5:39 AM
Re: [7.x] UBB Spoiler Tags ADWOFF 03/08/2007 10:18 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 10:23 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 10:28 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 10:48 AM
Re: [7.x] UBB Spoiler Tags Gizmo 03/08/2007 11:02 AM
Re: [7.x] UBB Spoiler Tags Cuervo 03/10/2007 1:03 PM
Re: [7.x] UBB Spoiler Tags Gizmo 03/10/2007 10:12 PM
Re: [7.x] UBB Spoiler Tags Gizmo 07/17/2007 5:00 AM
Re: [7.x] UBB Spoiler Tags sirdude 07/17/2007 3:28 PM
Re: [7.x] UBB Spoiler Tags Gizmo 07/18/2007 2:17 AM
Re: [7.x] UBB Spoiler Tags lysaraj 01/10/2011 9:53 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)