[Suggestion] Somewhat better spoiler code.

X Prime 11-13-2004 11:54 PM
Well, one thing that always annoyed me with most of the 'contemporary' spoiler code was that if you either used a smilie or color formatting inside it, it would not be hidden. I edited the javascript spoiler code file here for an effect that fixes this... Essentially, it hides and unhides everything inside spoiler boxes when you click inside said box. There are a few catches however...

1) You'd need to reference this JS file on any page that has spoiler code... That means adding a line to... Four templates?

2) Clicking a spoiler box reveals all spoilers in the thread because I have absolutely no inkling on how to make it box specific.

3) You'd need to overwrite your current spoiler BBCode.

4) That Show All Spoilers / Hide all Spoilers thing wouldn't work anymore because I'm practically javascript illiterate.

Would you like to try it Krang?

Here's the contents of the modded JS file...

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function showhidespoilers() {
	TCells = document.getElementsByTagName("font")
	
		for (var i=0; i<TCells.length; i++) {
			if (TCells[i].style.visibility=='hidden') {
				TCells[i].style.visibility='visible'
			}
                        else {
				TCells[i].style.visibility='hidden'
			}
		}
}


And the modded BBcode...

code:
1:
2:
3:
4:
5:
6:
7:
8:
<table align="center" width="98%" cellpadding="{$style['tableincellpadding']}" cellspacing="{$style['tableincellspacing']}" class="tableinborder" onclick="showhidespoilers();">
<tr>
<td align="left" class="tablecat"><span class="smallfont"><b>{$lang->items['LANG_GLOBAL_SPOILER']}</b></span></td>
</tr>
<tr class="normalfont">
<td class="inposttable" align="left"><font style="visibility: hidden;">{param1}</font></td>
</tr>
</table>
Krang 11-16-2004 01:32 AM
Sorry, I forgot to respond to this earlier. While this is a good idea and would end up solving some of the problems with the current spoiler code, it does cause problems for people who don't have JavaScript enabled and for people who don't necessarily want to read all the spoilers in the thread at once. If those two problems could be solved, though, then this would definitely work as a replacement for the current code.
Zola 11-16-2004 01:55 AM
javaEnabled() is a boolean to check for that:

if javaEnabled() false
{
plain old BB spoiler code
}

else

{
shiny new code
}
X Prime 11-18-2004 07:06 PM
Wouldn't work without semiserious editing, the old code doesn't rely on JS at all.

The only JS bit is that cute little Show/Hide all spoilers thing.

...You'd have to wonder who'd use PCF without javascript enabled. They wouldn't be able to attach anything for example. Oh well.
Krang 11-18-2004 10:45 PM
quote:
Originally posted by X Prime
...You'd have to wonder who'd use PCF without javascript enabled. They wouldn't be able to attach anything for example. Oh well.

I wasn't really talking about people who disabled JavaScript by choice, I meant people who browse the forums from schools and workplaces that have strict firewalls that block things like JavaScript.
Mr. Fortnight 11-19-2004 04:13 AM
Or people like me that most of the time view this forum using a text-based browser.

It might make the spoiler completely dissapear if it was JS, and be unretrievable without me doing some VERY DIFFICULT looking.
X Prime 11-19-2004 04:23 AM
Hmm.. Actually, if you use a text based browser, it might not recognize the CSS property that's hiding it I would imagine. But then, that's only a guess.

*Idly wonders what the point of using a text based browser is on a more or less graphically driven forum, shrugs*