MyBB Community Forums

Full Version: [MyCode] Spoiler text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Title: Spoiler text
Short Description: Allow user to put text on value of the button.
Regular Expression:
Quote:\[spoiler\=(.*?)](.*?)\[/spoiler\=(.*?)]
Replacement:
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><input type="button" value="$1" style="width:auto;font-size:12px;margin:0px;padding:0px;" 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 = '$3'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '$1'; }" />
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">$2</div>
</div>
</div>

Enabled? : Yes

Example code in post

[spoiler=You can put your txt here to show the spoiler]Something here[/spoiler=You can put your txt here to hide the spoiler]

Result:
[attachment=18392]

- Code are valid the markup validity.
- If you looking for standard spoiler, you can use this code on Replacement box.
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><input type="button" value="Show Spoiler" style="width:100px;font-size:10px;margin:0px;padding:0px;" 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 Spoiler'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show Spoiler'; }" />
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">$1</div>
</div>
</div>

with this regular expression.
Quote:\[spoiler\](.*?)\[/spoiler\]
Example code in post
[spoiler]text here[/spoiler]



Thanks
It doesn't Show "Hide Spoiler" button when I click "Show Spoiler"
Wow nice coding!