Author Topic: href="javascript:void(0);" and the problems with my backslash  (Read 3349 times)

Offline Unregistriert

  • Semi-Newbie
  • *
  • Posts: 20

I try to write my own add on. This add on has me inspired.

In the manuals is the following code used:

Code: [Select]
<a href="javascript:void(0);" onclick="replaceText(\'', $variable, '\', '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;" style="text-decoration: none;"><img src=\'images', $variable, '\' align="bottom" alt="', $variable, '" title="', $variable, '" /></a> ';
The variables called like:  '\name'  or '\name\name\'  or something like that.

My problem is, that javascript ignores the backslash, and in the image-tag it is shown.

If i use double-backslash so that the javascript shows one, the image-tag shows both.

has anyone an idea, how i can close this problem?

thx :)

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,526
  • Young and Foolish
    • SimplePortal
Re: href="javascript:void(0);" and the problems with my backslash
« Reply #1 on: July 13, 2009, 01:02:55 PM »
Well, it is hard to guess the problem and offer a solution with a very little portion of code here. Can you provide all the code?

If you have quotes in the text you are inserting, then you need to use a different name for image file though.
Former SMF Core Developer | My Mods | SimplePortal

Offline Unregistriert

  • Semi-Newbie
  • *
  • Posts: 20
Re: href="javascript:void(0);" and the problems with my backslash
« Reply #2 on: July 13, 2009, 02:03:06 PM »
Hi  :)

okay, it's possible, that it is hard, to guess the problem.

now complete explanation:

I want to use a math-editor for my forum. So I found THIS modification. But I think, there is a problem for users, which are not that experienced with the TeX-program (it based on). So I asked HERE for a "bigger" modification, with choseable options of symbols.

Like this:


I didn't found a modification, which I like, so I decided, I program my own  :)

Inspired on THIS modification i started to coding....

This is my result :)

I started to duplicate the "swapOptions" (no smileys, fileupload...) on the bottom of the text-area, moved it to the top, the icon behind the buttons for the bb-styles, an the new field between the smiley-bar and the text area.

In the Post.template.php must be find the following code:
Code: [Select]
// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
insert this before:
Code: [Select]
echo '
function swapMathOptions()

document.getElementById("postMoreMathOptions").style.display = currentSwap ? "" : "none";

currentSwap = !currentSwap;

then it mus be find the following code:
Code: [Select]
// Now start printing all of the smileys.
if (!empty($context['smileys']['postform']))

in the echo-tag over it (which is closing a table with </td></tr>) must be insert before that </td></tr>:
Code: [Select]
<img src="', $settings['images_url'], '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" /><a href="javascript:swapMathOptions();"><img src="Themes/default/images/bbc/tex.gif" align="bottom" width="23" height="22" alt="LaTeX" title="LaTeX" style="background-image: url(Themes/default/images/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>

Finally it must be insert the new area:

It must be searched the following code:
Code: [Select]
// Finally the most important bit - the actual text box to write in!
insert this before:
Code: [Select]
// Display the check boxes for all the special options!
echo '
<td align="right"></td>
<td valign="middle">
<div id="postMoreMathOptions">

<!--<img src="" align="middle" alt="" title="" />
[tex][/tex] -->

<link rel="stylesheet" type="text/css" href="Themes/default/tabcontent.css" />
<script type="text/javascript" src="Themes/default/tabcontent.js"></script>

<ul id="countrytabs" class="shadetabs">
<li><a href="#" rel="country1" class="selected">
<img src="{\alpha}{\delta}" align="bottom" alt="{\alpha}{\delta}" title="{\alpha}{\delta}" />
<li><a href="#" rel="country2">
<img src="{a}\times{b}" align="bottom" alt="{a}\times{b}" title="{a}\times{b}" />
<li><a href="#" rel="country3">
<img src="{f(x)}" align="bottom" alt="{f(x)}" title="{f(x)}" />

<div style="border:1px solid gray; width:500px; margin-bottom: 1em; padding: 10px">

<div id="country1" class="tabcontent">
<img src="{\alpha}" align="bottom" alt="{\alpha}  " title="{\alpha}  " />

<img src="{\beta}" align="bottom" alt="{\beta}" title="{\beta}" />

<img src="{\gamma}" align="bottom" alt="{\gamma}" title="{\gamma}" />

<img src="{\delta}" align="bottom" alt="{\delta}" title="{\delta}" />

<img src="{\epsilon}" align="bottom" alt="{\epsilon}" title="{\epsilon}" />

<img src="{\zeta}" align="bottom" alt="{\zeta}" title="{\zeta}" />

<img src="{\eta}" align="bottom" alt="{\eta}" title="{\eta}" />

<img src="{\theta}" align="bottom" alt="{\theta}" title="{\theta}" />

