From: dpvc v. a. <we...@ma...> - 2008-08-27 12:05:59
|
Log Message: ----------- BACKPORT: changes from version 1.8 (in particular,include the \verb command). Tags: ---- rel-2-4-patches Modified Files: -------------- webwork-modperl/htdocs/jsMath: jsMath-ww.js Revision Data ------------- Index: jsMath-ww.js =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/htdocs/jsMath/jsMath-ww.js,v retrieving revision 1.6.2.1.2.1 retrieving revision 1.6.2.1.2.2 diff -Lhtdocs/jsMath/jsMath-ww.js -Lhtdocs/jsMath/jsMath-ww.js -u -r1.6.2.1.2.1 -r1.6.2.1.2.2 --- htdocs/jsMath/jsMath-ww.js +++ htdocs/jsMath/jsMath-ww.js @@ -9,18 +9,22 @@ */ var jsMath = { + styles: { '.math': 'font-family: serif; font-style: normal; color: grey; font-size: 75%' }, Controls: {cookie: {scale: 133}}, Parser: {prototype: {macros: { - lt: ['Macro','<'], - gt: ['Macro','>'], setlength: ['Macro','',2], - boldsymbol: ['Macro','{\\bf #1}',1] + boldsymbol: ['Macro','{\\bf #1}',1], + verb: ['Extension','verb'] }}}, Font: {}, + // + // Look for jsMath-ww.js file and replace by jsMath.js + // Cause the jsMath.js file to be loaded + // wwSource: function () { var script = document.getElementsByTagName('SCRIPT'); var src = script[script.length-1].getAttribute('SRC'); @@ -34,15 +38,32 @@ wwProcess: function () { if (this.wwCount > 1) return; - var onload = (this.wwCount? this.wwProcessMultiple: this.wwProcessSingle); - if (window.addEventListener) {window.addEventListener("load",onload,false)} - else if (window.attachEvent) {window.attachEvent("onload",onload)} - else {window.onload = onload} + if (this.wwCount == 0) { + // + // This is the first call to jsMath, so install handler + // + if (window.addEventListener) {window.addEventListener("load",jsMath.wwOnLoad,false)} + else if (window.attachEvent) {window.attachEvent("onload",jsMath.wwOnLoad)} + else {window.onload = jsMath.wwOnLoad} + // + // Process the page synchronously + // + this.wwProcessWW = jsMath.ProcessBeforeShowing; + } else { + // + // There are multiple calls, so we're in the Library Browser + // Process the page asynchronously + // + this.wwProcessWW = jsMath.Process; + } this.wwCount++; }, - wwProcessSingle: function () {jsMath.ProcessBeforeShowing()}, - wwProcessMultiple: function () {jsMath.Process()} + // + // The actual onload handler calls whichever of the two + // processing commands has been saved + // + wwOnLoad: function () {jsMath.wwProcessWW()} }; @@ -50,12 +71,14 @@ if (window.missingFontMessage) {jsMath.Font.message = missingFontMessage} if (!window.processDoubleClicks) {jsMath.Click = {CheckDblClick: function () {}}} - // Load actual jsMath code + // + // Load jsMath.js + // jsMath.wwSource(); // - // Make sure answer boxes are above jsMath output (avoids deep - // baselines in jsMath fonts) + // Make sure answer boxes are above jsMath output + // (avoids deep baselines in jsMath fonts) // document.write('<STYLE> .problem INPUT, .problem TEXTAREA {position: relative; z-index: 2} </STYLE>'); |