Rev 12130 | Rev 12138 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7464 | schaersvoo | 1 | !set n=$counter |
2 | <link rel="stylesheet" href="$htmldir/jqmath.css"> |
||
3 | <script src="$jsdir/jqmath.js"></script> |
||
4 | !if $my_arrows=$empty |
||
5 | !set my_arrows=2 |
||
6 | !endif |
||
7 | !if $convert_root=$empty |
||
8 | !set convert_root=0 |
||
9 | !endif |
||
10 | !if $use_ineq != 1 |
||
11 | !set use_ineq=0 |
||
12 | !endif |
||
13 | <script type="text/javascript"> |
||
14 | //<![CDATA[ |
||
15 | <!-- no validator --> |
||
16 | var descr_list="$description";var descr_cnt = 30;var description = make_description(descr_list,descr_cnt);function dontknow(){myConfirm('$dontknow','?','$wims_ref_name','$session','$module','$counter','$nok_send_color');} |
||
17 | function sendanswer(){ |
||
18 | var input; |
||
19 | var show="<ul>"; |
||
20 | var inputfieldnumber = 0; |
||
21 | var reply = new Array(); |
||
22 | var tmp_show; |
||
23 | <!-- MathView js input html5 applet --> |
||
24 | if(document.getElementById("JSMathView")){ |
||
25 | input=document.getElementById("JSMathView").value; |
||
7483 | schaersvoo | 26 | if( input.length == 0) {setAlarm(r1+"\ $counter");return;}; |
27 | if( input.length > 200 ){setAlarm(r2); return;}; |
||
28 | if(input.indexOf(',') != -1 && input.indexOf('table') == -1){setAlarm(r4);return;}; |
||
7477 | schaersvoo | 29 | !if $special_fraction=1 |
7483 | schaersvoo | 30 | <!-- allow 1 2/3 to be send as 1+2/3 in stead of 12/3... --> |
7477 | schaersvoo | 31 | input = singlespace(input); |
32 | input = input.replace(/\ /g,'+'); |
||
33 | if(input.indexOf('+') == 0 ){input = input.substring(1,input.length);} |
||
34 | if(input.indexOf('+') == input.length ){input = input.substring(0,input.length-1);} |
||
35 | !endif |
||
7484 | schaersvoo | 36 | show = input; |
7483 | schaersvoo | 37 | <!-- convert all unicode to wims-math ... more to come... >= <= etc--> |
11754 | schaersvoo | 38 | input = conv_uni2wims(input) |
7464 | schaersvoo | 39 | if(check_f(input) == 0){return;}; |
40 | if(check_o(input) == 0){return;}; |
||
41 | if(check_log_NaN(input) == 0){return;} |
||
42 | if(check_sqrt_NaN(input) == 0){return;}; |
||
43 | input = science(input);if(input == "error"){return;}; |
||
44 | if(check_x(input) == 0){return;}; |
||
45 | !if $convert_root=0 |
||
46 | input = arrows(input,$my_arrows,"","");if(input == "error"){return;}; |
||
7483 | schaersvoo | 47 | input = nthroot(input);if(input == "error"){return;}; |
7464 | schaersvoo | 48 | if(input.indexOf("[") !=- 1){ |
49 | if(input.indexOf("sqrt[")!=-1){ |
||
7483 | schaersvoo | 50 | input=specialroot(input);if(input == "error"){return;}; |
7464 | schaersvoo | 51 | }; |
52 | if(input.indexOf("log[")!=-1){ |
||
7483 | schaersvoo | 53 | input=speciallog(input);if(input == "error"){return;}; |
7464 | schaersvoo | 54 | }; |
55 | }; |
||
56 | !endif |
||
57 | reply[inputfieldnumber] = input;inputfieldnumber = 1; |
||
58 | }; |
||
59 | if(reply[0].length == 0 ){setAlarm(r1);return;};show = show + "</ol>"; |
||
60 | myConfirm(show,reply,'$wims_ref_name','$session','$module','$counter','$ok_send_color'); |
||
61 | } |
||
62 | //]]> |
||
63 | </script> |
||
7573 | schaersvoo | 64 | !if $(object$n) != $empty |
65 | <table class="exercise" > |
||
7464 | schaersvoo | 66 | <tr> |
7477 | schaersvoo | 67 | <td class="exercise_m"> |
7573 | schaersvoo | 68 | !endif |
69 | <table id="exercise" class="exercise" ><!-- begin table id=exercise --> |
||
70 | <tr> |
||
71 | <td class="exercise_m"> |
||
7470 | schaersvoo | 72 | !if $(question$n)!= $empty |
7464 | schaersvoo | 73 | $(question$n) |
74 | !endif |
||
75 | !if $exotext != $empty |
||
76 | <br /> |
||
77 | $exotext |
||
78 | !endif |
||
7573 | schaersvoo | 79 | <table class="exercise"> |
80 | <tr> |
||
81 | !if $(formula$n) != $empty |
||
10574 | schaersvoo | 82 | <td class="exercise_c"> |
7573 | schaersvoo | 83 | !insmath $(formula$n) |
84 | </td> |
||
85 | <td class="exercise_c"> |
||
86 | $m_rightarrow |
||
87 | </td> |
||
88 | !endif |
||
7574 | schaersvoo | 89 | <td id="math_out" style="font-size:1.1em;"></td> |
7573 | schaersvoo | 90 | </tr> |
91 | </table> |
||
7577 | schaersvoo | 92 | <textarea id="JSMathView" style="color:black;background-color:#e8ffff;border:1px solid #ff0000;width:400px;webkit-box-sizing:border-box;moz-box-sizing:border-box;box-sizing:border-box;"></textarea> |
7573 | schaersvoo | 93 | </td> |
94 | </tr> |
||
95 | <tr> |
||
12137 | schaersvoo | 96 | <td class="exercise_m"> |
11757 | schaersvoo | 97 | !if minimaal isin $mathviewpanel |
98 | !set only_first=1 |
||
99 | !else |
||
100 | !set only_first=0 |
||
101 | !endif |
||
7573 | schaersvoo | 102 | <table class="demospecial" id="show_it"> |
103 | <tr id="math_op0"> |
||
11757 | schaersvoo | 104 | !if $only_first=1 |
105 | <td onclick="javascript:change_fontsize(0.5); adapt_width();"><span style="font-size:22pt">A</span></td> |
||
106 | <td onclick="javascript:change_fontsize(-0.5); adapt_width();"><span style="font-size:4pt">A</span></td> |
||
107 | !endif |
||
11786 | schaersvoo | 108 | <td colspan="1" id="clear_it" style="font-size:100%"> |
11757 | schaersvoo | 109 | !record 67 of $remarkdir/commonremarks.$taal |
7481 | schaersvoo | 110 | </td> |
7573 | schaersvoo | 111 | <!-- contents of mathviewpanel --> |
112 | </tr> |
||
113 | <tr id="math_op1" style="display:none"> |
||
7484 | schaersvoo | 114 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7470 | schaersvoo | 115 | <td onclick="javascript:button('^');"> ^</td> |
116 | <td onclick="javascript:button('/');"> /</td> |
||
117 | <td onclick="javascript:button('*');"> *</td> |
||
118 | <td onclick="javascript:button('+');"> +</td> |
||
7483 | schaersvoo | 119 | <td onclick="javascript:button(' − ');">−</td><!-- \u2212 --> |
7470 | schaersvoo | 120 | <td onclick="javascript:button('(');"> (</td> |
121 | <td onclick="javascript:button(')');"> )</td> |
||
122 | <td onclick="javascript:button('€');">€</td> |
||
7573 | schaersvoo | 123 | </tr> |
124 | <tr id="math_op2" style="display:none"> |
||
7484 | schaersvoo | 125 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7470 | schaersvoo | 126 | <td onclick="javascript:button('√()');">√()</td> |
127 | <td onclick="javascript:button('sin()');">sin</td> |
||
128 | <td onclick="javascript:button('cos()');">cos</td> |
||
129 | <td onclick="javascript:button('tan()');">tan</td> |
||
130 | <td onclick="javascript:button('log()');">log</td> |
||
7481 | schaersvoo | 131 | <td onclick="javascript:button('asin()');">asin</td> |
132 | <td onclick="javascript:button('acos()');">acos</td> |
||
7483 | schaersvoo | 133 | <td onclick="javascript:button('pi ');">π</td> |
7573 | schaersvoo | 134 | </tr> |
135 | <tr id="math_op3" style="display:none"> |
||
7484 | schaersvoo | 136 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7483 | schaersvoo | 137 | <td onclick="javascript:button(' ∈ ');"> ∈</td><!-- in \u2208 --> |
138 | <td onclick="javascript:button(' ∉ ');">∉</td><!-- notin \u2209 --> |
||
139 | <td onclick="javascript:button(' ∧ ');"> ∧</td><!-- and \u2227 --> |
||
140 | <td onclick="javascript:button(' ∨ ');"> ∨</td><!-- or \u2228 --> |
||
141 | <td onclick="javascript:button(' ≤ ');"> ≤</td><!-- <= \u2264 --> |
||
142 | <td onclick="javascript:button(' ≥ ');"> ≥</td><!-- >= \u2265 --> |
||
10574 | schaersvoo | 143 | <td onclick="javascript:button(' ± ');"> ±</td><!-- R --> |
7470 | schaersvoo | 144 | <td onclick="javascript:button(' N ');"> N</td> |
7573 | schaersvoo | 145 | </tr> |
146 | <tr id="math_op4" style="display:none"> |
||
7484 | schaersvoo | 147 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7470 | schaersvoo | 148 | <td onclick="javascript:button('sqrt[3]()');"><sup>3</sup>√()</td> |
149 | <td onclick="javascript:button('sqrt[4]()');"><sup>4</sup>√()</td> |
||
150 | <td onclick="javascript:button('sqrt[5]()');"><sup>5</sup>√()</td> |
||
151 | <td onclick="javascript:button('sqrt[6]()');"><sup>6</sup>√()</td> |
||
152 | <td onclick="javascript:button('sqrt[7]()');"><sup>7</sup>√()</td> |
||
153 | <td onclick="javascript:button('sqrt[8]()');"><sup>8</sup>√()</td> |
||
154 | <td onclick="javascript:button('sqrt[9]()');"><sup>9</sup>√()</td> |
||
155 | <td onclick="javascript:button('sqrt[10]()');"><sup>10</sup>√()</td> |
||
7573 | schaersvoo | 156 | </tr> |
157 | <tr id="math_op5" style="display:none"> |
||
7484 | schaersvoo | 158 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7470 | schaersvoo | 159 | <td onclick="javascript:button('log[2]()');"><sup>2</sup>log()</td> |
160 | <td onclick="javascript:button('log[3]()');"><sup>3</sup>log()</td> |
||
161 | <td onclick="javascript:button('log[4]()');"><sup>4</sup>log()</td> |
||
162 | <td onclick="javascript:button('log[5]()');"><sup>5</sup>log()</td> |
||
163 | <td onclick="javascript:button('log[6]()');"><sup>6</sup>log()</td> |
||
164 | <td onclick="javascript:button('log[7]()');"><sup>7</sup>log()</td> |
||
165 | <td onclick="javascript:button('log[8]()');"><sup>8</sup>log()</td> |
||
166 | <td onclick="javascript:button('log[9]()');"><sup>9</sup>log()</td> |
||
7573 | schaersvoo | 167 | </tr> |
168 | <tr id="math_op6" style="display:none"> |
||
7484 | schaersvoo | 169 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7470 | schaersvoo | 170 | <td onclick="javascript:button('f\'(x) = ');"> f'(x) = </td> |
171 | <td onclick="javascript:button('dy/dx = ');"> dy/dx = </td> |
||
7483 | schaersvoo | 172 | <td onclick="javascript:button(' ∧ ');"> ∧</td><!-- and \u22C0 --> |
173 | <td onclick="javascript:button(' ∨ ');"> ∨</td><!-- or \u22C1 --> |
||
174 | <td onclick="javascript:button(' ≤ ');"> ≤</td><!-- <= \u2264 --> |
||
175 | <td onclick="javascript:button(' ≥ ');"> ≥</td><!-- >= \u2265 --> |
||
7470 | schaersvoo | 176 | <td onclick="javascript:button('f(x) = ');"> f(x) =</td> |
177 | <td onclick="javascript:button('F(x) = ');"> F(x) =</td> |
||
7573 | schaersvoo | 178 | </tr> |
179 | <tr id="math_op7" style="display:none"> |
||
7484 | schaersvoo | 180 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
7483 | schaersvoo | 181 | <td onclick="javascript:button(' ⇒ ');">⇒</td><!-- \u21D2 ⇒ ⇒ --> |
182 | <td onclick="javascript:button(' ⟶ ');">⟶</td><!-- \u2192 --> |
||
183 | <td onclick="javascript:button(' ↔ ');">↔</td><!-- \u2194 --> |
||
184 | <td onclick="javascript:button(' ⇔ ');">⇔</td><!-- \u21D4 --> |
||
185 | <td onclick="javascript:button(' ∑ ');">∑</td><!-- \u2211 --> |
||
186 | <td onclick="javascript:button('( \\table a,b,c;d,e,f;g,h,i) ');">matrix</td> |
||
187 | <td onclick="javascript:button(' ∞ ');">∞</td><!-- \u221E --> |
||
7499 | schaersvoo | 188 | <td onclick="javascript:button(' ∫_{a}^{b} ');">∫</td><!-- \u222B --> |
7573 | schaersvoo | 189 | </tr> |
190 | <tr id="math_op8" style="display:none"> |
||
7484 | schaersvoo | 191 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
192 | <td onclick="javascript:button(' x ∈ R ⧵ {a:b:c}');">x ∈ R \ {a:b:c}</td><!-- \u29F5 --> |
||
193 | <td onclick="javascript:button(' 〈 : 〉 ');"> 〈 : 〉 </td><!-- \u2329 : \u232A --> |
||
194 | <td onclick="javascript:button(' 〈 ');"> 〈 </td><!-- \u2329 --> |
||
195 | <td onclick="javascript:button(' 〉 ');"> 〉 </td><!-- \u232A --> |
||
196 | <td onclick="javascript:button(' [ ');"> [ </td> |
||
197 | <td onclick="javascript:button(' ] ');"> ] </td> |
||
198 | <td onclick="javascript:button(' ∞ ');">∞</td><!-- \u222B --> |
||
199 | <td onclick="javascript:button(' R Z N');">R Z N</td> |
||
7573 | schaersvoo | 200 | </tr> |
7574 | schaersvoo | 201 | <tr id="math_op9" style="display:none"> |
202 | <!-- only increase in math from user input; the math_formula should be size using wims adm/light ... --> |
||
203 | <td style="background-color:yellow" onclick="javascript:hide_button_row();"><img src="$gifdir/punt.gif" alt="wissen" /></td> |
||
204 | <td onclick="javascript:change_fontsize(0.2);"><span style="font-size:18pt">A</span></td> |
||
205 | <td onclick="javascript:change_fontsize(-0.2);"><span style="font-size:6pt">A</span></td> |
||
206 | <td></td> |
||
207 | <td></td> |
||
208 | <td></td> |
||
209 | <td></td> |
||
210 | <td></td> |
||
211 | <td></td> |
||
212 | </tr> |
||
7573 | schaersvoo | 213 | <tr id="control_1" style="display:table-row;"> |
11757 | schaersvoo | 214 | !if $only_first=0 |
215 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(1);">+ −</td> |
||
216 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(2);">sin</td> |
||
217 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(3);">∈</td> |
||
218 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(4);"><sup>3</sup>√</td> |
||
219 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(5);"><sup>3</sup>log()</td> |
||
220 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(6);">dy/dx</td> |
||
221 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(7);">⟶</td> |
||
222 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(8);">〈 : 〉</td> |
||
223 | <td style="background-color:lightgreen;" onclick="javascript:show_button_row(9);"><span style="font-size:18pt">A</span><span style="font-size:6pt">A</span></td> |
||
224 | !endif |
||
7573 | schaersvoo | 225 | </tr> |
226 | </table> |
||
227 | </td> |
||
228 | </tr> |
||
229 | </table> |
||
230 | !if $(object$n)!=$empty |
||
231 | !if $make_tr=1 |
||
232 | </tr> |
||
233 | <tr> |
||
234 | !endif |
||
235 | <td class="exercise_t"> |
||
236 | $(object$n) |
||
7470 | schaersvoo | 237 | </td> |
7464 | schaersvoo | 238 | </table> |
7573 | schaersvoo | 239 | !endif |
7464 | schaersvoo | 240 | <div id="send_buttons" class="embedded_central"> |
241 | <input type="button" id="schaersvoorde_ok_button" onclick="javascript:sendanswer();" value="$send" /> |
||
242 | <input type="button" id="schaersvoorde_nok_button" onclick="javascript:dontknow();" value="$dontknow" /> |
||
7481 | schaersvoo | 243 | !if $wims_user=supervisor |
11440 | schaersvoo | 244 | !set answer_n=!lines2items $(answer$n) |
245 | <input type="button" id="schaersvoorde_extra_button" onclick="document.getElementById('JSMathView').value = '$answer_n';doMathSrc(1);" value="$wims_firstname $wims_lastname" /> |
||
7469 | schaersvoo | 246 | !endif |
7464 | schaersvoo | 247 | </div> |
248 | <script type="text/javascript"> |
||
7574 | schaersvoo | 249 | "use strict"; |
11754 | schaersvoo | 250 | var uni2wims = { |
251 | '\u00B1':' pm ', |
||
252 | '\u2227':' and ', |
||
253 | '\u2228':' or ', |
||
254 | '\u2264':' <= ', |
||
255 | '\u2265':' >= ', |
||
256 | '\u2212':'-', |
||
257 | '\u221A':' sqrt ', |
||
258 | '\u20AC':' euro ', |
||
259 | '\u03C0':' pi ', |
||
260 | '\u2208':' in ', |
||
261 | '\u2209':' notin ', |
||
262 | '\u21d0':' <= ', |
||
263 | '\u21D2':' => ', |
||
264 | '\u27F6':' --> ', |
||
265 | '\u2190':' <- ', |
||
266 | '\u2192':' -> ', |
||
267 | '\u2194':' <-> ', |
||
268 | '\u21D4':' <=> ', |
||
269 | '\u2211':' SUM ', |
||
270 | '\u221E':' inf ', |
||
271 | '\u222B':' int ', |
||
272 | '\u2329':' langle ', |
||
273 | '\u232A':' rangle ', |
||
274 | '\u2203':' exist ', |
||
275 | '\u2200':' forall ', |
||
276 | '\u00ac':' not ', |
||
277 | '\u22a4':' true ', |
||
278 | '\u22a5':' false ', |
||
279 | '\u2254':' equiv ', |
||
280 | '\u2261':' defined ', |
||
281 | '\u22a2':' proved ', |
||
282 | '\u22a8':' entails ', |
||
283 | '\u222a':' union ', |
||
284 | '\u2282':' subset ', |
||
285 | '\u2229':' intersection ', |
||
286 | '\u2204':' notexist ', |
||
12130 | schaersvoo | 287 | '\u2295':' xor ', |
12096 | schaersvoo | 288 | '\u2205':' empty ', |
11754 | schaersvoo | 289 | '\u29F5':' \ ', |
12137 | schaersvoo | 290 | '\uFF1A':' : ', |
11754 | schaersvoo | 291 | '\u2234':' therefore ', |
292 | '\u2235':' because '}; |
||
293 | |||
294 | |||
295 | function conv_uni2wims(input){ |
||
296 | for(var p in uni2wims){ |
||
297 | input = input.split(p).join(' '+uni2wims[p]); |
||
298 | }; |
||
299 | return input; |
||
300 | }; |
||
301 | function conv_wims2uni(u){ |
||
302 | for(var p in uni2wims){ |
||
303 | if( uni2wims[p] == u ){ |
||
304 | return p; |
||
305 | } |
||
306 | } |
||
307 | return u; |
||
308 | }; |
||
11786 | schaersvoo | 309 | var lang="$lang" || "$taal"; |
11758 | schaersvoo | 310 | var num_button_tabs = 8;var JSMathView = document.getElementById("JSMathView");var show_it = document.getElementById("show_it");var clear_it = document.getElementById("clear_it");var math_out = document.getElementById("math_out");var math_font_size = 1.1;var my_wims_mathml=document.getElementsByTagName('math');var my_mathml_len = my_wims_mathml.length; |
7577 | schaersvoo | 311 | /* wims variable mathviewpanel something like 'module_title:sqrt():sin():f(x):F(x)" */ |
11787 | schaersvoo | 312 | var mathviewpanel ="$mathviewpanel";mathviewpanel = mathviewpanel.split(':');if(mathviewpanel.length > 1){ var opt = document.getElementById('math_op0');for(var i=1; i<= num_button_tabs ;i++){if(mathviewpanel[i]){(function(){var paneltxt = conv_wims2uni(mathviewpanel[i]) ;var td = document.createElement('td');var id = i-1;td.setAttribute('id','mypanel'+id);opt.appendChild(td);td.addEventListener('click',function(e){ button(paneltxt);},false);td.innerHTML = paneltxt;}());};};}; |
7577 | schaersvoo | 313 | function show_button_row(row){hide_button_row();document.getElementById("math_op"+row).style.display = 'table-row';adapt_width();}; |
314 | function hide_button_row(){var i=1;while(document.getElementById("math_op"+i)){document.getElementById("math_op"+i).style.display = 'none';i++};adapt_width()}; |
||
315 | function displayroot(t){var power;var sqrt;var begin;var end;var mod;var tot;var wait;var got;var chr;var t1;var t2;var t3;var t4;var test;var org;t2=t.indexOf("](");if(t2==-1){return;};org=t;t=t.replace(/sqrt\(/g,"SQRT(");t=t.replace(/log\[/g,"LOG~");t=t.replace(/sqrt\[/g,"@[");test=t.replace(/[a-z]\[/g,"#");if(test.indexOf("#")!=-1){return;};t2=t.indexOf("[");var trouble=0;while(t2 != -1){begin=t.indexOf("@");t2=t.indexOf("[");t3=t.indexOf("]");if(t2==begin+1 && t3>t2){power=t.substring(t2+1,t3);if(power.length==0){return t;};if(power<2){return;}t4="["+power+"]";t=t.replace(t4,'');tot=t.length;wait=0;got=0;end=0;for(var s=begin;s<tot;s++){if(end==0){chr=t.charAt(s);if(chr=="("){wait=wait+1;};if(chr==")"){got=got+1;};if(got!=0){if(wait==got){end=s;}}}};begin=begin+2;sqrt=t.substring(begin,end);mod=(power % 2);if(sqrt<0 && mod!=1){return;};t=t.replace("@("+sqrt+")","{^"+power+"√#"+sqrt+"!}");}else{t=t.replace("]","?");}trouble++;if(trouble>100){setAlarm(r20);t="error";return t;}};t=t.replace(/SQRT\(/g,"√#");t=t.replace(/LOG~/g,"log[");t=t.replace(/~/g,"[");t=t.replace(/\?/g,"]");t=t.replace(/@/g,"√");return t;} |
||
11786 | schaersvoo | 316 | function displayfun(t,fun,alias){var cnt=0;var chk = [];var ti = t.indexOf(fun);while( ti !=-1 ){ var to = t.indexOf(fun+'[');t = t.replace(fun,"@");;if( to < ti+3 ){ chk.push(cnt);}else{chk.push(-1);};ti = t.indexOf(fun);cnt++;};var idx=null;var tot=t.length;var wait=0;var got=0;var end=0;var arg;var begin;var s1;var s2;var chr;var found;var i;var ii;var idx;for(var p=0 ; p < cnt; p++ ){tot = t.length;idx=null;begin = t.indexOf('@');i=t.indexOf('[');if( chk[p] != -1 ){ii=t.indexOf(']');idx=t.substring(i+1,ii);s1 = t.substring(0,i);s2 = t.substring(ii+1,tot);t=s1+s2;};found=false;wait=0;got=0;for(var s = begin; s < tot && found==false; s++){chr = t.charAt(s);if(chr == "("){wait = wait + 1;};if(chr == ")"){got = got + 1;};if(got != 0){ if( wait == got ){ end = s;found = true;};};};begin=begin+2;arg=t.substring(begin,end);if(idx != null ){if(lang == "fr" ){t = t.replace("@("+arg+")","{"+alias+"_{"+idx+"}#"+arg+"!}");}else{t = t.replace("@("+arg+")","{^{"+idx+"}"+alias+"#"+arg+"!}");};}else{t = t.replace("@("+arg+")","{"+alias+"#"+arg+"!}");};};return t;}; |
7482 | schaersvoo | 317 | function button(myValue){if(document.selection){JSMathView.focus();var sel = document.selection.createRange();sel.text = myValue;}else{ if(JSMathView.selectionStart || JSMathView.selectionStart == '0'){var startPos = JSMathView.selectionStart;var endPos = JSMathView.selectionEnd;JSMathView.value = JSMathView.value.substring(0, startPos) + myValue + JSMathView.value.substring(endPos,JSMathView.value.length);} else {JSMathView.value += myValue;};};if(myValue.indexOf('()') != -1){JSMathView.setSelectionRange(startPos+myValue.length - 1,startPos+myValue.length - 1);};}; |
11790 | schaersvoo | 318 | function change_fontsize(t){math_font_size = math_font_size+t;math_out.setAttribute('style','font-size:'+math_font_size+'em');for(var i=0 ; i < num_button_tabs; i++){;if(document.getElementById('mypanel'+i)){ document.getElementById('mypanel'+i).setAttribute('style','font-size:'+math_font_size+'em');};};JSMathView.setAttribute('style','font-size:'+math_font_size+'em');for(var i=0 ;i < my_wims_mathml.length; i++){ my_wims_mathml[i].setAttribute('mathsize',math_font_size+'em');};adapt_width();}; |
11884 | schaersvoo | 319 | function rewrite(input){if(input.indexOf("sqrt[") != -1){ input = displayroot(input);};var rep1 = ["sqrt(","pi",">=","<="," and "," or "," isin "," in "," notin "," R "," N ","dy","dx","\ ","dv","dt"];var rep2 = ["√(","\\pi","\\ge "," \\le "," \\wedge "," \\vee "," \\in "," \\in "," \\notin ","\\R","\\N","\\dy","\\dx","\\;","\\dv","\\dt"];for(var i=0; i < rep1.length ; i++){input = input.split(rep1[i]).join(rep2[i]);};var math = ["asin","acos","atan","sqrt","sin","tan","log","cos"];var rep_math = ["\\asin","\\acos","\\atan","\\sqrt","\\sin","\\tan","\\log","\\cos"];var subst=["|A|","|B|","|C|","|D|","|E|","|F|","|G|","|H|","|K|","|L|","|M|","|N|","|O|","|P|","|Q|","|R|"];var repindex=[16];var mathindex=[16];var idx;var found=false;for(var i=0;i < math.length ; i++){idx = input.indexOf(math[i]);while( idx != -1 ){found=true;repindex.push(subst[i]);mathindex.push(rep_math[i]);input = input.replace(math[i],subst[i]);idx = input.indexOf(math[i]);};};if( found ){for(var i=0;i < repindex.length ; i++){input = displayfun(input,repindex[i],mathindex[i]);};};input=input.replace(/#/g,'(');input=input.replace(/!/g,')');return input;}var ents_ = { nwarr: '\u2196', swarr: '\u2199' };show_it.addEventListener('click',function(e){doMathSrc(1);},false);clear_it.addEventListener('click',function(e){JSMathView.value=" ";doMathSrc(1);return;},false);JSMathView.addEventListener('keyup',function(e){doMathSrc(1);},false);var ents_ = { nwarr: '\u2196', swarr: '\u2199' }; |
11786 | schaersvoo | 320 | function doMathSrc(n){var org = JSMathView.value;var ms = rewrite(org);if(ms.indexOf('@')!= -1){return;};if(!ms){return;}; ms = ms.replace(/&([-#.\w]+);|\\([a-z]+)(?: |(?=[^a-z]))/ig,function(s, e, m){if (m && (M.macros_[m] || M.macro1s_[m])){ return s;};var t = '&'+(e || m)+';', res = $$('<span>'+t+'</span>').text();return res != t ? res : ents_[e || m] || s;});var t; try { math_out.removeChild(math_out.childNodes[0]); } catch(e){};try { t = M.sToMathE(ms, true); math_out.appendChild(t);} catch(e) { setAlarm(e+"<br />"+org); };JSMathView.focus();JSMathView.value=org;}; |
11790 | schaersvoo | 321 | function adapt_width(){try{var inp_width=document.getElementById('control_1').offsetWidth;JSMathView.style.width = inp_width+'px';} catch(e){};}; |
7582 | schaersvoo | 322 | adapt_width(); |
7464 | schaersvoo | 323 | </script> |
324 | |||
325 | |||
11754 | schaersvoo | 326 | !! # 3/6/2016 : added " pm " as option: y = ± 5*t |
327 | !! # 7/7/2017 : added more unitcode <-> wims [for logic module] |
||
11786 | schaersvoo | 328 | !! # 24/7/2017: rewrite "latexing" of function... log(...) -> { \log(...) } log[3](...) -> {^{3}\log(...)} or in case lang=fr {\log_{3}(...)} |