[LON-CAPA-cvs] cvs: loncom /html/adm/dragmath/applet EditMathPopup.html
foxr
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 01 Jul 2008 11:02:50 -0000
foxr Tue Jul 1 07:02:50 2008 EDT
Modified files:
/loncom/html/adm/dragmath/applet EditMathPopup.html
Log:
BZ 5744 - Get this to work as a generic inserter of dragmath
rendedred as latex into a textarea form field.
Index: loncom/html/adm/dragmath/applet/EditMathPopup.html
diff -u loncom/html/adm/dragmath/applet/EditMathPopup.html:1.1 loncom/html/adm/dragmath/applet/EditMathPopup.html:1.2
--- loncom/html/adm/dragmath/applet/EditMathPopup.html:1.1 Tue Jul 1 05:12:33 2008
+++ loncom/html/adm/dragmath/applet/EditMathPopup.html Tue Jul 1 07:02:49 2008
@@ -2,32 +2,42 @@
<html>
<head>
-<title>DragMath Latex Example</title>
+<title>DragMath Equation Editor</title>
<script>
+function insertAtCursor(doc, myField, myValue) {
+ //IE support
+ if (doc.selection) {
+ myField.focus();
+ sel = doc.selection.createRange();
+ sel.text = myValue;
+ }
+ //MOZILLA/NETSCAPE support
+ else if (myField.selectionStart || myField.selectionStart == '0') {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ myField.value = myField.value.substring(0, startPos)
+ + myValue + '\n\n'
+ + myField.value.substring(endPos, myField.value.length);
+ } else {
+ myField.value += myValue;
+ }
+ }
+
function renderLatex() {
var ans = document.DragMath.getMathExpression();
- var source = '<html>'
- + '<body>'
- + '<h4>Latex Syntax: '
- + ans
- + '</h4>'
- + '<applet code="HotEqn.class" codebase="HotEqn" archive="HotEqn.jar" height="300" width="600" name="my equation">'
- + '<param name="equation" value="'
+ var source = '<m>$'
+ ans
- + '"/>'
- + '</applet>'
- + '</body>'
- + '</html>'
- + '';
-
- var target = document.getElementById('outputID');
- var doc = target.contentDocument;
- if (doc == undefined || doc == null)
- doc = target.contentWindow.document;
- doc.open();
- doc.write(source);
- doc.close();
+ + '$</m>';
+
+// var target = document.getElementById('outputID');
+// var doc = target.contentDocument;
+
+ var doc = opener.targetDoc
+ var target = doc.getElementById(opener.targetEntry);
+ insertAtCursor(doc, target, source);
+
+ window.close();
}
@@ -40,7 +50,7 @@
<DIV align=left><FONT face=Arial color=#000080
-size=6><STRONG>DragMath Latex Example</STRONG></FONT></DIV>
+size=6><STRONG>DragMath Latex Equation Editor</STRONG></FONT></DIV>
<br><br>
<applet name="DragMath" codebase="classes" code="Display.MainApplet.class" archive="Project.jar,AbsoluteLayout.jar,swing-layout-1.0.jar,jdom.jar,jep.jar" width=540 height=333>
@@ -55,13 +65,5 @@
<input type='button' value='Render Latex' onclick='renderLatex(); return true;' />
</form>
-<H2>Latex Rendering:</H2>
-
-<iframe id='outputID' src='' width='98%' height='150'>
-</iframe>
-
-</div>
-<br>
-Latex rendering performed by freeware Java applet <a href="http://www.atp.ruhr-uni-bochum.de/VCLab/software/HotEqn/HotEqn.html">HotEqn </a>
</body>
</html>