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

Last change on this file since 904 was 879, checked in by ray, 12 years ago
  • #1059 Equation plugin loosing formula onsubmit
  • #1060 Equation plugin various updates
  • 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        var inputField = document.getElementById("inputText");
83       
84        if (param["editedNode"] && param["editedNode"].tagName.toLowerCase() == 'span')
85        {
86                var formula = param["editedNode"].getAttribute("title").replace(/^`*(.*?)`*$/m,"$1");
87                if (!formula) formula = param["editedNode"].innerHTML.replace(/^`*(.*?)`*$/m,"$1");
88                inputField.value = formula;
89                preview();
90        }
91        else inputField.value = '';
92        inputField.focus();
93}
94 
95function onOK() {
96       
97 var param = {
98        "editedNode":window.dialogArguments.editedNode,
99        "formula" : document.getElementById("inputText").value
100 };
101 
102 __dlg_close(param);
103  return false;
104}
105
106function onCancel() {
107  __dlg_close(null);
108  return false;
109}
110
111function translate() {
112  if (!AMtranslated) { // run this only once
113    AMtranslated = true;
114    AMinitSymbols();
115    AMprocessNode(document.getElementById("clickInput"),true);
116    preview();
117  }
118}
119window.onload = Init;
120
121function AMnode2string(inNode,indent) {
122// thanks to James Frazer for contributing an initial version of this function
123   var i, str = "";
124   if(inNode.nodeType == 1) {
125       var name = inNode.nodeName.toLowerCase(); // (IE fix)
126       str = "\r" + indent + "<" + name;
127       for(i=0; i < inNode.attributes.length; i++)
128           if (inNode.attributes[i].nodeValue!="italic" &&
129               inNode.attributes[i].nodeValue!="" &&  //stop junk attributes
130               inNode.attributes[i].nodeValue!="inherit" && // (mostly IE)
131               inNode.attributes[i].nodeValue!=undefined &&
132               inNode.attributes[i].nodeName[0] != '-'
133               )
134               str += " "+inNode.attributes[i].nodeName+"="+
135                     "\""+inNode.attributes[i].nodeValue+"\"";
136       if (name == "math")
137           str += " xmlns=\"http://www.w3.org/1998/Math/MathML\"";
138       str += ">";
139       for(i=0; i<inNode.childNodes.length; i++)
140           str += AMnode2string(inNode.childNodes[i], indent+"  ");
141       if (name != "mo" && name != "mi" && name != "mn") str += "\r"+indent;
142       str += "</" + name + ">";
143   }
144   else if(inNode.nodeType == 3) {
145       var st = inNode.nodeValue;
146       for (i=0; i<st.length; i++)
147           if (st.charCodeAt(i)<32 || st.charCodeAt(i)>126)
148               str += "&#"+st.charCodeAt(i)+";";
149           else if (st.charAt(i)=="<" && indent != "  ") str += "&lt;";
150           else if (st.charAt(i)==">" && indent != "  ") str += "&gt;";
151           else if (st.charAt(i)=="&" && indent != "  ") str += "&amp;";
152           else str += st.charAt(i);
153   }
154   return str;
155}
156function showMathML()
157{
158        var math = document.getElementById("outputNode").getElementsByTagName("math")[0];
159        if (math)
160                math.parentNode.innerHTML = '<pre>'+Xinha.htmlEncode(AMnode2string(math,''))+'</pre>';
161}
162// ]]>
163</script>
164
165</head>
166
167<body class="dialog">
168<div class="title">AsciiMath Formula Input</div>
169<!--
170Table modified from CharacterMap for ASCIIMathML by Peter Jipsen
171HTMLSource based on HTMLArea XTD 1.5 (http://mosforge.net/projects/htmlarea3xtd/) modified by Holger Hees
172Original Author - Bernhard Pfeifer novocaine@gmx.net
173-->
174<table  id="clickInput">
175<tr>
176<td colspan="3" class="character" title="(x+1)/(x-1)" onclick="set('(x+1)/(x-1)')">`(x+1)/(x-1)`</td>
177<td colspan="2" class="character" title="x^(m+n)" onclick="set('x^(m+n)')">`x^(m+n)`</td>
178<td colspan="2" class="character" title="x_(mn)" onclick="set('x_(mn)')">`x_(mn)`</td>
179<td colspan="2" class="character" title="sqrt(x)" onclick="set('sqrt(x)')">`sqrt(x)`</td>
180<td colspan="3" class="character" title="root(n)(x)" onclick="set('root(n)(x)')">`root(n)(x)`</td>
181<td colspan="2" class="character" title="&quot;text&quot;" onclick="set('&quot;text&quot;')">`&quot;text&quot;`</td>
182<td colspan="2" class="character" style="cursor:default"></td>
183</tr><tr>
184<td colspan="2" class="character" title="dy/dx" onclick="set('dy/dx')">`dy/dx`</td>
185<td colspan="3" class="character" title="lim_(x-&gt;oo)" onclick="set('lim_(x-&gt;oo)')">`lim_(x-&gt;oo)`</td>
186<td colspan="3" class="character" title="sum_(n=1)^oo" onclick="set('sum_(n=1)^oo')">`sum_(n=1)^oo`</td>
187<td colspan="3" class="character" title="int_a^bf(x)dx" onclick="set('int_a^bf(x)dx')">`int_a^bf(x)dx`</td>
188<td colspan="3" class="character" title="[[a,b],[c,d]]" onclick="set('[[a,b],[c,d]]')">`[[a,b],[c,d]]`</td>
189<td colspan="2" class="character" title="((n),(k))" onclick="set('((n),(k))')">`((n),(k))`</td>
190</tr><tr>
191<td class="character" title="*" onclick="set('*')">`*`</td>
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="xx" onclick="set('xx')">`xx`</td>
196<td class="character" title="-:" onclick="set('-:')">`-:`</td>
197<td class="character" title="@" onclick="set('@')">`@`</td>
198<td class="character" title="o+" onclick="set('o+')">`o+`</td>
199<td class="character" title="ox" onclick="set('ox')">`ox`</td>
200<td class="character" title="o." onclick="set('o.')">`o.`</td>
201<td class="character" title="sum" onclick="set('sum')">`sum`</td>
202<td class="character" title="prod" onclick="set('prod')">`prod`</td>
203<td class="character" title="^^" onclick="set('^^')">`^^`</td>
204<td class="character" title="^^^" onclick="set('^^^')"><span style="font-size:larger">`&and;`</span></td>
205<td class="character" title="vv" onclick="set('vv')">`vv`</td>
206<td class="character" title="vvv" onclick="set('vvv')"><span style="font-size:larger">`&or;`</span></td>
207</tr><tr>
208<td class="character" title="!=" onclick="set('!=')">`!=`</td>
209<td class="character" title="&lt;=" onclick="set('&lt;=')">`&lt;=`</td>
210<td class="character" title="&gt;=" onclick="set('&gt;=')">`&gt;=`</td>
211<td class="character" title="-&lt;" onclick="set('-&lt;')">`-&lt;`</td>
212<td class="character" title="&gt;-" onclick="set('&gt;-')">`&gt;-`</td>
213<td class="character" title="in" onclick="set('in')">`in`</td>
214<td class="character" title="!in" onclick="set('!in')">`!in`</td>
215<td class="character" title="sub" onclick="set('sub')">`sub`</td>
216<td class="character" title="sup" onclick="set('sup')">`sup`</td>
217<td class="character" title="sube" onclick="set('sube')">`sube`</td>
218<td class="character" title="supe" onclick="set('supe')">`supe`</td>
219<td class="character" title="O/" onclick="set('O/')">`O/`</td>
220<td class="character" title="nn" onclick="set('nn')">`nn`</td>
221<td class="character" title="nnn" onclick="set('nnn')"><span style="font-size:larger">`&cap;`</span></td>
222<td class="character" title="uu" onclick="set('uu')">`uu`</td>
223<td class="character" title="uuu" onclick="set('uuu')"><span style="font-size:larger">`&cup;`</span></td>
224</tr><tr>
225<td class="character" title="and" onclick="set('and')">`and`</td>
226<td class="character" title="or" onclick="set('or')">`or`</td>
227<td class="character" title="not" onclick="set('not')">`not`</td>
228<td class="character" title="=&gt;" onclick="set('==&gt;')">`=&gt;`</td>
229<td class="character" title="if" onclick="set('if')">`if`</td>
230<td class="character" title="&lt;=&gt;" onclick="set('&lt;=&gt;')">`&lt;=&gt;`</td>
231<td class="character" title="AA" onclick="set('AA')">`AA`</td>
232<td class="character" title="EE" onclick="set('EE')">`EE`</td>
233<td class="character" title="_|_" onclick="set('_|_')">`_|_`</td>
234<td class="character" title="TT" onclick="set('TT')">`TT`</td>
235<td class="character" title="|--" onclick="set('|--')">`|--`</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="prop" onclick="set('prop')">`prop`</td>
241</tr><tr>
242<td class="character" title="int" onclick="set('int')">`int`</td>
243<td class="character" title="oint" onclick="set('oint')">`oint`</td>
244<td class="character" title="del" onclick="set('del')">`del`</td>
245<td class="character" title="grad" onclick="set('grad')">`grad`</td>
246<td class="character" title="+-" onclick="set('+-')">`+-`</td>
247<td class="character" title="oo" onclick="set('oo')">`oo`</td>
248<td class="character" title="aleph" onclick="set('aleph')">`aleph`</td>
249<td class="character" title="quad" onclick="set('quad')">`quad`</td>
250<td class="character" title="diamond" onclick="set('diamond')">`diamond`</td>
251<td class="character" title="square" onclick="set('square')">`square`</td>
252<td class="character" title="|__" onclick="set('|__')">`|__`</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="&lt;x&gt;" onclick="set('&lt;x&gt;')">`&lt;x&gt;`</td>
257<td class="character" title="/_" onclick="set('/_')">`/_`</td>
258</tr><tr>
259<td class="character" title="uarr" onclick="set('uarr')">`uarr`</td>
260<td class="character" title="darr" onclick="set('darr')">`darr`</td>
261<td class="character" title="larr" onclick="set('larr')">`larr`</td>
262<td class="character" title="-&gt;" onclick="set('-&gt;')">`-&gt;`</td>
263<td class="character" title="|-&gt;" onclick="set('|-&gt;')">`|-&gt;`</td>
264<td class="character" title="harr" onclick="set('harr')">`harr`</td>
265<td class="character" title="lArr" onclick="set('lArr')">`lArr`</td>
266<td class="character" title="rArr" onclick="set('rArr')">`rArr`</td>
267<td class="character" title="hArr" onclick="set('hArr')">`hArr`</td>
268<td class="character" title="hata" onclick="set('hat')">`hata`</td>
269<td class="character" title="ula" onclick="set('ul')">`ula`</td>
270<td class="character" title="dota" onclick="set('dot')">`dota`</td>
271<td class="character" title="ddota" onclick="set('ddot')">`ddota`</td>
272<td class="character" title="veca" onclick="set('vec')">`veca`</td>
273<td class="character" title="bara" onclick="set('bar')">`bara`</td>
274<td class="character" title=":." onclick="set(':.')">`:.`</td>
275</tr><tr>
276<td class="character" title="NN" onclick="set('NN')">`NN`</td>
277<td class="character" title="ZZ" onclick="set('ZZ')">`ZZ`</td>
278<td class="character" title="QQ" onclick="set('QQ')">`QQ`</td>
279<td class="character" title="RR" onclick="set('RR')">`RR`</td>
280<td class="character" title="CC" onclick="set('CC')">`CC`</td>
281<td class="character" title="bba" onclick="set('bb')">`bba`</td>
282<td class="character" title="bbba" onclick="set('bbb')">`bbba`</td>
283<td class="character" title="cca" onclick="set('cc')">`cca`</td>
284<td class="character" title="fra" onclick="set('fr')">`fra`</td>
285<td class="character" title="sfa" onclick="set('sf')">`sfa`</td>
286<td class="character" title="tta" onclick="set('tt')">`tta`</td>
287<td colspan="4" class="character" title="stackrel(-&gt;)(+)" onclick="set('stackrel(-&gt;)(+)')">`stackrel(-&gt;)(+)`</td>
288<td class="character" title="upsilon" onclick="set('upsilon')">`upsilon`</td>
289</tr><tr>
290<td class="character" title="alpha" onclick="set('alpha')">`alpha`</td>
291<td class="character" title="beta" onclick="set('beta')">`beta`</td>
292<td class="character" title="gamma" onclick="set('gamma')">`gamma`</td>
293<td class="character" title="Gamma" onclick="set('Gamma')">`Gamma`</td>
294<td class="character" title="delta" onclick="set('delta')">`delta`</td>
295<td class="character" title="Delta" onclick="set('Delta')">`Delta`</td>
296<td class="character" title="epsi" onclick="set('epsi')">`epsi`</td>
297<td class="character" title="zeta" onclick="set('zeta')">`zeta`</td>
298<td class="character" title="eta" onclick="set('eta')">`eta`</td>
299<td class="character" title="theta" onclick="set('theta')">`theta`</td>
300<td class="character" title="Theta" onclick="set('Theta')">`Theta`</td>
301<td class="character" title="iota" onclick="set('iota')">`iota`</td>
302<td class="character" title="kappa" onclick="set('kappa')">`kappa`</td>
303<td class="character" title="lambda" onclick="set('lambda')">`lambda`</td>
304<td class="character" title="Lambda" onclick="set('Lambda')">`Lambda`</td>
305<td class="character" title="mu" onclick="set('mu')">`mu`</td>
306</tr><tr>
307<td class="character" title="nu" onclick="set('nu')">`nu`</td>
308<td class="character" title="pi" onclick="set('pi')">`pi`</td>
309<td class="character" title="Pi" onclick="set('Pi')">`Pi`</td>
310<td class="character" title="rho" onclick="set('rho')">`rho`</td>
311<td class="character" title="sigma" onclick="set('sigma')">`sigma`</td>
312<td class="character" title="Sigma" onclick="set('Sigma')">`Sigma`</td>
313<td class="character" title="tau" onclick="set('tau')">`tau`</td>
314<td class="character" title="xi" onclick="set('xi')">`xi`</td>
315<td class="character" title="Xi" onclick="set('Xi')">`Xi`</td>
316<td class="character" title="phi" onclick="set('phi')">`phi`</td>
317<td class="character" title="Phi" onclick="set('Phi')">`Phi`</td>
318<td class="character" title="chi" onclick="set('chi')">`chi`</td>
319<td class="character" title="psi" onclick="set('psi')">`psi`</td>
320<td class="character" title="Psi" onclick="set('Psi')">`Psi`</td>
321<td class="character" title="omega" onclick="set('omega')">`omega`</td>
322<td class="character" title="Omega" onclick="set('Omega')">`Omega`</td>
323</tr>
324</table>
325<form action="javascript:void(0);">
326<table style="width: 100%;border:none">
327  <tr>
328    <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>
329  </tr>
330  <tr>
331    <td>
332    <textarea id="inputText" onkeyup="preview()"></textarea>
333    </td>
334    <td>
335    <div id="outputNode"></div>
336    <textarea id="mathml" style="display:none"></textarea>
337    </td>
338  </tr>
339  <tr><td colspan="2">
340  <span>Based on ASCIIMathML by </span><a href="http://www.chapman.edu/~jipsen" onclick="window.open(this.href,'_blank','');return false;">Peter Jipsen</a>,
341<a href="http://www.chapman.edu" onclick="window.open(this.href,'_blank','');return false;">Chapman University</a><br />
342  <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>
343</table>
344
345<div id="buttons">
346<script type="text/javascript">
347// <![CDATA[
348if (Xinha.is_ie)
349 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>');
350// ]]>
351</script>
352  <button type="submit" name="ok" onclick="return onOK();">OK</button>
353  <button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
354</div>
355</form>
356</body>
357</html>
Note: See TracBrowser for help on using the repository browser.