I have been going nuts here trying to get javascript to do what I want it to do... As part of my nicer move tag, I have to have it insert a bunch of options. No problem there, except that in order to get it to work, all of the options have to be defined, which creates a little bit of a problem when trying to get [move=...] to be equivalent to the default marquee tag. I figured out that if you set the bgcolor and scrollamount to
"" or
'', it will work. My problem comes when trying to get the surroundtext function to insert this when the user clicks on the "move" button when posting...
In subs.php, I have
'/\[move=(.+?),(.+?),(.+?),(.+?),(.+?)\](.+?)\[\/move\]/is',
which coresponds to
<marquee direction=\\1 behavior=\\2 scrollamount=\\3 bgcolor=\\4 width=\\5>\\6</marquee>
The default code in post.php for move is:
<a href="javascript:surroundText(\'[move]\',\'[/move]\')"><img src="' . $imagesdir . '/move.gif" align="bottom" width="23" height="22" alt="' . $txt[439] . '" border="0" /></a>
Now... Everything works fine if I use a default bgcolor and a default scrollamount. My problem comes when trying to get it to act like the default <marquee></marquee> tag. I figured out that if I set both bgcolor and scrollamount to
'' or
"", it works just like the default marquee tag. The problem is, I can't get the surroundtext function to insert either of those (two single quotes or two double quotes). If I use
"", it ends the link early and cuts off the javascript, which will give me an error when I try to click the button. If I use
\"\", I get an error saying "Unterminated string constant" when I click on the button. If I use
'', I get a parse error, and if I use
\'\', I get an error saying expected: ')' because the extra \' s in the function cause it to end early:
Quote<a href="javascript:surroundText(\'[move=left,scroll,\'\',\'\',100%]\',\'[/move]\')"><img src="' . $imagesdir . '/move.gif" align="bottom" width="23" height="22" alt="' . $txt[439] . '" border="0" /></a>
If you look at the main surroundtext() function in ubbc.js, you notice that it's defined as javascript:surroundtext(text1,text2), so according to the code above:
text1 is
\'[move=left,scroll,\'then we have
\',\'and text2 is
\',100%]\'You can see where the error is occurring. My question is, how do I get this function to do this? It works fine if I subsitute a colorname and a scrollamount number for the '' above, but I want to set it so the default is scroll left with the default scrollamount and no background color.