<img src="{\iota}" align="bottom" alt="{\iota}" title="{\iota}" />

<img src="{\kappa}" align="bottom" alt="{\kappa}" title="{\kappa}" />

<img src="{\lambda}" align="bottom" alt="{\lambda}" title="{\lambda}" />

<img src="{\mu}" align="bottom" alt="{\mu}" title="{\mu}" />

<img src="{\nu}" align="bottom" alt="{\nu}" title="{\nu}" />

<img src="{\xi}" align="bottom" alt="{\xi}" title="{\xi}" />

<img src="{\pi}" align="bottom" alt="{\pi}" title="{\pi}" />
[tex]\pi [/tex]-->

<img src="{\rho}" align="bottom" alt="{\rho}" title="{\rho}" />
[tex]\rho [/tex]-->

<img src="{\sigma}" align="bottom" alt="{\sigma}" title="{\sigma}" />

<img src="{\tau}" align="bottom" alt="{\tau}" title="{\tau}" />

<img src="{\upsilon}" align="bottom" alt="{\upsilon}" title="{\upsilon}" />

<img src="{\phi}" align="bottom" alt="{\phi}" title="{\phi}" />

<img src="{\chi}" align="bottom" alt="{\chi}" title="{\chi}" />

<img src="{\psi}" align="bottom" alt="{\psi}" title="{\psi}" />

<img src="{\omega}" align="bottom" alt="{\omega}" title="{\omega}" />
[tex]\omega [/tex]-->

                      <br>      <br>

<img src="{\Gamma}" align="bottom" alt="{\Gamma}" title="{\Gamma}" />

<img src="{\Delta}" align="bottom" alt="{\Delta}" title="{\Delta}" />

<img src="{\Theta}" align="bottom" alt="{\Theta}" title="{\Theta}" />

<img src="{\Lambda}" align="bottom" alt="{\Lambda}" title="{\Lambda}" />

<img src="{\Xi}" align="bottom" alt="{\Xi}" title="{\Xi}" />

<img src="{\Pi}" align="bottom" alt="{\Pi}" title="{\Pi}" />
[tex]\Pi [/tex]-->

<img src="{\Sigma}" align="bottom" alt="{\Sigma}" title="{\Sigma}" />

<img src="{\Upsilon}" align="bottom" alt="{\Upsilon}" title="{\Upsilon}" />

<img src="{\Phi}" align="bottom" alt="{\Phi}" title="{\Phi}" />

<img src="{\Psi}" align="bottom" alt="{\Psi}" title="{\Psi}" />

<img src="{\Omega}" align="bottom" alt="{\Omega}" title="{\Omega}" />
[tex]\Omega [/tex]-->
<img src="{\dot V}" align="bottom" alt="{\dot V}" title="{\dot V}" />
<!--{\dot V}
[tex]{\dot V}[/tex]-->

<img src="{\ddot m}" align="bottom" alt="{\ddot m}" title="{\ddot m}" />
<!--{\ddot m}
[tex]{\ddot m}[/tex]-->

<img src="{\vec a}" align="bottom" alt="{\vec a}" title="{\vec a}" />
<!--{\vec a}
[tex]{\vec a}[/tex]-->

<img src="{\emptyset}" align="bottom" alt="{\emptyset}" title="{\emptyset}" />


<div id="country2" class="tabcontent">

<img src="\frac{a}{b}" align="middle" alt="\frac{a}{b}" title="\frac{a}{b}" />
[tex]\frac{a}{b} [/tex]-->
<img src="{a}+{b}" align="middle" alt="{a}+{b}" title="{a}+{b}" />
[tex] {a}+{b} [/tex]-->
<img src="{a}-{b}" align="middle" alt="{a}-{b}" title="{a}-{b}" />
[tex] {a}-{b} [/tex]-->
<img src="{a}\times{b}" align="middle" alt="{a}\times{b}" title="{a}\times{b}" />
<img src="{\neq}" align="middle" alt="{\neq}" title="{\neq}" />
<img src="{\ge}" align="middle" alt="{\ge}" title="{\ge}" />
<img src="{\le}" align="middle" alt="{\le}" title="{\le}" />
<img src="{sqrt{\beta}}" align="middle" alt="{sqrt{\beta}}" title="{sqrt{\beta}}" />
<img src="{sin(x)}" align="middle" alt="{sin(x)}" title="{sin(x)}" />
<img src="{360^\circ}" align="middle" alt="{360^\circ}" title="{360^\circ}" />
<img src="{X^{n}}" align="middle" alt="{X^{n}}" title="{X^{n}}" />
<img src="{{X}_{n}}" align="middle" alt="{{X}_{n}}" title="{{X}_{n}}" />
<!-- {{X}_{n}}


<div id="country3" class="tabcontent">

