/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the"License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an"AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Mozilla MathML Project. * * The Initial Developer of the Original Code is The University Of * Queensland. Portions created by The University Of Queensland are * Copyright (C) 2002 The University Of Queensland. All Rights Reserved. * * Contributor(s): * Roger B. Sidje * Steve Swanson * */ var gDebug = 0; var gLineCount = 0; var gStartTargetLine = 0; var gEndTargetLine = 0; var gTargetNode = null; var gWYSIWYGWindow = null; // had to use an absolute path here, otherwise Mozilla is confused when the // script is loaded from a directory different from where the CSS resides var gViewSourceCSS = 'http://www.mozilla.org/projects/mathml/demo/viewsource.css'; function viewmath(evt) { evt.preventBubble(); gLineCount = 0; gStartTargetLine = 0; gEndTargetLine = 0; gTargetNode = evt.target; if (gTargetNode.nodeType == Node.TEXT_NODE) { // leaf text gTargetNode = gTargetNode.parentNode; } var m = findmathparent(evt.target); if (m) { gWYSIWYGWindow = open("", "wysiwyg", "scrollbars=1,resizable=1,width=500,height=200"); gWYSIWYGWindow.document.open(); with (gWYSIWYGWindow.document) { writeln(''); writeln('MathML WYSIWYG Source'); writeln(''); writeln(''); writeln(''); writeln(''); write(''); //if wrapping... write(''); write('
');
      writeln(getOuterMarkup(m,0));
      writeln('
'); } gWYSIWYGWindow.document.close(); } } function findmathparent(node) { while (node && node.nodeName.indexOf("math") == -1) node = node.parentNode; return node; } function getInnerMarkup(n, indent) { var str = ''; for (var i = 0; i... newline = ''; if (gLineCount > 0) { newline = '\n'; } if (gLineCount == gStartTargetLine || gLineCount == gEndTargetLine) { newline = ''; } gLineCount++; if (gDebug) { newline += gLineCount; } for (var k=0; k' + n.nodeName + ''; for (var i=0; i' + n.nodeName + '>'; break; case Node.TEXT_NODE: // Text var tmp = n.nodeValue; tmp = tmp.toString(); tmp = tmp.replace(/(\n|\r|\t)+/g, " "); tmp = tmp.replace(/\s+/," "); tmp = tmp.replace(/^\s+/, ""); tmp = tmp.replace(/\s+$/,""); if (tmp.length != 0) { str += '' + unicode2entity(tmp) + ''; } break; default: break; } if (n == gTargetNode) { gEndTargetLine = gLineCount; str += '
';
  }
  return str;
}