6 | Part of the jsMath package for mathematics on the web.
8 | This file handles the details of the jsMath control panels
10 | ---------------------------------------------------------------------
12 | Copyright 2004-2007 by Davide P. Cervone
14 | Licensed under the Apache License, Version 2.0 (the "License");
15 | you may not use this file except in compliance with the License.
16 | You may obtain a copy of the License at
18 | http://www.apache.org/licenses/LICENSE-2.0
20 | Unless required by applicable law or agreed to in writing, software
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
31 var domain = document.domain || "";
32 var mustPost = ((domain == "" || domain == "localhost") && window.postMessage);
33 while (!window.jsMath && !showWarning) {
35 window.jsMath = window.parent.jsMath;
36 if (!window.jsMath) {throw "no jsMath";}
38 showWarning = 1; pageDomain = '';
39 try {pageDomain = document.domain} catch (err) {}
41 // MSIE on Mac can't change document.domain, and 'try' won't
42 // catch the error (Grrr!) so don't even attempt it.
44 if (pageDomain.match(/\..*\./) &&
45 (navigator.appName != 'Microsoft Internet Explorer' ||
46 !navigator.platform.match(/Mac/) || !navigator.userProfile || !document.all)) {
48 document.domain = pageDomain.replace(/^[^.]*\./,'');
57 "jsMath can't open the control panel, since jsMath was not " +
58 "obtained from a server that is in the same domain as the " +
59 "page that loaded it."
64 if (!mustPost) setTimeout("Warning()",1);
66 var debug = window.parent.debug;
67 var show = window.parent.show;
71 <SCRIPT ID="jsMath_script">
74 jsMath.Add(jsMath.Controls,{
79 print: 'Print', reload: 'Reload', local: 'Go Local', global: 'Go Global',
80 ctrls: 'Controls', opts: 'Options', done: 'Done'
82 optionLabels: {back: 'Back', done: 'Done'},
85 this.panel.style.display = "none";
86 jsMath.Element("button").style.display = (this.cookie.button ? "block" : "none");
87 if (jsMath.document.location.protocol == 'file:' && jsMath.Global.islocal) return;
88 for (var id in {scale:1, scaleImg:1, font:1, print:1, printwarn:1,
89 stayhires:1, autofont:1, alpha:1, tex2math:1, global:1}) {
90 if (this.cookie[id] && this.cookie[id] != this.oldCookie[id] &&
91 this.oldCookie[id] != null) {
99 this.oldCookie = {}; jsMath.Add(this.oldCookie,this.cookie);
100 this.GetPanel("main");
102 jsMath.Element("_version").innerHTML = jsMath.version;
104 jsMath.Element("_fontType").innerHTML =
107 symbol:"Image symbol",
108 unicode:"Unicode"})[this.cookie.font];
110 jsMath.Element("_mailto").href =
111 "mailto:dpvc@union.edu?subject=Bug Report for jsMath "
112 + jsMath.version + " (using " + jsMath.browser
113 + " in " + this.cookie.font + " mode)";
115 if (this.cookie.print ||
116 (this.cookie.font != 'image' && this.cookie.font != 'symbol'))
117 {jsMath.Element("_resolution").disabled = true}
119 if (jsMath.Global.isLocal) {
120 jsMath.Element("_ctrls").disabled = true;
122 this.cookie.hiddenGlobal = jsMath.Global.isHidden;
123 jsMath.Element("_global").style.display = "none";
124 jsMath.Element("_local").style.display = "";
125 if (!jsMath.Global.isHidden || jsMath.noShowGlobal)
126 {jsMath.Element("_ctrls").disabled = true}
128 if (jsMath.noChangeGlobal) {
129 for (var id in {global:1, local:1, ctrls: 1})
130 {jsMath.Element('_'+id).disabled = true}
132 if (!window.print) {jsMath.Element("_print").disabled = true}
134 if (jsMath.Browser.safariButtonBug) {
135 for (var id in this.mainLabels)
136 {jsMath.Element('_'+id).value = this.mainLabels[id]}
139 this.panel.style.display = "block";
143 Options: function () {
144 this.GetPanel("options");
145 jsMath.Element("_scale").value = this.cookie.scale;
146 jsMath.Element("_keep").value = this.cookie.keep;
147 jsMath.Element("_global").value = this.cookie.global;
148 for (var id in {autofont:1, scaleImg:1, alpha:1, warn:1, printwarn: 1,
149 stayhires: 1, button:1, progress:1, asynch:1, blank:1, tex2math:1}) {
150 if (this.cookie[id]) {jsMath.Element('_'+id).checked = true}
152 var font = jsMath.document.getElementsByName("jsMath__font");
153 for (var i = 0; i < font.length; i++) {
154 if ((font[i].value == 'tex' && jsMath.nofonts) ||
155 ((font[i].value == 'symbol' || font[i].value == 'image') &&
156 jsMath.noImgFonts)) {
157 jsMath.Element('_'+font[i].value+"Text").className = "disabled";
158 font[i].disabled = true;
160 else if (this.cookie.font == font[i].value) {font[i].checked = true}
162 if (jsMath.noImgFonts) {
163 for (var id in {alpha:1, printwarn:1, stayhires:1}) {
164 var obj = jsMath.Element("_"+id);
166 obj.parentNode.className = "disabled";
168 } else if (jsMath.Browser.imgScale != 1) {
169 jsMath.Element("_alphaText").className = "disabled";
170 jsMath.Element("_alpha").disabled = true;
172 if (jsMath.tex2math.Convert) {
173 jsMath.Element("_separator").style.display = '';
174 jsMath.Element("_tex2mathRow").style.display = '';
176 if (jsMath.noChangeGlobal) {
177 jsMath.Element("_globalText").className = "disabled";
178 jsMath.Element("_global").disabled = true;
180 if (jsMath.isCHMmode) {
181 jsMath.Element("_asynchText").className = "disabled";
182 jsMath.Element("_asynch").disabled = true;
185 if (jsMath.Browser.safariButtonBug) {
186 for (var id in this.optionLabels)
187 {jsMath.Element('_'+id).value = this.optionLabels[id]}
190 this.panel.style.display = "block";
192 if (jsMath.Browser.msieMoveButtonHack) {
193 this.panel.style.left = "0px";
194 this.panel.style.top = "0px";
195 jsMath.Controls.MoveButton();
199 HTML: {}, // storage for panels for Firefox3 in local mode
201 GetPanel: function (name) {
202 this.panel.innerHTML = ""; // for MSIE on the Mac
203 var html = this.HTML[name];
204 if (html == null) {html = document.getElementById("jsMath_"+name).innerHTML}
205 this.panel.innerHTML = html;
208 SaveOptions: function (close) {
209 this.cookie.scale = jsMath.Element("_scale").value;
210 var font = jsMath.document.getElementsByName("jsMath__font");
211 for (var i = 0; i < font.length; i++)
212 {if (font[i].checked) {this.cookie.font = font[i].value}}
213 for (var id in {autofont:1, scaleImg:1, alpha:1, warn:1, printwarn: 1,
214 stayhires: 1, button:1, progress:1, asynch:1, blank:1, tex2math:1}) {
215 if (this.cookie[id] != null) {
216 this.cookie[id] = jsMath.Element('_'+id).checked ? 1: 0;
219 this.cookie.keep = jsMath.Element("_keep").value;
220 this.cookie.global = jsMath.Element("_global").value;
221 this.cookie.print = this.cookie.stayhires;
223 if (close) {this.Close()} else {this.Main()}
226 PrintResolution: function () {
227 this.cookie.print = 1;
234 jsMath.window.print();
237 GoGlobal: function () {
238 this.cookie.global = "always";
239 jsMath.Global.GoGlobal(this.SetCookie(2));
241 GoLocal: function () {jsMath.Global.GoLocal()},
243 ShowControls: function () {
245 jsMath.Global.Show();
248 NoAuto: function () {jsMath.Element("_autofont").checked = false}
252 jsMath.Add(jsMath.Post.Commands,{
253 PAN: function (message) {jsMath.Controls.HTML.main = message},
254 OPT: function (message) {jsMath.Controls.HTML.options = message},
256 PST: function (message) {
257 jsMath.Controls.Main();
258 jsMath.Script.endLoad();
259 jsMath.Message.doClear();
266 <!------------------------------------------------------------>
268 <div id="jsMath_main">
269 <div style="text-align:center">
270 <b style="font-size:133%">jsMath v<span ID="jsMath__version"></span></b>
271 (<span id="jsMath__fontType">type</span> fonts)
272 [<a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/main.html">help</a>]
273 <p style="margin-bottom:0px">
274 <table border="0" cellspacing="0" cellpadding="0" style="margin:0px">
275 <tr valign="middle"><td align="center">
276 <table border="0" cellspacing="0" cellpadding="0">
277 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/quickstart.html">Quick Start</a></td></tr>
278 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/fonts.html">Missing Fonts</a></td></tr>
279 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/printing.html">Printing Issues</a></td></tr>
280 <tr><td height="5"></td></tr>
281 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath">Home Page</a></td></tr>
282 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/">Documentation</a></td></tr>
283 <tr><td class="infoLink" align="left">• <a target="_blank" href="https://sourceforge.net/forum/?group_id=172663">User Community</a></td></tr>
284 <tr><td height="5"></td></tr>
285 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/bugs.html">Known Bugs</a></td></tr>
286 <tr><td class="infoLink" align="left">• <a id="jsMath__mailto" href="mailto:dpvc@union.edu?subject=jsMath Bug Report">Report a Bug</a></td></tr>
287 <tr><td height="5"></td></tr>
288 <tr><td class="infoLink" align="left">• <a target="_blank" href="http://www.math.union.edu/locate/jsMath/jsMath/COPYING.txt">License</a></td></tr>
292 <td style="width:1em"> </td>
295 <table border="0" cellspacing="0" cellpadding="0">
296 <tr><td align="center" colspan="3">
297 <input type="button" id="jsMath__resolution" value="Hi-Res Fonts for Printing"
298 style="width:18em" onclick="jsMath.Controls.PrintResolution()" />
301 <tr><td height="8"></td></tr>
303 <tr valign="bottom"><td align="left">
304 <input type="button" value="Print" id="jsMath__print" style="width:8em" onclick="jsMath.Controls.Print()" /><br />
305 <input type="button" value="Reload" id="jsMath__reload" style="width:8em" style="width:8em" onclick="jsMath.window.location.reload()" /><br />
308 </td><td align="right">
309 <input type="button" value="Go Global" id="jsMath__global" style="width:8em" onclick="jsMath.Controls.GoGlobal()"a /><!--
310 --><input type="button" value="Go Local" id="jsMath__local" style="width:8em;display:none" onclick="jsMath.Controls.GoLocal()" /><br />
311 <input type="button" value="Controls" id="jsMath__ctrls" style="width:8em" onclick="jsMath.Controls.ShowControls()" /><br/>
314 <tr><td height="8"></td></tr>
316 <tr valign="bottom"><td align="left">
317 <input type="button" value="Options" id="jsMath__opts" style="width:8em" onclick="jsMath.Controls.Options()" /><br/>
320 </td><td align="right">
321 <input type="button" value="Done" id="jsMath__done" style="width:8em" onclick="jsMath.Controls.Close()" />
325 <tr><td height="10"></td></tr>
328 <td colspan="3" align="center" style="width:26em">
329 <i style="font-size:75%">Click the jsMath button or <nobr>ALT-click</nobr>
330 on mathematics to reopen this panel.</i>
337 <!------------------------------------------------------------>
339 <div id="jsMath_options">
340 <div style="text-align:center">
341 <b style="font-size:133%">jsMath Options</b>
342 [<a target="_blank" href="http://www.math.union.edu/locate/jsMath/users/help.html">help</a>]
344 <form action="javascript:" style="margin:0px">
345 <table border="0" cellspacing="0" cellpadding="0">
346 <tr valign="top"><td>
348 <table border="0" cellspacing="0" cellpadding="0" style="text-align:left">
350 <tr><td><input type="checkbox" id="jsMath__autofont" value="1" /> Autoselect best font</td></tr>
351 <tr><td><input type="checkbox" id="jsMath__warn" value="1" /> Show font warnings</td></tr>
352 <tr><td><input type="checkbox" id="jsMath__alpha" value="1" /> Use image alpha channels</td></tr>
353 <tr><td><input type="checkbox" id="jsMath__printwarn" value="1" /> Print image-font help</td></tr>
354 <tr><td><input type="checkbox" id="jsMath__stayhires" value="1" /> Always use hi-res fonts</td></tr>
356 <tr><td style="height:.8em"></td></tr>
358 <tr><td><input type="checkbox" id="jsMath__progress" value="1" /> Show progress messages</td></tr>
359 <tr><td><input type="checkbox" id="jsMath__asynch" value="1" /> <span id="jsMath__asynchText">Force asynchronous processing</span></td></tr>
360 <tr><td><input type="checkbox" id="jsMath__blank" value="1" /> Don't show page until complete</td></tr>
361 <tr><td><input type="checkbox" id="jsMath__button" value="1" /> Show jsMath button</td></tr>
363 <tr id="jsMath__separator" style="display:none"><td style="height:.8em"></td></tr>
365 <tr id="jsMath__tex2mathRow" style="display:none"><td><input type="checkbox" id="jsMath__tex2math" value="1" /> Enable <code>tex2math</code> plug-in</td></tr>
370 <td style="width:2em"></td>
373 <table border="0" cellspacing="0" cellpadding="0" style="text-align:left">
374 <tr><td>Scale all mathematics to <input type="text" id="jsMath__scale" value="100" size="3" />%</td></tr>
376 <tr><td style="height:.5em"></td></tr>
378 <tr><td><input type="radio" name="jsMath__font" value="tex" onclick="jsMath.Controls.NoAuto()" />
379 <span id="jsMath__texText">Use native TeX fonts</span>
380 <small>(<a target="_blank" href="http://www.math.union.edu/locate/jsMath/download/jsMath-fonts.html">download</a>)</small>
382 <tr><td><input type="radio" name="jsMath__font" value="image" onclick="jsMath.Controls.NoAuto()" />
383 <span id="jsMath__imageText">Use image fonts
384 <span id="jsMath__scaleImgText">(<input type="checkbox" id="jsMath__scaleImg" value="1" /> scalable)</span></span></td></tr>
385 <tr><td><input type="radio" name="jsMath__font" value="symbol" onclick="jsMath.Controls.NoAuto()" />
386 <span id="jsMath__symbolText">Use images for symbols only</span></td></tr>
387 <tr><td height="2"></td></tr>
388 <tr><td><input type="radio" name="jsMath__font" value="unicode" onclick="jsMath.Controls.NoAuto()" />
389 Use native Unicode fonts</td></tr>
391 <tr><td style="height:1em"></td></tr>
393 <tr><td align="center"><span id="jsMath__globalText">Use Global mode</span>
394 <select id="jsMath__global">
395 <option value="auto">when requested
396 <option value="always">always
397 <option value="never">never
400 <tr><td height="3"></td></tr>
401 <tr><td>Save settings for
402 <select id="jsMath__keep">
403 <option value="0D">this session only
404 <option value="1D">1 day
405 <option value="2D">2 days
406 <option value="3D">3 days
407 <option value="1W">1 week
408 <option value="2W">2 weeks
409 <option value="1M">1 month
410 <option value="2M">2 months
411 <option value="3M">3 months
412 <option value="6M">6 months
413 <option value="1Y">1 year
414 <option value="5Y">5 years
418 <tr><td style="height:1em"></td></tr>
422 <table border="0" cellspacing="0" cellpadding="0" width="100%">
424 <td align="left">
425 <input type="button" value="Back" id="jsMath__back" style="width:8em" onclick="jsMath.Controls.SaveOptions(0)" />
429 <input type="button" value="Done" id="jsMath__done" style="width:8em" onclick="jsMath.Controls.SaveOptions(1)" />
443 <!------------------------------------------------------------>
448 var scr = document.getElementById("jsMath_script");
449 window.parent.postMessage("jsMCP:SCR:"+scr.innerHTML,"*");
450 var main = document.getElementById("jsMath_main");
451 window.parent.postMessage("jsMCP:PAN:"+main.innerHTML,"*");
452 var options = document.getElementById("jsMath_options");
453 window.parent.postMessage("jsMCP:OPT:"+options.innerHTML,"*");
454 window.parent.postMessage("jsMCP:PST:","*");
457 jsMath.Controls.Main()
462 jsMath.Script.endLoad();
463 jsMath.Message.doClear();