<img src="{\sum_{k=1}^N k^2}" align="middle" alt="{\sum_{k=1}^N k^2}" title="{\sum_{k=1}^N k^2}" />
<!--{\sum_{k=1}^N k^2}
[tex]{\sum_{k=1}^N k^2}[/tex]-->
<img src="{\int_{-N}^N e^x\,dx}" align="middle" alt="{\int_{-N}^N e^x\,dx}" title="{\int_{-N}^N e^x\,dx}" />
<!--{\int_{-N}^N e^x\,dx}
[tex]{\int_{-N}^N e^x\,dx}[/tex]-->
<img src="{n \choose k}" align="middle" alt="{n \choose k}" title="{n \choose k}" />
<!--{n \choose k}
[tex]{n \choose k}[/tex]-->
<img src="{\begin{pmatrix}{a_1}&{a_2}&{a_3}\\\{b_1}&{b_2}&{b_3}\\\{c_1}&{c_2}&{c_3}\end{pmatrix}}" align="middle" alt="{\begin{pmatrix}{a_1}&{a_2}&{a_3}\\{b_1}&{b_2}&{b_3}\\{c_1}&{c_2}&{c_3}\end{pmatrix}}" title="{\begin{pmatrix}{a_1}&{a_2}&{a_3}\\{b_1}&{b_2}&{b_3}\\{c_1}&{c_2}&{c_3}\end{pmatrix}}" />
<img src="{\begin{vmatrix}{a_1}&{a_2}&{a_3}\\\{b_1}&{b_2}&{b_3}\\\{c_1}&{c_2}&{c_3}\end{vmatrix}}" align="middle" alt="{\begin{vmatrix}{a_1}&{a_2}&{a_3}\\{b_1}&{b_2}&{b_3}\\{c_1}&{c_2}&{c_3}\end{vmatrix}}" title="{\begin{vmatrix}{a_1}&{a_2}&{a_3}\\{b_1}&{b_2}&{b_3}\\{c_1}&{c_2}&{c_3}\end{vmatrix}}" />
<img src="{}^4_2\mathrm{He}" align="middle" alt="{}^4_2\mathrm{He}" title="{}^4_2\mathrm{He}" />
<img src="{\lim_{n\to{\infty}}x_n}" align="middle" alt="{\lim_{n\to{\infty}}x_n}" title="{\lim_{n\to{\infty}}x_n}" />



<script type="text/javascript">

var countries=new ddtabcontent("countrytabs")
countries.setselectedClassTarget("link") //"link" or "linkparent"



// Show list of Vietnamese characters
$maths = array(
'{\Omega}', '{\Sigma}'

echo '
<td align="right"></td>
<td valign="middle">';
foreach ($maths as $math)
echo '<a href="javascript:void(0);" onclick="replaceText(\'', $math, '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;" style="text-decoration: none;"><img src=\'', $math, '\' align="bottom" alt="', $math, '" title="', $math, '" /></a> ';

         echo  "<img src=\"{\Omega}\" align=\"bottom\" alt=\"{\Omega}\" title=\"{\Omega}\" />";
echo '

// Show list of Vietnamese characters
$vietCharsM = array(
'Ä?', 'ỵ'
$vietCharsC = array(
'Ä?', 'á»´'

echo '
<td align="right"></td>
<td valign="middle">';
foreach ($vietCharsM as $vietChar)
echo '<a href="javascript:void(0);" onclick="replaceText(\'', $vietChar, '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;" style="text-decoration: none;">', $vietChar, '</a> ';

echo '
echo '
<td align="right"></td>
<td valign="middle">';
foreach ($vietCharsC as $vietChar)
echo '<a href="javascript:void(0);" onclick="replaceText(\'', $vietChar, '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;" style="text-decoration: none;">', $vietChar, '</a> ';

echo '

Finally the modifications from the "Tag LaTeX" are needed (Link I posted on top)

I know there is much useless code, and some errors, but the most is working :)

The tab-Script I found HERE [nofollow]
then there are needed following files:


(in the moment in the "Themes/default/" directory)

I think, that should it be...

I uploaded my files for the Version 1.1.4

Here it is working:;topic=1.0;num_replies=2 [nofollow]

Offline Unregistriert

  • Semi-Newbie
  • *
  • Posts: 20
Re: href="javascript:void(0);" and the problems with my backslash
« Reply #3 on: July 13, 2009, 02:12:37 PM »
To change the file-names i am not able, it caused, the math-script from [nofollow] used this:



certainly I am able to write for each icon:
Code: [Select]
<a href="javascript:void(0);" onclick="replaceText(\'{\\\Omega}\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;" style="text-decoration: none;"><img src=\'{\Omega}\' align="bottom" alt="{\Omega}" title="{\Omega}" /></a>
to show the Icons in the Forum, i did, but I think it is too pedantically. :)