source: trunk/plugins/Equation/popups/dialog.html @ 942

Last change on this file since 942 was 942, checked in by ray, 12 years ago
  • #1137 [Equation] FF3 fixes & improved way of avoiding formula changes in editor
  • #1136 FF3 Linux select boxes in toolbar are too small
  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 16.5 KB
Line 
1<!DOCTYPE html
2     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6<head>
7  <title>AsciiMath Formula Input</title>
8  <script type="text/javascript" src="../../../popups/popup.js"></script>
9  <script type="text/javascript" src="../ASCIIMathML.js"></script>
10  <link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
11
12  <style type="text/css">
13        /* <![CDATA[ */
14        #outputNode,#inputText,#mathml {
15                padding:5px;
16                background-color:white;
17                width:98%;
18                height:200px;
19                font-size:1.3em;
20                border: 1px solid darkgrey;
21                overflow:auto;
22        }
23        #clickInput {
24                width:100%;
25                border-collapse:collapse;
26                background-color: white;
27                text-align:center;
28        }
29        #clickInput td {
30                border: thin solid gray;
31                cursor:pointer;
32                font-size:1.1em;
33               
34        }
35        h3 {
36                font-size:1.6em;
37        }
38        /* ]]> */
39  </style>
40  <script type="text/javascript">
41 // <![CDATA[
42   window.resizeTo(500, 300);
43var showasciiformulaonhover = false;
44if (typeof Xinha == "undefined")
45        Xinha = window.opener.Xinha;
46
47function i18n(str) {
48  return (Xinha._lc(str, 'Equation'));
49}
50function set (string)
51{
52        var inputField = document.getElementById("inputText");
53        inputField.value += string;
54        preview();
55        inputField.focus();
56        return false;
57}
58function preview() {
59  if (document.getElementById("inputText") != '') {
60      var str = document.getElementById("inputText").value;
61      var outnode = document.getElementById("outputNode");
62      var newnode = AMcreateElementXHTML("div");
63      newnode.setAttribute("id","outputNode");
64      outnode.parentNode.replaceChild(newnode,outnode);
65      outnode = document.getElementById("outputNode");
66      var n = outnode.childNodes.length;
67      for (var i = 0; i < n; i++)
68        outnode.removeChild(outnode.firstChild);
69      outnode.appendChild(document.createComment("`"+str+"`"));
70      AMprocessNode(outnode,true);
71  }
72}
73function Init() {
74        __dlg_translate('Equation');
75        __dlg_init();
76        var param = window.dialogArguments;
77        var cfg = param["editor"].config;
78       
79        mathcolor = cfg.Equation.mathcolor;
80        mathfontfamily = cfg.Equation.mathfontfamily;
81       
82        translate();
83        var inputField = document.getElementById("inputText");
84       
85        if (param["editedNode"] && param["editedNode"].tagName.toLowerCase() == 'span')
86        {
87                var formula = param["editedNode"].getAttribute("title").replace(/^`*(.*?)`*$/m,"$1");
88                if (!formula) formula = param["editedNode"].innerHTML.replace(/^`*(.*?)`*$/m,"$1");
89                inputField.value = formula;
90                preview();
91        }
92        else inputField.value = '';
93        inputField.focus();
94}
95 
96function onOK() {
97       
98 var param = {
99        "editedNode":window.dialogArguments.editedNode,
100        "formula" : document.getElementById("inputText").value
101 };
102 
103 __dlg_close(param);
104  return false;
105}
106
107function onCancel() {
108  __dlg_close(null);
109  return false;
110}
111
112function translate() {
113  if (!AMtranslated) { // run this only once
114    AMtranslated = true;
115    AMinitSymbols();
116    AMprocessNode(document.getElementById("clickInput"),true);
117    preview();
118  }
119}
120window.onload = Init;
121
122function AMnode2string(inNode,indent) {
123// thanks to James Frazer for contributing an initial version of this function
124   var i, str = "";
125   if(inNode.nodeType == 1) {
126       var name = inNode.nodeName.toLowerCase(); // (IE fix)
127       str = "\r" + indent + "<" + name;
128       for(i=0; i < inNode.attributes.length; i++)
129           if (inNode.attributes[i].nodeValue!="italic" &&
130               inNode.attributes[i].nodeValue!="" &&  //stop junk attributes
131               inNode.attributes[i].nodeValue!="inherit" && // (mostly IE)
132               inNode.attributes[i].nodeValue!=undefined &&
133               inNode.attributes[i].nodeName[0] != '-'
134               )
135               str += " "+inNode.attributes[i].nodeName+"="+
136                     "\""+inNode.attributes[i].nodeValue+"\"";
137       if (name == "math")
138           str += " xmlns=\"http://www.w3.org/1998/Math/MathML\"";
139       str += ">";
140       for(i=0; i<inNode.childNodes.length; i++)
141           str += AMnode2string(inNode.childNodes[i], indent+"  ");
142       if (name != "mo" && name != "mi" && name != "mn") str += "\r"+indent;
143       str += "</" + name + ">";
144   }
145   else if(inNode.nodeType == 3) {
146       var st = inNode.nodeValue;
147       for (i=0; i<st.length; i++)
148           if (st.charCodeAt(i)<32 || st.charCodeAt(i)>126)
149               str += "&#"+st.charCodeAt(i)+";";
150           else if (st.charAt(i)=="<" && indent != "  ") str += "&lt;";
151           else if (st.charAt(i)==">" && indent != "  ") str += "&gt;";
152           else if (st.charAt(i)=="&" && indent != "  ") str += "&amp;";
153           else str += st.charAt(i);
154   }
155   return str;
156}
157function showMathML()
158{
159        var math = document.getElementById("outputNode").getElementsByTagName("math")[0];
160        if (math)
161                math.parentNode.innerHTML = '<pre>'+Xinha.htmlEncode(AMnode2string(math,''))+'</pre>';
162}
163// ]]>
164</script>
165
166</head>
167
168<body class="dialog">
169<div class="title">AsciiMath Formula Input</div>
170<!--
171Table modified from CharacterMap for ASCIIMathML by Peter Jipsen
172HTMLSource based on HTMLArea XTD 1.5 (http://mosforge.net/projects/htmlarea3xtd/) modified by Holger Hees
173Original Author - Bernhard Pfeifer novocaine@gmx.net
174-->
175<table  id="clickInput">
176<tr>
177<td colspan="3" class="character" title="(x+1)/(x-1)" onclick="set('(x+1)/(x-1)')">`(x+1)/(x-1)`</td>
178<td colspan="2" class="character" title="x^(m+n)" onclick="set('x^(m+n)')">`x^(m+n)`</td>
179<td colspan="2" class="character" title="x_(mn)" onclick="set('x_(mn)')">`x_(mn)`</td>
180<td colspan="2" class="character" title="sqrt(x)" onclick="set('sqrt(x)')">`sqrt(x)`</td>
181<td colspan="3" class="character" title="root(n)(x)" onclick="set('root(n)(x)')">`root(n)(x)`</td>
182<td colspan="2" class="character" title="&quot;text&quot;" onclick="set('&quot;text&quot;')">`&quot;text&quot;`</td>
183<td colspan="2" class="character" style="cursor:default"></td>
184</tr><tr>
185<td colspan="2" class="character" title="dy/dx" onclick="set('dy/dx')">`dy/dx`</td>
186<td colspan="3" class="character" title="lim_(x-&gt;oo)" onclick="set('lim_(x-&gt;oo)')">`lim_(x-&gt;oo)`</td>
187<td colspan="3" class="character" title="sum_(n=1)^oo" onclick="set('sum_(n=1)^oo')">`sum_(n=1)^oo`</td>
188<td colspan="3" class="character" title="int_a^bf(x)dx" onclick="set('int_a^bf(x)dx')">`int_a^bf(x)dx`</td>
189<td colspan="3" class="character" title="[[a,b],[c,d]]" onclick="set('[[a,b],[c,d]]')">`[[a,b],[c,d]]`</td>
190<td colspan="2" class="character" title="((n),(k))" onclick="set('((n),(k))')">`((n),(k))`</td>
191</tr><tr>
192<td class="character" title="*" onclick="set('*')">`*`</td>
193<td class="character" title="**" onclick="set('**')">`**`</td>
194<td class="character" title="//" onclick="set('//')">`//`</td>
195<td class="character" title="\\" onclick="set('\\\\')">`\\`</td>
196<td class="character" title="xx" onclick="set('xx')">`xx`</td>
197<td class="character" title="-:" onclick="set('-:')">`-:`</td>
198<td class="character" title="@" onclick="set('@')">`@`</td>
199<td class="character" title="o+" onclick="set('o+')">`o+`</td>
200<td class="character" title="ox" onclick="set('ox')">`ox`</td>
201<td class="character" title="o." onclick="set('o.')">`o.`</td>
202<td class="character" title="sum" onclick="set('sum')">`sum`</td>
203<td class="character" title="prod" onclick="set('prod')">`prod`</td>
204<td class="character" title="^^" onclick="set('^^')">`^^`</td>
205<td class="character" title="^^^" onclick="set('^^^')"><span style="font-size:larger">`&and;`</span></td>
206<td class="character" title="vv" onclick="set('vv')">`vv`</td>
207<td class="character" title="vvv" onclick="set('vvv')"><span style="font-size:larger">`&or;`</span></td>
208</tr><tr>
209<td class="character" title="!=" onclick="set('!=')">`!=`</td>
210<td class="character" title="&lt;=" onclick="set('&lt;=')">`&lt;=`</td>
211<td class="character" title="&gt;=" onclick="set('&gt;=')">`&gt;=`</td>
212<td class="character" title="-&lt;" onclick="set('-&lt;')">`-&lt;`</td>
213<td class="character" title="&gt;-" onclick="set('&gt;-')">`&gt;-`</td>
214<td class="character" title="in" onclick="set('in')">`in`</td>
215<td class="character" title="!in" onclick="set('!in')">`!in`</td>
216<td class="character" title="sub" onclick="set('sub')">`sub`</td>
217<td class="character" title="sup" onclick="set('sup')">`sup`</td>
218<td class="character" title="sube" onclick="set('sube')">`sube`</td>
219<td class="character" title="supe" onclick="set('supe')">`supe`</td>
220<td class="character" title="O/" onclick="set('O/')">`O/`</td>
221<td class="character" title="nn" onclick="set('nn')">`nn`</td>
222<td class="character" title="nnn" onclick="set('nnn')"><span style="font-size:larger">`&cap;`</span></td>
223<td class="character" title="uu" onclick="set('uu')">`uu`</td>
224<td class="character" title="uuu" onclick="set('uuu')"><span style="font-size:larger">`&cup;`</span></td>
225</tr><tr>
226<td class="character" title="and" onclick="set('and')">`and`</td>
227<td class="character" title="or" onclick="set('or')">`or`</td>
228<td class="character" title="not" onclick="set('not')">`not`</td>
229<td class="character" title="=&gt;" onclick="set('==&gt;')">`=&gt;`</td>
230<td class="character" title="if" onclick="set('if')">`if`</td>
231<td class="character" title="&lt;=&gt;" onclick="set('&lt;=&gt;')">`&lt;=&gt;`</td>
232<td class="character" title="AA" onclick="set('AA')">`AA`</td>
233<td class="character" title="EE" onclick="set('EE')">`EE`</td>
234<td class="character" title="_|_" onclick="set('_|_')">`_|_`</td>
235<td class="character" title="TT" onclick="set('TT')">`TT`</td>
236<td class="character" title="|--" onclick="set('|--')">`|--`</td>
237<td class="character" title="|==" onclick="set('|==')">`|==`</td>
238<td class="character" title="-=" onclick="set('-=')">`-=`</td>
239<td class="character" title="~=" onclick="set('~=')">`~=`</td>
240<td class="character" title="~~" onclick="set('~~')">`~~`</td>
241<td class="character" title="prop" onclick="set('prop')">`prop`</td>
242</tr><tr>
243<td class="character" title="int" onclick="set('int')">`int`</td>
244<td class="character" title="oint" onclick="set('oint')">`oint`</td>
245<td class="character" title="del" onclick="set('del')">`del`</td>
246<td class="character" title="grad" onclick="set('grad')">`grad`</td>
247<td class="character" title="+-" onclick="set('+-')">`+-`</td>
248<td class="character" title="oo" onclick="set('oo')">`oo`</td>
249<td class="character" title="aleph" onclick="set('aleph')">`aleph`</td>
250<td class="character" title="quad" onclick="set('quad')">`quad`</td>
251<td class="character" title="diamond" onclick="set('diamond')">`diamond`</td>
252<td class="character" title="square" onclick="set('square')">`square`</td>
253<td class="character" title="|__" onclick="set('|__')">`|__`</td>
254<td class="character" title="__|" onclick="set('__|')">`__|`</td>
255<td class="character" title="|~" onclick="set('|~')">`|~`</td>
256<td class="character" title="~|" onclick="set('~|')">`~|`</td>
257<td class="character" title="&lt;x&gt;" onclick="set('&lt;x&gt;')">`&lt;x&gt;`</td>
258<td class="character" title="/_" onclick="set('/_')">`/_`</td>
259</tr><tr>
260<td class="character" title="uarr" onclick="set('uarr')">`uarr`</td>
261<td class="character" title="darr" onclick="set('darr')">`darr`</td>
262<td class="character" title="larr" onclick="set('larr')">`larr`</td>
263<td class="character" title="-&gt;" onclick="set('-&gt;')">`-&gt;`</td>
264<td class="character" title="|-&gt;" onclick="set('|-&gt;')">`|-&gt;`</td>
265<td class="character" title="harr" onclick="set('harr')">`harr`</td>
266<td class="character" title="lArr" onclick="set('lArr')">`lArr`</td>
267<td class="character" title="rArr" onclick="set('rArr')">`rArr`</td>
268<td class="character" title="hArr" onclick="set('hArr')">`hArr`</td>
269<td class="character" title="hata" onclick="set('hat')">`hata`</td>
270<td class="character" title="ula" onclick="set('ul')">`ula`</td>
271<td class="character" title="dota" onclick="set('dot')">`dota`</td>
272<td class="character" title="ddota" onclick="set('ddot')">`ddota`</td>
273<td class="character" title="veca" onclick="set('vec')">`veca`</td>
274<td class="character" title="bara" onclick="set('bar')">`bara`</td>
275<td class="character" title=":." onclick="set(':.')">`:.`</td>
276</tr><tr>
277<td class="character" title="NN" onclick="set('NN')">`NN`</td>
278<td class="character" title="ZZ" onclick="set('ZZ')">`ZZ`</td>
279<td class="character" title="QQ" onclick="set('QQ')">`QQ`</td>
280<td class="character" title="RR" onclick="set('RR')">`RR`</td>
281<td class="character" title="CC" onclick="set('CC')">`CC`</td>
282<td class="character" title="bba" onclick="set('bb')">`bba`</td>
283<td class="character" title="bbba" onclick="set('bbb')">`bbba`</td>
284<td class="character" title="cca" onclick="set('cc')">`cca`</td>
285<td class="character" title="fra" onclick="set('fr')">`fra`</td>
286<td class="character" title="sfa" onclick="set('sf')">`sfa`</td>
287<td class="character" title="tta" onclick="set('tt')">`tta`</td>
288<td colspan="4" class="character" title="stackrel(-&gt;)(+)" onclick="set('stackrel(-&gt;)(+)')">`stackrel(-&gt;)(+)`</td>
289<td class="character" title="upsilon" onclick="set('upsilon')">`upsilon`</td>
290</tr><tr>
291<td class="character" title="alpha" onclick="set('alpha')">`alpha`</td>
292<td class="character" title="beta" onclick="set('beta')">`beta`</td>
293<td class="character" title="gamma" onclick="set('gamma')">`gamma`</td>
294<td class="character" title="Gamma" onclick="set('Gamma')">`Gamma`</td>
295<td class="character" title="delta" onclick="set('delta')">`delta`</td>
296<td class="character" title="Delta" onclick="set('Delta')">`Delta`</td>
297<td class="character" title="epsi" onclick="set('epsi')">`epsi`</td>
298<td class="character" title="zeta" onclick="set('zeta')">`zeta`</td>
299<td class="character" title="eta" onclick="set('eta')">`eta`</td>
300<td class="character" title="theta" onclick="set('theta')">`theta`</td>
301<td class="character" title="Theta" onclick="set('Theta')">`Theta`</td>
302<td class="character" title="iota" onclick="set('iota')">`iota`</td>
303<td class="character" title="kappa" onclick="set('kappa')">`kappa`</td>
304<td class="character" title="lambda" onclick="set('lambda')">`lambda`</td>
305<td class="character" title="Lambda" onclick="set('Lambda')">`Lambda`</td>
306<td class="character" title="mu" onclick="set('mu')">`mu`</td>
307</tr><tr>
308<td class="character" title="nu" onclick="set('nu')">`nu`</td>
309<td class="character" title="pi" onclick="set('pi')">`pi`</td>
310<td class="character" title="Pi" onclick="set('Pi')">`Pi`</td>
311<td class="character" title="rho" onclick="set('rho')">`rho`</td>
312<td class="character" title="sigma" onclick="set('sigma')">`sigma`</td>
313<td class="character" title="Sigma" onclick="set('Sigma')">`Sigma`</td>
314<td class="character" title="tau" onclick="set('tau')">`tau`</td>
315<td class="character" title="xi" onclick="set('xi')">`xi`</td>
316<td class="character" title="Xi" onclick="set('Xi')">`Xi`</td>
317<td class="character" title="phi" onclick="set('phi')">`phi`</td>
318<td class="character" title="Phi" onclick="set('Phi')">`Phi`</td>
319<td class="character" title="chi" onclick="set('chi')">`chi`</td>
320<td class="character" title="psi" onclick="set('psi')">`psi`</td>
321<td class="character" title="Psi" onclick="set('Psi')">`Psi`</td>
322<td class="character" title="omega" onclick="set('omega')">`omega`</td>
323<td class="character" title="Omega" onclick="set('Omega')">`Omega`</td>
324</tr>
325</table>
326<form action="javascript:void(0);">
327<table style="width: 100%;border:none">
328  <tr>
329    <td style="width:50%">Input</td><td style="width:50%"><input type="button" onclick="showMathML()" style="float:right;font-size:10px" value="Show MathML" /><span>Preview</span></td>
330  </tr>
331  <tr>
332    <td>
333    <textarea id="inputText" onkeyup="preview()"></textarea>
334    </td>
335    <td>
336    <div id="outputNode"></div>
337    <textarea id="mathml" style="display:none"></textarea>
338    </td>
339  </tr>
340  <tr><td colspan="2">
341  <span>Based on ASCIIMathML by </span><a href="http://www.chapman.edu/~jipsen" onclick="window.open(this.href,'_blank','');return false;">Peter Jipsen</a>,
342<a href="http://www.chapman.edu" onclick="window.open(this.href,'_blank','');return false;">Chapman University</a><br />
343  <span>For more information on AsciiMathML visit this page: </span><a href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html" onclick="window.open(this.href,'_blank','');return false;">http://www1.chapman.edu/~jipsen/mathml/asciimath.html</a></td></tr>
344</table>
345
346<div id="buttons">
347<script type="text/javascript">
348// <![CDATA[
349if (Xinha.is_ie)
350 document.write('<span style="color:red;float:left">'+i18n('Attention Internet Explorer users: Please note that there is no WYSIWYG representation of the formula in the editor!<br />You might wish to use <a href="http://www.mozilla.com" target="_blank">Mozilla Firefox</a> instead.')+'</span>');
351// ]]>
352</script>
353  <button type="submit" name="ok" onclick="return onOK();">OK</button>
354  <button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
355</div>
356</form>
357</body>
358</html>
Note: See TracBrowser for help on using the repository browser.