MyBB Community Forums

Full Version: My Custom MyCodes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
My site is pretty much bloated with useless MyCodes... *sigh*
Oh well, I've decided to post them here, if anyone finds them useful Toungue Most are quite useless and very simple, but meh.
(Note, I'm sorda lazy, so I've just put the Regular expression followed by the replacement for each tag)

Background Color of Text
\[bg=([a-zA-Z]*|\#?[0-9a-fA-F]{6})\](.*?)\[/bg\]
<SPAN STYLE="background-color: $1">$2</SPAN>

Background Picture of Text
\[bgimg=([^"'[]+?)\](.*?)\[/bgimg\]
<SPAN STYLE="background-image: url('$1')">$2</SPAN>

Embedded Webpage
(note that I have three versions of this - you could probably make a "neater" version by editing the parser; also note that I suggest you change the image it points to)
\[page\]([^"[]+?)\[/page\]
<small><i><a href="$1" title="Link to the original flash object">Object Link</a></i></small>
<div style="padding: 0 0 0 0; width: 480px; height: 360px;">
<a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('div')[0].innerHTML='<iframe width=\'480\' height=\'360\' src=\'$1\'>[Embedded Webpage]</iframe>';" onMouseOver="this.getElementsByTagName('div')[0].style.background='#C0C0C0';" onMouseOut="this.getElementsByTagName('div')[0].style.background='#E0E0E0';"><div style="text-align: center; vertical-align: middle; font-size: 1.3em; background: #E0E0E0; border-width: 1px; border-color: #A0A0A0; border-style: solid; width: 480px; height: 360px; overflow: hidden"><img src="http://zingaburga.freehostia.com/img/webpage.gif" style="margin-top: 20px"><br>Click here to view embedded webpage
<br /><font size="-2">Please note that by activating this feature, there may be undesirable consequences</font></div></a></div>
...with dimensions
\[page=([0-9]{1,3})x([0-9]{1,3})\]([^"[]+?)\[/page\]
<small><i><a href="$3" title="Link to the original flash object">Object Link</a></i></small>
<div style="padding: 0 0 0 0; width: $1px; height: $2px;">
<a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('div')[0].innerHTML='<iframe width=\'$1\' height=\'$2\' src=\'$3\'>[Embedded Webpage]</iframe>';" onMouseOver="this.getElementsByTagName('div')[0].style.background='#C0C0C0';" onMouseOut="this.getElementsByTagName('div')[0].style.background='#E0E0E0';"><div style="text-align: center; vertical-align: middle; font-size: 1.3em; background: #E0E0E0; border-width: 1px; border-color: #A0A0A0; border-style: solid; width: $1px; height: $2px; overflow: hidden"><img src="http://zingaburga.freehostia.com/img/webpage.gif" style="margin-top: 20px"><br>Click here to view embedded webpage
<br /><font size="-2">Please note that by activating this feature, there may be undesirable consequences</font></div></a></div>
...with just a height dimension (will make width = 100%)
\[page=(x|)([0-9]{1,3})\]([^"[]+?)\[/page\]
<small><i><a href="$3" title="Link to the original flash object">Object Link</a></i></small>
<div style="padding: 0 0 0 0; width: 100%; height: $2px;">
<a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('div')[0].innerHTML='<iframe width=\'100%\' height=\'$2\' src=\'$3\'>[Embedded Webpage]</iframe>';" onMouseOver="this.getElementsByTagName('div')[0].style.background='#C0C0C0';" onMouseOut="this.getElementsByTagName('div')[0].style.background='#E0E0E0';"><div style="text-align: center; vertical-align: middle; font-size: 1.3em; background: #E0E0E0; border-width: 1px; border-color: #A0A0A0; border-style: solid; width: 100%; height: $2px; overflow: hidden"><img src="http://zingaburga.freehostia.com/img/webpage.gif" style="margin-top: 20px"><br>Click here to view embedded webpage
<br /><font size="-2">Please note that by activating this feature, there may be undesirable consequences</font></div></a></div>

Fieldset
\[fieldset\](.*?)\[/fieldset\]
<FIELDSET>$1</FIELDSET>
...with colour
\[fieldset=([a-zA-Z]*|\#?[0-9a-fA-F]{6})\](.*?)\[/fieldset\]
<FIELDSET STYLE="background-color: $1">$2</FIELDSET>
...legend
\[legend\](.*?)\[/legend\]
<LEGEND>$1</LEGEND>
(I preferred to use this instead of a fieldset= type tag to allow MyCode to be entered into the legend)

Flash Object
(note that this is loaded through DHTML to prevent possible exploitation via Flash; also, please change the URL of the icon)
\[flash\]([^"[]+?)\[/flash\]
<small><i><a href="$1" title="Link to the original flash object">Object Link</a></i></small>
<div style="padding: 0 0 0 0; width: 320px; height: 240px;">
<a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('div')[0].innerHTML='<object width=\'320\' height=\'240\'><param name=\'movie\' value=\'$1\'><embed src=\'$1\' width=\'320\' height=\'240\' type=\'application/x-shockwave-flash\' quality=\'best\'></embed></object>';" onMouseOver="this.getElementsByTagName('div')[0].style.background='#C0C0C0';" onMouseOut="this.getElementsByTagName('div')[0].style.background='#E0E0E0';"><div style="text-align: center; valign: middle; font-size: 1.3em; background: #E0E0E0; border-width: 1px; border-color: #A0A0A0; border-style: solid; width: 320px; height: 240px; overflow: hidden"><img src="http://zingaburga.freehostia.com/img/flash.gif" style="margin-top: 20px"><br>Click here to view flash object</div></a></div>
...with dimensions
\[flash=([0-9]{1,3})x([0-9]{1,3})\]([^"[]+?)\[/flash\]
<small><i><a href="$3" title="Link to the original flash object">Object Link</a></i></small>
<div style="padding: 0 0 0 0; width: $1px; height: $2px;">
<a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('div')[0].innerHTML='<object width=\'$1\' height=\'$2\'><param name=\'movie\' value=\'$3\'><embed src=\'$3\' width=\'$1\' height=\'$2\' type=\'application/x-shockwave-flash\' quality=\'best\'></embed></object>';" onMouseOver="this.getElementsByTagName('div')[0].style.background='#C0C0C0';" onMouseOut="this.getElementsByTagName('div')[0].style.background='#E0E0E0';"><div style="text-align: center; valign: middle; font-size: 1.3em; background: #E0E0E0; border-width: 1px; border-color: #A0A0A0; border-style: solid; width: $1px; height: $2px; overflow: hidden"><img src="http://zingaburga.freehostia.com/img/flash.gif" style="margin-top: 20px"><br>Click here to view flash object</div></a></div>

Google Video
\[gvid\]http\://video\.google\.com/videoplay\?docid=([^"[]+?)\[/gvid\]
<SMALL STYLE="margin-top: -100"><I><A HREF="http://video.google.com/videoplay?docid=$1">Source: Google Video</A></I></SMALL>
<embed style=\"width:400px; height:326px;\" id=\"VideoPlayback\" align=\"middle\" type=\"application/x-shockwave-flash\" src=\"$1&hl=en\" quality=\"best\"  FlashVars=\"playerMode=embedded\"> </embed>

Indent
\[indent\](.*?)\[/indent\]
<DIV STYLE="margin-left: 15px">$1</DIV>

Link in new window
\[popup=([^"'\\[]+?)\](.*?)\[/popup\]
<A HREF="javascript:window.open('$1',0,'toolbars=0,location=0,status=0,resizable=1,scrollbars=1');void(0);">$2</A>

List (images as items)
\[list=http://([^"'[]+?)\](.*?)\[/list\]
<UL STYLE="list-style-image: url('http://$1')">$2</UL>
...you'll also need to add this
\[\*\]
<LI>

Overline
\[o\](.*?)\[/o\]
<SPAN STYLE="text-decoration: overline">$1</SPAN>

Small caps
\[sc\](.*?)\[/sc\]
<SPAN STYLE="font-variant: small-caps">$1</SPAN>

Sound (embedded link)
\[sound=([^"'\\[]+?)\](.*?)\[/sound\]
<span><a href="javascript:void(0);" onClick="this.parentNode.getElementsByTagName('span')[0].innerHTML='<embed src=\'$1\' hidden=true autostart=true loop=false style=\'visibility: hidden; visible: hide; width:1;height:1;position:absolute\'>';" TITLE="Click to play sound"><img src="images/smilies/sound.gif" style="padding-top: 2px; vertical-align: top" border=0 /> $2</A><span STYLE="visibility: hidden; visible: hide;height:1;width:1;overflow:hidden"></span></span>

Spoiler
\[spoiler\](.*?)\[/spoiler\]
<div><div style="margin-bottom:2px; font-size: 12px"><b>Spoiler</b>: <input type="button" value="Show" style="width:45px;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'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }">
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
$1
</div>
</div></div>
...with description
\[spoiler=(.*?)\](.*?)\[/spoiler\]
<div><div style="margin-bottom:2px; font-size: 12px"><b>Spoiler</b> for <i>$1</i>: <input type="button" value="Show" style="width:45px;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'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }">
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
$2
</div>
</div></div>

Subscript
\[sub\](.*?)\[/sub\]
<SUB>$1</SUB>

Superscript
\[sup\](.*?)\[/sup\]
<SUP>$1</SUP>

Tables
\[table\](.*?)\[/table\]
<TABLE STYLE="border-style: ridge; border-width: 1px; padding: 5 5 5 5; margin: 5 0 5 5" ALIGN="center" CELLSPACING=0 CELLPADDING=4 BORDER=0>$1</TABLE>
...Table Row
\[tr\](.*?)\[/tr\]
<TR><TH STYLE="height:1px; padding: 0 0 0 0; margin: 0 0 0 0" COLSPAN=100 CLASS="trow_sep"></TH></TR><TR>$1</TR>
...Table Row with colour
\[tr=([a-zA-Z]*|\#?[0-9a-fA-F]{6})\](.*?)\[/tr\]
<TR><TH STYLE="height:1px; padding: 0 0 0 0; margin: 0 0 0 0; background-color: $1" COLSPAN=100 CLASS="trow_sep"></TH></TR><TR>$2</TR>
......Table Element
\[td\](.*?)\[/td\]
<TD>$1</TD>
......Table Element with colour
\[td=([a-zA-Z]*|\#?[0-9a-fA-F]{6})\](.*?)\[/td\]
<TD BGCOLOR="$1">$2</TD>
......Table Element, spanned
\[td span=([^" []+?)\](.*?)\[/td\]
<TD COLSPAN="$1">$2</TD>
......Table Element, spanned with colour
\[td=([a-zA-Z]*|\#?[0-9a-fA-F]{6}) span=([0-9]+?)\](.*?)\[/td\]
<TD BGCOLOR="$1" COLSPAN="$2">$3</TD>

Tooltip
<TD BGCOLOR="$1" COLSPAN="$2">$3</TD>
<SPAN TITLE="$1">$2</SPAN>

Youtube
\[youtube\]http\://(www\.|)youtube\.com/watch\?v=([^"'[]+?)\[/youtube\]
<SMALL STYLE="margin-top: -100"><I><A HREF="http://www.youtube.com/watch?v=$2">Source: YouTube</A></I></SMALL>
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$2"></param><embed src="http://www.youtube.com/v/$2" type="application/x-shockwave-flash" width="425" height="350"></embed></object>



Hope someone finds this useful Smile
Just wanted to let you know, but your regex syntax is flawed. For example this is what it should be for subscript:
\[sub\](.*?)\[sub\]
Otherwise your codes won't work on most servers out there.
Apart from the above mentioned flaws in the regex, you have most of your html tags in uppercase when the standard is lowercase...

You also seem to switch between the old html tag attributes and CSS stylings quite randomly...

The "bgcolor" attribute for example, should be a css style:
background-color:
or just
background:
Cool thanks
DrPoodle Wrote:you have most of your html tags in uppercase when the standard is lowercase...
Big deal.... It's not like it's going to effect the output any. Confused

But you got a nice list, and I have some on my localhost, that I've never released...

Dr Small
The Wicked Flea Wrote:Just wanted to let you know, but your regex syntax is flawed. For example this is what it should be for subscript:
\[sub\](.*?)\[sub\]
Otherwise your codes won't work on most servers out there.
Really? Wow, thanks.
I'm sorda new to all this, so thanks for your input!
So, basically, you can't use an end-tag?

DrPoodle Wrote:Apart from the above mentioned flaws in the regex, you have most of your html tags in uppercase when the standard is lowercase...
Yeah. Actually, I was taught to use uppercase, so I'm sorda used to using uppercase.

DrPoodle Wrote:You also seem to switch between the old html tag attributes and CSS stylings quite randomly...

The "bgcolor" attribute for example, should be a css style:
background-color:
or just
background:
Yeah probably. I'm not very consistent >_>
Made them at different times.

Thanks everyone for their input! Smile
Quote:So, basically, you can't use an end-tag?
No. You missed the "/" in front of the expressions on your MyCode. You can have end tags, but it is almost always necessary to have the complete expression, or something'll go wrong.

Dr Small
Dr Small Wrote:
Quote:So, basically, you can't use an end-tag?
No. You missed the "/" in front of the expressions on your MyCode. You can have end tags, but it is almost always necessary to have the complete expression, or something'll go wrong.
*checks code*

ZOMG, the glitch in the MyBB parser!!! If I edit the post, it's there (you may have trouble quoting it, but if you do, you'll see the \ characters there).
I made a suggestion to fix that bug Smile
http://community.mybboard.net/showthread...#pid117712
Lowercase is the proper way and "xhtml valid". Otherwise you will be producing invalid xhtml and it's looked down upon.
Tikitiki Wrote:Lowercase is the proper way and "xhtml valid". Otherwise you will be producing invalid xhtml and it's looked down upon.
Oh okay. Didn't know that >_>

Thanks for the info!
Pages: 1 2