MyBB Community Forums

Full Version: Creating Custom MyCode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
is there any way we can filter or perform checks/modifications to the variables given?

Say with embedding stuff, it doesn't specify a mime type or whatever, I believe it could potentially be unsafe, if someone was able to apply a mime type, or something similar.
asmilewyt Wrote:oh it doesn't work.just show the blank in the post
Check this.

Flash tag
Replacement
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\">
<param name=\"movie\" value=\"$1\" />
<param name=\"quality\" value=\"high\" />
<embed src=\"$1\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>
</object>

WMP tag
Replacement
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="true" EnableContextMenu="true" autostart="false" width="320" height="240" loop="false" src="$1" />
Here is a better flash tag that supports width and height

Syntax : [flash=WidthxHeight]URL[/flash]

Regular expression :
\[flash\=(.*?)x(.*?)\](.*?)\[/flash\]

Replacement :
<object width="$1" height="$2"><param name="movie" value="somefilename.swf"><embed src="$3" width="$1" height="$2"></embed></object>

(No line breaks because it makes line breaks on the posts too
I'm trying to get a spoiler tag to work.  I know there's a mod for this, but I'd rather just create a custom mycode than have to have a mod for it.

I added the simple function to jscripts/general.js:
function showSpoiler(block) 
{
   block.nextSibling.nextSibling.style.display ="block";
   block.parentNode.removeChild(block);
}

As my replacement code, I have:
<input type="button" style="background:black;color:white;" onClick="showSpoiler(this);" value="SPOILER - Click to Show">
<span style="display:none">$1</span>

I know the javascript and html work, because I've used that exact code on my website several times.  I can't figure out what's preventing it from working in MyBB though.  Any ideas?
Well, this appears to be a bug. I looked at the source code for the page that's output and discovered why it isn't working.

Instead of onClick="showSpoiler(this);", the board is for some unknown reason outputting o<strong></strong>nClick="showSpoiler(this);"

wtf???
That would be MyBB's "Javascript fixer" in action. Toungue It basically tries to make sure no dangerous Javascript sneaks through the post parser. The only way to avoid it is to use a plugin and the "parse_message_end" hook.
I figured it might be something like that but WHY would the javascript fixer be "fixing" custom MyCode? I think that's something that should be changed.
It stripped it after parsing the post however this will be changed to before for subsequent releases.
Ah, so in the next release, my javascript will work?  That'll be nice Smile

Edit: Oh yes, the MyCode replacement text definately needs to be run without being parsed. I just tried setting up a "text quote" that uses a textarea in place of the quote_body div. It was very nice, except that all line breaks got parsed, so in the text box you'd see <br /> all over the place. Hehehe...
Aweb Wrote:Here is a better flash tag that supports width and height

Syntax : [flash=WidthxHeight]URL[/flash]

Regular expression :
\[flash\=(.*?)x(.*?)\](.*?)\[/flash\]

Replacement :
<object width="$1" height="$2"><param name="movie" value="somefilename.swf"><embed src="$3" width="$1" height="$2"></embed></object>

(No line breaks because it makes line breaks on the posts too

Sure one can use additional variables to parse the width and height... But what's the point when one is only going to set it once in the MyCode.. Not unless you want the poster to be able to change the wrapper height and width to enlarge the display ??

Not something I would like a user to be able to do...

Have a look here > http://community.mybboard.net/showthread...4#pid80914

It's simple enough without giving the user the option to float the variables... Wink
Pages: 1 2 3 4 5 6 7 8 9