+ -- and should be called that, but methods specific to IE should
+ -- be a part of the InternetExplorer.prototype, we won't trample on
+ -- namespace that way.
+ --
+ -- $HeadURL: http://svn.xinha.python-hosting.com/trunk/modules/InternetExplorer/InternetExplorer.js $
+ -- $LastChangedDate: 2007-01-31 02:09:44 +1300 (Wed, 31 Jan 2007) $
+ -- $LastChangedRevision: 707 $
+ -- $LastChangedBy: ray $
+ --------------------------------------------------------------------------*/
+
+InternetExplorer._pluginInfo = {
+ name : "Internet Explorer",
+ origin : "Xinha Core",
+ version : "$LastChangedRevision: 707 $".replace(/^[^:]*: (.*) \$$/, '$1'),
+ developer : "The Xinha Core Developer Team",
+ developer_url : "$HeadURL: http://svn.xinha.python-hosting.com/trunk/modules/InternetExplorer/InternetExplorer.js $".replace(/^[^:]*: (.*) \$$/, '$1'),
+ sponsor : "",
+ sponsor_url : "",
+ license : "htmlArea"
+};
+
+function InternetExplorer(editor) {
+ this.editor = editor;
+ editor.InternetExplorer = this; // So we can do my_editor.InternetExplorer.doSomethingIESpecific();
+}
+
+/** Allow Internet Explorer to handle some key events in a special way.
+ */
+
+InternetExplorer.prototype.onKeyPress = function(ev)
+{
+ // Shortcuts
+ if(this.editor.isShortCut(ev))
+ {
+ switch(this.editor.getKey(ev).toLowerCase())
+ {
+ case 'n':
+ {
+ this.editor.execCommand('formatblock', false, '');
+ Xinha._stopEvent(ev);
+ return true;
+ }
+ break;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ {
+ this.editor.execCommand('formatblock', false, '');
+ Xinha._stopEvent(ev);
+ return true;
+ }
+ break;
+ }
+ }
+
+ switch(ev.keyCode)
+ {
+ case 8: // KEY backspace
+ case 46: // KEY delete
+ {
+ if(this.handleBackspace())
+ {
+ Xinha._stopEvent(ev);
+ return true;
+ }
+ }
+ break;
+ }
+
+ return false;
+}
+
+/** When backspace is hit, the IE onKeyPress will execute this method.
+ * It preserves links when you backspace over them and apparently
+ * deletes control elements (tables, images, form fields) in a better
+ * way.
+ *
+ * @returns true|false True when backspace has been handled specially
+ * false otherwise (should pass through).
+ */
+
+InternetExplorer.prototype.handleBackspace = function()
+{
+ var editor = this.editor;
+ var sel = editor.getSelection();
+ if ( sel.type == 'Control' )
+ {
+ var elm = editor.activeElement(sel);
+ Xinha.removeFromParent(elm);
+ return true;
+ }
+
+ // This bit of code preseves links when you backspace over the
+ // endpoint of the link in IE. Without it, if you have something like
+ // link_here |
+ // where | is the cursor, and backspace over the last e, then the link
+ // will de-link, which is a bit tedious
+ var range = editor.createRange(sel);
+ var r2 = range.duplicate();
+ r2.moveStart("character", -1);
+ var a = r2.parentElement();
+ // @fixme: why using again a regex to test a single string ???
+ if ( a != range.parentElement() && ( /^a$/i.test(a.tagName) ) )
+ {
+ r2.collapse(true);
+ r2.moveEnd("character", 1);
+ r2.pasteHTML('');
+ r2.select();
+ return true;
+ }
+};
+
+InternetExplorer.prototype.inwardHtml = function(html)
+{
+ // Both IE and Gecko use strike internally instead of del (#523)
+ // Xinha will present del externally (see Xinha.prototype.outwardHtml
+ html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2");
+
+ return html;
+}
+
+/*--------------------------------------------------------------------------*/
+/*------- IMPLEMENTATION OF THE ABSTRACT "Xinha.prototype" METHODS ---------*/
+/*--------------------------------------------------------------------------*/
+
+/** Insert a node at the current selection point.
+ * @param toBeInserted DomNode
+ */
+
+Xinha.prototype.insertNodeAtSelection = function(toBeInserted)
+{
+ Xinha.notImplemented('insertNodeAtSelection');
+};
+
+
+/** Get the parent element of the supplied or current selection.
+ * @param sel optional selection as returned by getSelection
+ * @returns DomNode
+ */
+
+Xinha.prototype.getParentElement = function(sel)
+{
+ if ( typeof sel == 'undefined' )
+ {
+ sel = this.getSelection();
+ }
+ var range = this.createRange(sel);
+ switch ( sel.type )
+ {
+ case "Text":
+ // try to circumvent a bug in IE:
+ // the parent returned is not always the real parent element
+ var parent = range.parentElement();
+ while ( true )
+ {
+ var TestRange = range.duplicate();
+ TestRange.moveToElementText(parent);
+ if ( TestRange.inRange(range) )
+ {
+ break;
+ }
+ if ( ( parent.nodeType != 1 ) || ( parent.tagName.toLowerCase() == 'body' ) )
+ {
+ break;
+ }
+ parent = parent.parentElement;
+ }
+ return parent;
+ case "None":
+ // It seems that even for selection of type "None",
+ // there _is_ a parent element and it's value is not
+ // only correct, but very important to us. MSIE is
+ // certainly the buggiest browser in the world and I
+ // wonder, God, how can Earth stand it?
+ return range.parentElement();
+ case "Control":
+ return range.item(0);
+ default:
+ return this._doc.body;
+ }
+};
+
+/**
+ * Returns the selected element, if any. That is,
+ * the element that you have last selected in the "path"
+ * at the bottom of the editor, or a "control" (eg image)
+ *
+ * @returns null | DomNode
+ */
+
+Xinha.prototype.activeElement = function(sel)
+{
+ if ( ( sel === null ) || this.selectionEmpty(sel) )
+ {
+ return null;
+ }
+
+ if ( sel.type.toLowerCase() == "control" )
+ {
+ return sel.createRange().item(0);
+ }
+ else
+ {
+ // If it's not a control, then we need to see if
+ // the selection is the _entire_ text of a parent node
+ // (this happens when a node is clicked in the tree)
+ var range = sel.createRange();
+ var p_elm = this.getParentElement(sel);
+ if ( p_elm.innerHTML == range.htmlText )
+ {
+ return p_elm;
+ }
+ /*
+ if ( p_elm )
+ {
+ var p_rng = this._doc.body.createTextRange();
+ p_rng.moveToElementText(p_elm);
+ if ( p_rng.isEqual(range) )
+ {
+ return p_elm;
+ }
+ }
+
+ if ( range.parentElement() )
+ {
+ var prnt_range = this._doc.body.createTextRange();
+ prnt_range.moveToElementText(range.parentElement());
+ if ( prnt_range.isEqual(range) )
+ {
+ return range.parentElement();
+ }
+ }
+ */
+ return null;
+ }
+};
+
+/**
+ * Determines if the given selection is empty (collapsed).
+ * @param selection Selection object as returned by getSelection
+ * @returns true|false
+ */
+
+Xinha.prototype.selectionEmpty = function(sel)
+{
+ if ( !sel )
+ {
+ return true;
+ }
+
+ return this.createRange(sel).htmlText === '';
+};
+
+/**
+ * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table)
+ * the node itself is selected for manipulation.
+ *
+ * @param node DomNode
+ * @param pos Set to a numeric position inside the node to collapse the cursor here if possible.
+ */
+
+Xinha.prototype.selectNodeContents = function(node, pos)
+{
+ this.focusEditor();
+ this.forceRedraw();
+ var range;
+ var collapsed = typeof pos == "undefined" ? true : false;
+ // Tables and Images get selected as "objects" rather than the text contents
+ if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|select|textarea/) )
+ {
+ range = this._doc.body.createControlRange();
+ range.add(node);
+ }
+ else
+ {
+ range = this._doc.body.createTextRange();
+ range.moveToElementText(node);
+ //(collapsed) && range.collapse(pos);
+ }
+ range.select();
+};
+
+/** Insert HTML at the current position, deleting the selection if any.
+ *
+ * @param html string
+ */
+
+Xinha.prototype.insertHTML = function(html)
+{
+ var sel = this.getSelection();
+ var range = this.createRange(sel);
+ this.focusEditor();
+ range.pasteHTML(html);
+};
+
+
+/** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML.
+ *
+ * @returns string
+ */
+
+Xinha.prototype.getSelectedHTML = function()
+{
+ var sel = this.getSelection();
+ var range = this.createRange(sel);
+
+ // Need to be careful of control ranges which won't have htmlText
+ if( range.htmlText )
+ {
+ return range.htmlText;
+ }
+ else if(range.length >= 1)
+ {
+ return range.item(0).outerHTML;
+ }
+
+ return '';
+};
+
+/** Get a Selection object of the current selection. Note that selection objects are browser specific.
+ *
+ * @returns Selection
+ */
+
+Xinha.prototype.getSelection = function()
+{
+ return this._doc.selection;
+};
+
+/** Create a Range object from the given selection. Note that range objects are browser specific.
+ *
+ * @param sel Selection object (see getSelection)
+ * @returns Range
+ */
+
+Xinha.prototype.createRange = function(sel)
+{
+ return sel.createRange();
+};
+
+/** Determine if the given event object is a keydown/press event.
+ *
+ * @param event Event
+ * @returns true|false
+ */
+
+Xinha.prototype.isKeyEvent = function(event)
+{
+ return event.type == "keydown";
+}
+
+/** Return the character (as a string) of a keyEvent - ie, press the 'a' key and
+ * this method will return 'a', press SHIFT-a and it will return 'A'.
+ *
+ * @param keyEvent
+ * @returns string
+ */
+
+Xinha.prototype.getKey = function(keyEvent)
+{
+ return String.fromCharCode(keyEvent.keyCode);
+}
+
+
+/** Return the HTML string of the given Element, including the Element.
+ *
+ * @param element HTML Element DomNode
+ * @returns string
+ */
+
+Xinha.getOuterHTML = function(element)
+{
+ return element.outerHTML;
+};
+
+// Control character for retaining edit location when switching modes
+Xinha.prototype.cc = String.fromCharCode(0x2009);
+
+Xinha.prototype.setCC = function ( target )
+{
+ if ( target == "textarea" )
+ {
+ var ta = this._textArea;
+ var pos = document.selection.createRange();
+ pos.collapse();
+ pos.text = this.cc;
+ var index = ta.value.indexOf( this.cc );
+ var before = ta.value.substring( 0, index );
+ var after = ta.value.substring( index + this.cc.length , ta.value.length );
+
+ if ( after.match(/^[^<]*>/) )
+ {
+ var tagEnd = after.indexOf(">") + 1;
+ ta.value = before + after.substring( 0, tagEnd ) + this.cc + after.substring( tagEnd, after.length );
+ }
+ else ta.value = before + this.cc + after;
+ }
+ else
+ {
+ var sel = this.getSelection();
+ var r = sel.createRange();
+ if ( sel.type == 'Control' )
+ {
+ var control = r.item(0);
+ control.outerHTML += this.cc;
+ }
+ else
+ {
+ r.collapse();
+ r.text = this.cc;
+ }
+ }
+};
+
+Xinha.prototype.findCC = function ( target )
+{
+ var findIn = ( target == 'textarea' ) ? this._textArea : this._doc.body;
+ range = findIn.createTextRange();
+ if( range.findText( this.cc ) )
+ {
+ range.select();
+ range.text = '';
+ }
+ if ( target == 'textarea' ) this._textArea.focus();
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Abbreviation/lang/nb.js 2 Feb 2007 21:04:48 -0000 1.1
@@ -0,0 +1,8 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Abbreviation": "Beskrive forkortelse",
+ "Expansion:": "Betydning:",
+ "Delete": "Fjerne"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/BackgroundImage/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/BackgroundImage/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/BackgroundImage/lang/nb.js 2 Feb 2007 21:04:48 -0000 1.1
@@ -0,0 +1,9 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Set page background image": "Velg bakgrunnsbilde på siden",
+ "Set Page Background Image": "Velg bakgrunnsbilde på Siden",
+ "Remove Current Background": "Fjern gjeldende bakgrunn",
+ "Cancel": "Avbryt"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/char-counter.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/char-counter.js,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/char-counter.js 4 Jun 2006 00:45:49 -0000 1.3
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/char-counter.js 2 Feb 2007 21:04:48 -0000 1.4
@@ -1,10 +1,15 @@
// Charcounter for HTMLArea-3.0
-// (c) Udo Schmal & L.N.Schaffrath NeueMedien
+// (c) Udo Schmal & L.N.Schaffrath NeueMedien
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
function CharCounter(editor) {
- this.editor = editor;
+ this.editor = editor;
+ this._Chars = 0;
+ this._Words = 0;
+ this._HTML = 0;
+ this.maxHTML = 1024;
+ this.onKeyPress = this.__onKeyPress;
}
HTMLArea.Config.prototype.CharCounter =
@@ -16,14 +21,14 @@
};
CharCounter._pluginInfo = {
- name : "CharCounter",
- version : "1.1",
- developer : "Udo Schmal",
- developer_url : "http://www.schaffrath-neuemedien.de",
- sponsor : "L.N.Schaffrath NeueMedien",
- sponsor_url : "http://www.schaffrath-neuemedien.de",
- c_owner : "Udo Schmal & L.N.Schaffrath NeueMedien",
- license : "htmlArea"
+ name : "CharCounter",
+ version : "1.3",
+ developer : "Udo Schmal",
+ developer_url : "http://www.schaffrath-neuemedien.de",
+ sponsor : "L.N.Schaffrath NeueMedien",
+ sponsor_url : "http://www.schaffrath-neuemedien.de",
+ c_owner : "Udo Schmal & L.N.Schaffrath NeueMedien",
+ license : "htmlArea"
};
CharCounter.prototype._lc = function(string) {
@@ -58,35 +63,27 @@
}
};
-CharCounter.prototype.onUpdateToolbar = function() {
- this.updateCharCount();
-};
-
-CharCounter.prototype.onMode = function (mode)
-{
- //Hide Chars in statusbar when switching into textmode
- switch (mode)
- {
- case "textmode":
- this.charCount.style.display = "none";
- break;
- case "wysiwyg":
- this.charCount.style.display = "";
- break;
- default:
- alert("Mode <" + mode + "> not defined!");
- return false;
+CharCounter.prototype.__onKeyPress= function(ev) {
+ if ((ev.keyCode != 8) && (ev.keyCode !=46)) { // not backspace & delete
+ if (this.maxHTML!=-1) {
+ var contents = this.editor.getHTML();
+ if (contents.length>=this.maxHTML) {
+ HTMLArea._stopEvent(ev);
+ return true;
+ }
+ }
}
-};
+}
-CharCounter.prototype.updateCharCount = function(ev) {
+CharCounter.prototype._updateCharCount= function() {
var editor = this.editor;
var cfg = editor.config;
- var contents = editor.getHTML();
- var string = new Array();
+ var contents = editor.getHTML();
+ var string = new Array();
if (cfg.CharCounter.showHtml) {
string[string.length] = this._lc("HTML") + ": " + contents.length;
}
+ this._HTML = contents.length;
if (cfg.CharCounter.showWord || cfg.CharCounter.showChar) {
contents = contents.replace(/<\/?\s*!--[^-->]*-->/gi, "" );
contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags
@@ -97,18 +94,43 @@
contents = contents.replace(/^\s*|\s*$/g, '');//trim
}
if (cfg.CharCounter.showWord) {
- var words=0;
- for (var x=0;x=1) { words++; }
- string[string.length] = this._lc("Words") + ": " + words;
+ if (this._Words >=1) { this._Words++; }
+ string[string.length] = this._lc("Words") + ": " + this._Words ;
}
-
if (cfg.CharCounter.showChar) {
string[string.length] = this._lc("Chars") + ": " + contents.length;
+ this._Chars = contents.length;
}
-
this.charCount.innerHTML = string.join(cfg.CharCounter.separator);
};
+
+CharCounter.prototype.onUpdateToolbar = function() {
+ this.charCount.innerHTML = this._lc("... in progress");
+ if(this._timeoutID) {
+ window.clearTimeout(this._timeoutID);
+ }
+ var e = this;
+ this._timeoutID = window.setTimeout(function() {e._updateCharCount();}, 1000);
+};
+
+CharCounter.prototype.onMode = function (mode)
+{
+ //Hide Chars in statusbar when switching into textmode
+ switch (mode)
+ {
+ case "textmode":
+ this.charCount.style.display = "none";
+ break;
+ case "wysiwyg":
+ this.charCount.style.display = "";
+ break;
+ default:
+ alert("Mode <" + mode + "> not defined!");
+ return false;
+ }
+};
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/de.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/de.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/de.js 2 Nov 2005 08:55:59 -0000 1.1
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/de.js 2 Feb 2007 21:04:49 -0000 1.2
@@ -2,5 +2,7 @@
// LANG: "de", ENCODING: UTF-8
// Author: Udo Schmal (gocher), http://www.schaffrath-neuemedien.de/, udo.schmal@t-online.de
{
- "Chars": "Zeichen"
+ "Chars": "Zeichen",
+ "Words": "Worte",
+ "... in progress": "... in Bearbeitung"
};
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/fr.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/fr.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/fr.js 2 Nov 2005 08:55:59 -0000 1.1
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/fr.js 2 Feb 2007 21:04:49 -0000 1.2
@@ -1,5 +1,6 @@
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
- "Chars": "Caractères"
+ "Chars": "Caractères",
+ "Words": "Mots"
};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharCounter/lang/nb.js 2 Feb 2007 21:04:49 -0000 1.1
@@ -0,0 +1,6 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Chars": "Tegn"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/character-map.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/character-map.js,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/character-map.js 4 Jun 2006 00:45:50 -0000 1.3
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/character-map.js 2 Feb 2007 21:04:49 -0000 1.4
@@ -115,8 +115,8 @@
{
if (HTMLArea.is_ie) editor.focusEditor();
editor.insertHTML( entite );
- self._isActive = false;
- editor.hidePanel( editor._CharacterMap );
+ //self._isActive = false;
+ //editor.hidePanel( editor._CharacterMap );
return false;
};
editor._CharacterMap.appendChild( a );
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/nb.js 2 Feb 2007 21:04:49 -0000 1.1
@@ -0,0 +1,7 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Insert special character": "Sett inn tegn",
+ "Cancel": "Avbryt"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/sv.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/sv.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/CharacterMap/lang/sv.js 2 Feb 2007 21:04:49 -0000 1.1
@@ -0,0 +1,7 @@
+// I18N constants
+// LANG: "sv" (Swedish), ENCODING: UTF-8
+// translated: Erik Dalén
+{
+ "Insert special character": "Infoga tecken",
+ "Cancel": "Avbryt"
+};
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ClientsideSpellcheck/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ClientsideSpellcheck/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ClientsideSpellcheck/lang/nb.js 2 Feb 2007 21:04:49 -0000 1.1
@@ -0,0 +1,3 @@
+// Dummy file
+
+{};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/context-menu.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/context-menu.js,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/context-menu.js 4 Jun 2006 00:45:50 -0000 1.3
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/context-menu.js 2 Feb 2007 21:04:49 -0000 1.4
@@ -44,11 +44,13 @@
if (tbo) tbo = tbo.instance;
var selection = editor.hasSelectedText();
- if (selection)
- menu.push([ HTMLArea._lc("Cut", "ContextMenu"), function() { editor.execCommand("cut"); }, null, config.btnList["cut"][1] ],
- [ HTMLArea._lc("Copy", "ContextMenu"), function() { editor.execCommand("copy"); }, null, config.btnList["copy"][1] ]);
- menu.push([ HTMLArea._lc("Paste", "ContextMenu"), function() { editor.execCommand("paste"); }, null, config.btnList["paste"][1] ]);
-
+ if (!HTMLArea.is_gecko) {
+ if (selection) {
+ menu.push([ HTMLArea._lc("Cut", "ContextMenu"), function() { editor.execCommand("cut"); }, null, config.btnList["cut"][1] ],
+ [ HTMLArea._lc("Copy", "ContextMenu"), function() { editor.execCommand("copy"); }, null, config.btnList["copy"][1] ]);
+ menu.push([ HTMLArea._lc("Paste", "ContextMenu"), function() { editor.execCommand("paste"); }, null, config.btnList["paste"][1] ]);
+ }
+ }
var currentTarget = target;
var elmenus = [];
@@ -130,7 +132,27 @@
[ HTMLArea._lc("C_ell Properties...", "ContextMenu"),
function() { tableOperation("TO-cell-prop"); },
HTMLArea._lc("Show the Table Cell Properties dialog", "ContextMenu"),
- config.btnList["TO-cell-prop"][1] ]
+ config.btnList["TO-cell-prop"][1] ],
+
+ [ HTMLArea._lc("Insert Cell After", "ContextMenu"),
+ function() { tableOperation("TO-cell-insert-after"); },
+ HTMLArea._lc("Insert Cell After", "ContextMenu"),
+ config.btnList["TO-cell-insert-after"][1] ],
+
+ [ HTMLArea._lc("Insert Cell Before", "ContextMenu"),
+ function() { tableOperation("TO-cell-insert-before"); },
+ HTMLArea._lc("Insert Cell After", "ContextMenu"),
+ config.btnList["TO-cell-insert-before"][1] ],
+
+ [ HTMLArea._lc("Delete Cell", "ContextMenu"),
+ function() { tableOperation("TO-cell-delete"); },
+ HTMLArea._lc("Delete Cell", "ContextMenu"),
+ config.btnList["TO-cell-delete"][1] ],
+
+ [ HTMLArea._lc("Merge Cells", "ContextMenu"),
+ function() { tableOperation("TO-cell-merge"); },
+ HTMLArea._lc("Merge Cells", "ContextMenu"),
+ config.btnList["TO-cell-merge"][1] ]
);
break;
case "tr":
@@ -243,13 +265,16 @@
function() { insertPara(true); },
HTMLArea._lc("Insert a paragraph after the current node", "ContextMenu") ]
);
+ if (!menu[0]) menu.shift(); //If the menu begins with a separator, remove it for cosmetical reasons
return menu;
};
ContextMenu.prototype.popupMenu = function(ev) {
var self = this;
if (this.currentMenu)
- this.currentMenu.parentNode.removeChild(this.currentMenu);
+ {
+ this.closeMenu();
+ }
function getPos(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/nb.js 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,53 @@
+// I18N constants
+// LANG: "no", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+// Used key commands
+// C,D,e, ,I, ,k,k,l,M, ,n,o,R, ,s,T, ,w : English
+// H B j R m F v : Norwegian
+{
+ "Cut": "Klipp ut",
+ "Copy": "Kopier",
+ "Paste": "Lim inn",
+ "_Image Properties...": "_Bildeegenskaper...",
+ "Show the image properties dialog": "Vis bildeegenskaper",
+ "_Modify Link...": "_Rediger Link...",
+ "Current URL is": "Gjeldende URL er",
+ "Chec_k Link...": "Sje_kk Link...",
+ "Opens this link in a new window": "Åpner denne link i nytt vindu",
+ "_Remove Link...": "_Fjerne Link...",
+ "Please confirm that you want to unlink this element.": "Vennligst bekreft at du ønsker å fjerne link på elementet",
+ "Link points to:": "Link peker til:",
+ "Unlink the current element": "Fjerne link på gjeldende element",
+ "C_ell Properties...": "C_elleegenskaper...",
+ "Show the Table Cell Properties dialog": "Vis egenskaper for celle",
+ "Ro_w Properties...": "Rad Egenskaper... (_w)",
+ "Show the Table Row Properties dialog": "Vis egenskaper for rad",
+ "I_nsert Row Before": "Sett I_nn rad før",
+ "Insert a new row before the current one": "Sett inn ny rad før gjeldende",
+ "In_sert Row After": "_Sett inn rad etter",
+ "Insert a new row after the current one": "Sett inn ny rad etter gjeldende",
+ "_Delete Row": "Slett rad (_d)",
+ "Delete the current row": "Slett gjeldende rad",
+ "_Table Properties...": "_Tabellegenskaper...",
+ "Show the Table Properties dialog": "Vis egenskaper for tabellen",
+ "Insert _Column Before": "Sett inn kolonne etter (_c)",
+ "Insert a new column before the current one": "Sett inn kolonne før gjeldende",
+ "Insert C_olumn After": "Sett inn k_olonne etter",
+ "Insert a new column after the current one": "Sett inn kolonne etter gjeldende",
+ "De_lete Column": "S_lett kolonne",
+ "Delete the current column": "Slett gjeldende kolonne",
+ "Justify Left": "_Venstrejuster",
+ "Justify Center": "_Midtjuster",
+ "Justify Right": "_Høyrejuster",
+ "Justify Full": "Blokk_juster",
+ "Make lin_k...": "Lag len_ke...",
+ "Create a link": "Lag ny link",
+ "Remove the $elem Element...": "Fjerne $elem elementet...",
+ "Please confirm that you want to remove this element:": "Vennligst bekreft at du ønsker å fjerne elementet:",
+ "Remove this node from the document": "Fjerne denne node fra dokumentet",
+ "Insert paragraph before": "Sett inn paragraf før",
+ "Insert a paragraph before the current node": "Sett inn paragraf før gjeldende node",
+ "Insert paragraph after": "Sett inn paragraf etter",
+ "Insert a paragraph after the current node": "Sett inn paragraf etter gjeldende node",
+ "How did you get here? (Please report!)": "Hva skjedde? (Vennligst beskriv)"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/sv.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/sv.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ContextMenu/lang/sv.js 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,54 @@
+// I18N constants
+// LANG: "sv", ENCODING: UTF-8
+// Swedish version for rev. 477 (Mar 2006) by Thomas Loo
+
+// TODO: Proper keybindings
+// C,D,e, ,I, ,k,k,l,M, ,n,o,R, ,s,T, ,w : English
+// H B j R m F v : Swedish
+{
+ "Cut": "Klipp ut",
+ "Copy": "Kopiera",
+ "Paste": "Klistra in",
+ "_Image Properties...": "_Bildegenskaper...",
+ "Show the image properties dialog": "Visa bildegenskaper",
+ "_Modify Link...": "_Redigera Länk...",
+ "Current URL is": "Aktuellt URL är",
+ "Chec_k Link...": "Kontrollera länk...",
+ "Opens this link in a new window": "Öppna länk i nytt fönster",
+ "_Remove Link...": "_Ta bort länk...",
+ "Please confirm that you want to unlink this element.": "Bekräfta borttagning av länk",
+ "Link points to:": "Länken pekar mot:",
+ "Unlink the current element": "Ta bort länk kopplad till elementet",
+ "C_ell Properties...": "C_ellegenskaper...",
+ "Show the Table Cell Properties dialog": "Visa egenskaper for cellen",
+ "Ro_w Properties...": "Radegenskaper... (_w)",
+ "Show the Table Row Properties dialog": "Visa egenskaper för rad",
+ "I_nsert Row Before": "I_nfoga rad före",
+ "Insert a new row before the current one": "Infoga ny rad före aktuell",
+ "In_sert Row After": "Infoga rad efter aktuell rad",
+ "Insert a new row after the current one": "Infoga ny rad efter aktuell",
+ "_Delete Row": "Radera rad (_d)",
+ "Delete the current row": "T bort aktuell rad",
+ "_Table Properties...": "_Tabellegenskaper...",
+ "Show the Table Properties dialog": "Visa tabellegenskaper",
+ "Insert _Column Before": "Infoga kolumn efter (_c)",
+ "Insert a new column before the current one": "Infoga kolumn före aktuell",
+ "Insert C_olumn After": "Infoga k_olumn efter",
+ "Insert a new column after the current one": "Infoga kolumn efter aktuell",
+ "De_lete Column": "_Radera kolumn",
+ "Delete the current column": "Radera aktuell kolumn",
+ "Justify Left": "_Vänsterjustera",
+ "Justify Center": "_Centerjustera",
+ "Justify Right": "_Högerjustera",
+ "Justify Full": "Block_justera",
+ "Make lin_k...": "Skapa län_k...",
+ "Create a link": "SKapa ny länk",
+ "Remove the $elem Element...": "Radera elementet $elem...",
+ "Please confirm that you want to remove this element:": "Bekräfta borttagning av element:",
+ "Remove this node from the document": "Radera nod från dokumentet",
+ "Insert paragraph before": "Infoga paragraf före",
+ "Insert a paragraph before the current node": "Infoga paragraf före aktuell nod",
+ "Insert paragraph after": "Infoga paragraf efter",
+ "Insert a paragraph after the current node": "Infoga paragraf efter aktuell nod",
+ "How did you get here? (Please report!)": "Hur hamnade du här? (Beskriv förloppet)"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.css
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.css,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.css 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,21 @@
+dl { border: 1px dotted #800000; }
+dt {
+ width: 18px;
+ height: 18px;
+ background-image: url(img/ed_dt.gif);
+ background-repeat: no-repeat;
+ background-position: left top;
+ padding-left: 19px;
+ display: block;
+ color: #800000;
+}
+dd {
+ width: 18px;
+ height: 18px;
+ background-image: url(img/ed_dd.gif);
+ background-repeat: no-repeat;
+ background-position: left top;
+ padding-left: 19px;
+ display: block;
+ color: #800000;
+}
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/definition-list.js 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,99 @@
+// DefinitionList plugin for HTMLArea
+// Distributed under the same terms as HTMLArea itself.
+// This notice MUST stay intact for use (see license.txt).
+
+
+function DefinitionList(editor) {
+ this.editor = editor;
+ var cfg = editor.config;
+ var bl = DefinitionList.btnList;
+ var self = this;
+ // register the toolbar buttons provided by this plugin
+ var toolbar = ["linebreak"];
+ for (var i = 0; i < bl.length; ++i) {
+ var btn = bl[i];
+ if (!btn) {
+ toolbar.push("separator");
+ } else {
+ var id = btn[0];
+ cfg.registerButton(id, HTMLArea._lc(btn[1]), editor.imgURL("ed_" + btn[0] + ".gif", "DefinitionList"), false,
+ function(editor, id) {
+ // dispatch button press event
+ self.buttonPress(editor, id);
+ });
+ toolbar.push(id);
+ }
+ }
+ // add a new line in the toolbar
+ cfg.toolbar.push(toolbar);
+}
+
+DefinitionList._pluginInfo = {
+ name : "DefinitionList",
+ version : "1.0",
+ developer : "Udo Schmal",
+ developer_url : "",
+ c_owner : "Udo Schmal",
+ license : "htmlArea"
+};
+
+// the list of buttons added by this plugin
+DefinitionList.btnList = [
+ ["dl", "definition list"],
+ ["dt", "definition term"],
+ ["dd", "definition description"]
+ ];
+
+DefinitionList.prototype._lc = function(string) {
+ return HTMLArea._lc(string, 'DefinitionList');
+};
+
+DefinitionList.prototype.onGenerate = function() {
+ var style_id = "DefinitionList-style"
+ var style = this.editor._doc.getElementById(style_id);
+ if (style == null) {
+ style = this.editor._doc.createElement("link");
+ style.id = style_id;
+ style.rel = 'stylesheet';
+ style.href = _editor_url + 'plugins/DefinitionList/definition-list.css';
+ this.editor._doc.getElementsByTagName("HEAD")[0].appendChild(style);
+ }
+};
+
+DefinitionList.prototype.buttonPress = function(editor,button_id) {
+ if (button_id=='dl') { //definition list
+ var pe = editor.getParentElement();
+ while (pe.parentNode.tagName.toLowerCase() != 'body') {
+ pe = pe.parentNode;
+ }
+ var dx = editor._doc.createElement(button_id);
+ dx.innerHTML = ' ';
+ if(pe.parentNode.lastChild==pe) {
+ pe.parentNode.appendChild(dx);
+ }else{
+ pe.parentNode.insertBefore(dx,pe.nextSibling);
+ }
+ } else if ((button_id=='dt')||(button_id=='dd')) { //definition term or description
+ var pe = editor.getParentElement();
+ while (pe && (pe.nodeType == 1) && (pe.tagName.toLowerCase() != 'body')) {
+ if(pe.tagName.toLowerCase() == 'dl') {
+ var dx = editor._doc.createElement(button_id);
+ dx.innerHTML = ' ';
+ pe.appendChild(dx);
+ break;
+ }else if((pe.tagName.toLowerCase() == 'dt')||(pe.tagName.toLowerCase() == 'dd')){
+ var dx = editor._doc.createElement(button_id)
+ dx.innerHTML = ' ';
+ if(pe.parentNode.lastChild==pe) {
+ pe.parentNode.appendChild(dx);
+ }else{
+ pe.parentNode.insertBefore(dx,pe.nextSibling);
+ }
+ break;
+ }
+ pe = pe.parentNode;
+ }
+ if(pe.tagName.toLowerCase() == 'body')
+ alert('You can insert a definition term or description only in a definition list!');
+ }
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dd.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dd.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dl.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dl.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dt.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DefinitionList/img/ed_dt.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DoubleClick/double-click.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DoubleClick/double-click.js,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DoubleClick/double-click.js 11 Nov 2005 20:32:41 -0000 1.2
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DoubleClick/double-click.js 2 Feb 2007 21:04:50 -0000 1.3
@@ -36,12 +36,8 @@
// - editor is the HTMLArea object that triggered the call
// - target is the selected object
this.editor.dblClickList = {
- u: [ function(e) {e.execCommand("underline");} ],
- strike: [ function(e) {e.execCommand("strikethrough");} ],
- sub: [ function(e) {e.execCommand("subscript");} ],
- sup: [ function(e) {e.execCommand("superscript");} ],
// Edit Link dialog
- a: [ function(e) {e.execCommand("createlink");} ],
+ a: [ function(e) {e.config.btnList['createlink'][3](e); } ],
// Follow link
//a: [ function(editor, target) { window.location = target.href; properties(target); } ],
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DynamicCSS/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DynamicCSS/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/DynamicCSS/lang/nb.js 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,8 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Default": "Standard",
+ "Undefined": "Udefinert",
+ "Choose stylesheet": "Velg stilsett"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EditTag/lang/nb.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EditTag/lang/nb.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EditTag/lang/nb.js 2 Feb 2007 21:04:50 -0000 1.1
@@ -0,0 +1,6 @@
+// I18N constants
+// LANG: "nb", ENCODING: UTF-8
+// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
+{
+ "Edit HTML for selected text": "Rediger HTML for den valgte teksten"
+};
\ No newline at end of file
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EnterParagraphs/enter-paragraphs.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EnterParagraphs/enter-paragraphs.js,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EnterParagraphs/enter-paragraphs.js 11 Nov 2005 20:32:42 -0000 1.2
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/EnterParagraphs/enter-paragraphs.js 2 Feb 2007 21:04:51 -0000 1.3
@@ -3,7 +3,7 @@
/**
* @fileoverview By Adam Wright, for The University of Western Australia
*
-* Distributed under the same terms as HTMLArea itself.
+* Distributed under the same terms as Xinha itself.
* This notice MUST stay intact for use (see license.txt).
*
* Heavily modified by Yermo Lamers of DTLink, LLC, College Park, Md., USA.
@@ -107,7 +107,7 @@
// hook into the event handler to intercept key presses if we are using
// gecko (Mozilla/FireFox)
- if (HTMLArea.is_gecko)
+ if (Xinha.is_gecko)
{
//this.ddt._ddt( "enter-paragraphs.js","23", "EnterParagraphs(): we are gecko. Setting event handler." );
this.onKeyPress = this.__onKeyPress;
@@ -426,7 +426,7 @@
// does not return content.
return new Array(true, false );
- breal;
+ break;
case "find_cursorpoint":
@@ -700,12 +700,15 @@
}
// NODE TYPE 11 is DOCUMENT_FRAGMENT NODE
-
- if ( cnt.nodeType == 11 && !cnt.firstChild )
- {
- cnt.appendChild(editor._doc.createElement(pify.nodeName));
- }
-
+ // I do not profess to understand any of this, simply applying a patch that others say is good - ticket:446
+ if ( cnt.nodeType == 11 && !cnt.firstChild)
+ {
+ if (pify.nodeName != "BODY" || (pify.nodeName == "BODY" && pifyOffset != 0))
+ { //WKR: prevent body tag in empty doc
+ cnt.appendChild(editor._doc.createElement(pify.nodeName));
+ }
+ }
+
// YmL: Added additional last parameter for fill case to work around logic
// error in forEachNode()
@@ -779,7 +782,7 @@
{
// FIXME:/CHECKME: When Xinha is switched from WYSIWYG to text mode
- // HTMLArea.getHTMLWrapper() will strip out the trailing br. Not sure why.
+ // Xinha.getHTMLWrapper() will strip out the trailing br. Not sure why.
// fill.appendChild(editor._doc.createElement('br'));
@@ -960,8 +963,8 @@
// Grab the selection and associated range
- var sel = this.editor._getSelection();
- var rng = this.editor._createRange(sel);
+ var sel = this.editor.getSelection();
+ var rng = this.editor.createRange(sel);
//this.ddt._ddtDumpNode( "enter-paragraphs.js", "757", "handleEnter(): initial range is: ", rng );
@@ -1078,7 +1081,7 @@
this.editor.updateToolbar();
- HTMLArea._stopEvent(ev);
+ Xinha._stopEvent(ev);
return true;
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/ASCIIMathML.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/ASCIIMathML.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/ASCIIMathML.js 2 Feb 2007 21:04:51 -0000 1.1
@@ -0,0 +1,946 @@
+/*
+ASCIIMathML.js
+==============
+This file contains JavaScript functions to convert ASCII math notation
+to Presentation MathML. The conversion is done while the (X)HTML page
+loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
+Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
+Just add the next line to your (X)HTML page with this file in the same folder:
+
+This is a convenient and inexpensive solution for authoring MathML.
+
+Version 1.4.7 Aug 7, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
+Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
+For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
+If you use it on a webpage, please send the URL to jipsen@chapman.edu
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License (at http://www.gnu.org/licenses/lgpl.html)
+ for more details.
+
+ NOTE: I have changed the license from GPL to LGPL according to a permission
+ from the author (see http://xinha.gogo.co.nz/punbb/viewtopic.php?pid=4150#p4150)
+ Raimund Meyer 11-29-2006
+*/
+
+var checkForMathML = true; // check if browser can display MathML
+var notifyIfNoMathML = true; // put note at top of page if no MathML capability
+
+if ( typeof mathcolor == "undefined" )
+{
+ var mathcolor = "red"; // change it to "" (to inherit) or any other color
+}
+if ( typeof mathfontfamily == "undefined" )
+{
+ var mathfontfamily = "serif"; // change to "" to inherit (works in IE) or another family (e.g. "arial")
+}
+var displaystyle = true; // puts limits above and below large operators
+
+if ( typeof showasciiformulaonhover == "undefined" )
+{
+ var showasciiformulaonhover = true; // helps students learn ASCIIMath
+}
+
+var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
+var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
+var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
+var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
+ // for IE this works only in
+//var separatetokens;// has been removed (email me if this is a problem)
+var isIE = document.createElementNS==null;
+
+if (document.getElementById==null)
+ alert("This webpage requires a recent browser such as\
+\nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
+
+// all further global variables start with "AM"
+
+function AMcreateElementXHTML(t) {
+ if (isIE) return document.createElement(t);
+ else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
+}
+
+function AMnoMathMLNote() {
+ var nd = AMcreateElementXHTML("h3");
+ nd.setAttribute("align","center")
+ nd.appendChild(AMcreateElementXHTML("p"));
+ nd.appendChild(document.createTextNode("To view the "));
+ var an = AMcreateElementXHTML("a");
+ an.appendChild(document.createTextNode("ASCIIMathML"));
+ an.setAttribute("href","http://www.chapman.edu/~jipsen/asciimath.html");
+ nd.appendChild(an);
+ nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
+ an = AMcreateElementXHTML("a");
+ an.appendChild(document.createTextNode("MathPlayer"));
+ an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
+ nd.appendChild(an);
+ nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
+ nd.appendChild(AMcreateElementXHTML("p"));
+ return nd;
+}
+
+function AMisMathMLavailable() {
+ if (navigator.appName.slice(0,8)=="Netscape")
+ if (navigator.appVersion.slice(0,1)>="5") return null;
+ else return AMnoMathMLNote();
+ else if (navigator.appName.slice(0,9)=="Microsoft")
+ try {
+ var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
+ return null;
+ } catch (e) {
+ return AMnoMathMLNote();
+ }
+ else return AMnoMathMLNote();
+}
+
+// character lists for Mozilla/Netscape fonts
+var AMcal = [0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];
+var AMfrk = [0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];
+var AMbbb = [0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];
+
+var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
+ RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
+ LEFTRIGHT = 9, TEXT = 10; // token types
+
+var AMsqrt = {input:"sqrt", tag:"msqrt", output:"sqrt", tex:null, ttype:UNARY},
+ AMroot = {input:"root", tag:"mroot", output:"root", tex:null, ttype:BINARY},
+ AMfrac = {input:"frac", tag:"mfrac", output:"/", tex:null, ttype:BINARY},
+ AMdiv = {input:"/", tag:"mfrac", output:"/", tex:null, ttype:INFIX},
+ AMover = {input:"stackrel", tag:"mover", output:"stackrel", tex:null, ttype:BINARY},
+ AMsub = {input:"_", tag:"msub", output:"_", tex:null, ttype:INFIX},
+ AMsup = {input:"^", tag:"msup", output:"^", tex:null, ttype:INFIX},
+ AMtext = {input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT},
+ AMmbox = {input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT},
+ AMquote = {input:"\"", tag:"mtext", output:"mbox", tex:null, ttype:TEXT};
+
+var AMsymbols = [
+//some greek symbols
+{input:"alpha", tag:"mi", output:"\u03B1", tex:null, ttype:CONST},
+{input:"beta", tag:"mi", output:"\u03B2", tex:null, ttype:CONST},
+{input:"chi", tag:"mi", output:"\u03C7", tex:null, ttype:CONST},
+{input:"delta", tag:"mi", output:"\u03B4", tex:null, ttype:CONST},
+{input:"Delta", tag:"mo", output:"\u0394", tex:null, ttype:CONST},
+{input:"epsi", tag:"mi", output:"\u03B5", tex:"epsilon", ttype:CONST},
+{input:"varepsilon", tag:"mi", output:"\u025B", tex:null, ttype:CONST},
+{input:"eta", tag:"mi", output:"\u03B7", tex:null, ttype:CONST},
+{input:"gamma", tag:"mi", output:"\u03B3", tex:null, ttype:CONST},
+{input:"Gamma", tag:"mo", output:"\u0393", tex:null, ttype:CONST},
+{input:"iota", tag:"mi", output:"\u03B9", tex:null, ttype:CONST},
+{input:"kappa", tag:"mi", output:"\u03BA", tex:null, ttype:CONST},
+{input:"lambda", tag:"mi", output:"\u03BB", tex:null, ttype:CONST},
+{input:"Lambda", tag:"mo", output:"\u039B", tex:null, ttype:CONST},
+{input:"mu", tag:"mi", output:"\u03BC", tex:null, ttype:CONST},
+{input:"nu", tag:"mi", output:"\u03BD", tex:null, ttype:CONST},
+{input:"omega", tag:"mi", output:"\u03C9", tex:null, ttype:CONST},
+{input:"Omega", tag:"mo", output:"\u03A9", tex:null, ttype:CONST},
+{input:"phi", tag:"mi", output:"\u03C6", tex:null, ttype:CONST},
+{input:"varphi", tag:"mi", output:"\u03D5", tex:null, ttype:CONST},
+{input:"Phi", tag:"mo", output:"\u03A6", tex:null, ttype:CONST},
+{input:"pi", tag:"mi", output:"\u03C0", tex:null, ttype:CONST},
+{input:"Pi", tag:"mo", output:"\u03A0", tex:null, ttype:CONST},
+{input:"psi", tag:"mi", output:"\u03C8", tex:null, ttype:CONST},
+{input:"Psi", tag:"mi", output:"\u03A8", tex:null, ttype:CONST},
+{input:"rho", tag:"mi", output:"\u03C1", tex:null, ttype:CONST},
+{input:"sigma", tag:"mi", output:"\u03C3", tex:null, ttype:CONST},
+{input:"Sigma", tag:"mo", output:"\u03A3", tex:null, ttype:CONST},
+{input:"tau", tag:"mi", output:"\u03C4", tex:null, ttype:CONST},
+{input:"theta", tag:"mi", output:"\u03B8", tex:null, ttype:CONST},
+{input:"vartheta", tag:"mi", output:"\u03D1", tex:null, ttype:CONST},
+{input:"Theta", tag:"mo", output:"\u0398", tex:null, ttype:CONST},
+{input:"upsilon", tag:"mi", output:"\u03C5", tex:null, ttype:CONST},
+{input:"xi", tag:"mi", output:"\u03BE", tex:null, ttype:CONST},
+{input:"Xi", tag:"mo", output:"\u039E", tex:null, ttype:CONST},
+{input:"zeta", tag:"mi", output:"\u03B6", tex:null, ttype:CONST},
+
+//binary operation symbols
+{input:"*", tag:"mo", output:"\u22C5", tex:"cdot", ttype:CONST},
+{input:"**", tag:"mo", output:"\u22C6", tex:"star", ttype:CONST},
+{input:"//", tag:"mo", output:"/", tex:null, ttype:CONST},
+{input:"\\\\", tag:"mo", output:"\\", tex:"backslash", ttype:CONST},
+{input:"setminus", tag:"mo", output:"\\", tex:null, ttype:CONST},
+{input:"xx", tag:"mo", output:"\u00D7", tex:"times", ttype:CONST},
+{input:"-:", tag:"mo", output:"\u00F7", tex:"divide", ttype:CONST},
+{input:"@", tag:"mo", output:"\u2218", tex:"circ", ttype:CONST},
+{input:"o+", tag:"mo", output:"\u2295", tex:"oplus", ttype:CONST},
+{input:"ox", tag:"mo", output:"\u2297", tex:"otimes", ttype:CONST},
+{input:"o.", tag:"mo", output:"\u2299", tex:"odot", ttype:CONST},
+{input:"sum", tag:"mo", output:"\u2211", tex:null, ttype:UNDEROVER},
+{input:"prod", tag:"mo", output:"\u220F", tex:null, ttype:UNDEROVER},
+{input:"^^", tag:"mo", output:"\u2227", tex:"wedge", ttype:CONST},
+{input:"^^^", tag:"mo", output:"\u22C0", tex:"bigwedge", ttype:UNDEROVER},
+{input:"vv", tag:"mo", output:"\u2228", tex:"vee", ttype:CONST},
+{input:"vvv", tag:"mo", output:"\u22C1", tex:"bigvee", ttype:UNDEROVER},
+{input:"nn", tag:"mo", output:"\u2229", tex:"cap", ttype:CONST},
+{input:"nnn", tag:"mo", output:"\u22C2", tex:"bigcap", ttype:UNDEROVER},
+{input:"uu", tag:"mo", output:"\u222A", tex:"cup", ttype:CONST},
+{input:"uuu", tag:"mo", output:"\u22C3", tex:"bigcup", ttype:UNDEROVER},
+
+//binary relation symbols
+{input:"!=", tag:"mo", output:"\u2260", tex:"ne", ttype:CONST},
+{input:":=", tag:"mo", output:":=", tex:null, ttype:CONST},
+{input:"lt", tag:"mo", output:"<", tex:null, ttype:CONST},
+{input:"<=", tag:"mo", output:"\u2264", tex:"le", ttype:CONST},
+{input:"lt=", tag:"mo", output:"\u2264", tex:"leq", ttype:CONST},
+{input:">=", tag:"mo", output:"\u2265", tex:"ge", ttype:CONST},
+{input:"geq", tag:"mo", output:"\u2265", tex:null, ttype:CONST},
+{input:"-<", tag:"mo", output:"\u227A", tex:"prec", ttype:CONST},
+{input:"-lt", tag:"mo", output:"\u227A", tex:null, ttype:CONST},
+{input:">-", tag:"mo", output:"\u227B", tex:"succ", ttype:CONST},
+{input:"in", tag:"mo", output:"\u2208", tex:null, ttype:CONST},
+{input:"!in", tag:"mo", output:"\u2209", tex:"notin", ttype:CONST},
+{input:"sub", tag:"mo", output:"\u2282", tex:"subset", ttype:CONST},
+{input:"sup", tag:"mo", output:"\u2283", tex:"supset", ttype:CONST},
+{input:"sube", tag:"mo", output:"\u2286", tex:"subseteq", ttype:CONST},
+{input:"supe", tag:"mo", output:"\u2287", tex:"supseteq", ttype:CONST},
+{input:"-=", tag:"mo", output:"\u2261", tex:"equiv", ttype:CONST},
+{input:"~=", tag:"mo", output:"\u2245", tex:"cong", ttype:CONST},
+{input:"~~", tag:"mo", output:"\u2248", tex:"approx", ttype:CONST},
+{input:"prop", tag:"mo", output:"\u221D", tex:"propto", ttype:CONST},
+
+//logical symbols
+{input:"and", tag:"mtext", output:"and", tex:null, ttype:SPACE},
+{input:"or", tag:"mtext", output:"or", tex:null, ttype:SPACE},
+{input:"not", tag:"mo", output:"\u00AC", tex:"neg", ttype:CONST},
+{input:"=>", tag:"mo", output:"\u21D2", tex:"implies", ttype:CONST},
+{input:"if", tag:"mo", output:"if", tex:null, ttype:SPACE},
+{input:"<=>", tag:"mo", output:"\u21D4", tex:"iff", ttype:CONST},
+{input:"AA", tag:"mo", output:"\u2200", tex:"forall", ttype:CONST},
+{input:"EE", tag:"mo", output:"\u2203", tex:"exists", ttype:CONST},
+{input:"_|_", tag:"mo", output:"\u22A5", tex:"bot", ttype:CONST},
+{input:"TT", tag:"mo", output:"\u22A4", tex:"top", ttype:CONST},
+{input:"|--", tag:"mo", output:"\u22A2", tex:"vdash", ttype:CONST},
+{input:"|==", tag:"mo", output:"\u22A8", tex:"models", ttype:CONST},
+
+//grouping brackets
+{input:"(", tag:"mo", output:"(", tex:null, ttype:LEFTBRACKET},
+{input:")", tag:"mo", output:")", tex:null, ttype:RIGHTBRACKET},
+{input:"[", tag:"mo", output:"[", tex:null, ttype:LEFTBRACKET},
+{input:"]", tag:"mo", output:"]", tex:null, ttype:RIGHTBRACKET},
+{input:"{", tag:"mo", output:"{", tex:null, ttype:LEFTBRACKET},
+{input:"}", tag:"mo", output:"}", tex:null, ttype:RIGHTBRACKET},
+{input:"|", tag:"mo", output:"|", tex:null, ttype:LEFTRIGHT},
+//{input:"||", tag:"mo", output:"||", tex:null, ttype:LEFTRIGHT},
+{input:"(:", tag:"mo", output:"\u2329", tex:"langle", ttype:LEFTBRACKET},
+{input:":)", tag:"mo", output:"\u232A", tex:"rangle", ttype:RIGHTBRACKET},
+{input:"<<", tag:"mo", output:"\u2329", tex:null, ttype:LEFTBRACKET},
+{input:">>", tag:"mo", output:"\u232A", tex:null, ttype:RIGHTBRACKET},
+{input:"{:", tag:"mo", output:"{:", tex:null, ttype:LEFTBRACKET, invisible:true},
+{input:":}", tag:"mo", output:":}", tex:null, ttype:RIGHTBRACKET, invisible:true},
+
+//miscellaneous symbols
+{input:"int", tag:"mo", output:"\u222B", tex:null, ttype:CONST},
+{input:"dx", tag:"mi", output:"{:d x:}", tex:null, ttype:DEFINITION},
+{input:"dy", tag:"mi", output:"{:d y:}", tex:null, ttype:DEFINITION},
+{input:"dz", tag:"mi", output:"{:d z:}", tex:null, ttype:DEFINITION},
+{input:"dt", tag:"mi", output:"{:d t:}", tex:null, ttype:DEFINITION},
+{input:"oint", tag:"mo", output:"\u222E", tex:null, ttype:CONST},
+{input:"del", tag:"mo", output:"\u2202", tex:"partial", ttype:CONST},
+{input:"grad", tag:"mo", output:"\u2207", tex:"nabla", ttype:CONST},
+{input:"+-", tag:"mo", output:"\u00B1", tex:"pm", ttype:CONST},
+{input:"O/", tag:"mo", output:"\u2205", tex:"emptyset", ttype:CONST},
+{input:"oo", tag:"mo", output:"\u221E", tex:"infty", ttype:CONST},
+{input:"aleph", tag:"mo", output:"\u2135", tex:null, ttype:CONST},
+{input:"...", tag:"mo", output:"...", tex:"ldots", ttype:CONST},
+{input:":.", tag:"mo", output:"\u2234", tex:"therefore", ttype:CONST},
+{input:"/_", tag:"mo", output:"\u2220", tex:"angle", ttype:CONST},
+{input:"\\ ", tag:"mo", output:"\u00A0", tex:null, ttype:CONST},
+{input:"quad", tag:"mo", output:"\u00A0\u00A0", tex:null, ttype:CONST},
+{input:"qquad", tag:"mo", output:"\u00A0\u00A0\u00A0\u00A0", tex:null, ttype:CONST},
+{input:"cdots", tag:"mo", output:"\u22EF", tex:null, ttype:CONST},
+{input:"vdots", tag:"mo", output:"\u22EE", tex:null, ttype:CONST},
+{input:"ddots", tag:"mo", output:"\u22F1", tex:null, ttype:CONST},
+{input:"diamond", tag:"mo", output:"\u22C4", tex:null, ttype:CONST},
+{input:"square", tag:"mo", output:"\u25A1", tex:null, ttype:CONST},
+{input:"|__", tag:"mo", output:"\u230A", tex:"lfloor", ttype:CONST},
+{input:"__|", tag:"mo", output:"\u230B", tex:"rfloor", ttype:CONST},
+{input:"|~", tag:"mo", output:"\u2308", tex:"lceiling", ttype:CONST},
+{input:"~|", tag:"mo", output:"\u2309", tex:"rceiling", ttype:CONST},
+{input:"CC", tag:"mo", output:"\u2102", tex:null, ttype:CONST},
+{input:"NN", tag:"mo", output:"\u2115", tex:null, ttype:CONST},
+{input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
+{input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
+{input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
+{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
+{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
+
+//standard functions
+{input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
+{input:"Lim", tag:"mo", output:"Lim", tex:null, ttype:UNDEROVER},
+{input:"sin", tag:"mo", output:"sin", tex:null, ttype:UNARY, func:true},
+{input:"cos", tag:"mo", output:"cos", tex:null, ttype:UNARY, func:true},
+{input:"tan", tag:"mo", output:"tan", tex:null, ttype:UNARY, func:true},
+{input:"sinh", tag:"mo", output:"sinh", tex:null, ttype:UNARY, func:true},
+{input:"cosh", tag:"mo", output:"cosh", tex:null, ttype:UNARY, func:true},
+{input:"tanh", tag:"mo", output:"tanh", tex:null, ttype:UNARY, func:true},
+{input:"cot", tag:"mo", output:"cot", tex:null, ttype:UNARY, func:true},
+{input:"sec", tag:"mo", output:"sec", tex:null, ttype:UNARY, func:true},
+{input:"csc", tag:"mo", output:"csc", tex:null, ttype:UNARY, func:true},
+{input:"log", tag:"mo", output:"log", tex:null, ttype:UNARY, func:true},
+{input:"ln", tag:"mo", output:"ln", tex:null, ttype:UNARY, func:true},
+{input:"det", tag:"mo", output:"det", tex:null, ttype:UNARY, func:true},
+{input:"dim", tag:"mo", output:"dim", tex:null, ttype:CONST},
+{input:"mod", tag:"mo", output:"mod", tex:null, ttype:CONST},
+{input:"gcd", tag:"mo", output:"gcd", tex:null, ttype:UNARY, func:true},
+{input:"lcm", tag:"mo", output:"lcm", tex:null, ttype:UNARY, func:true},
+{input:"lub", tag:"mo", output:"lub", tex:null, ttype:CONST},
+{input:"glb", tag:"mo", output:"glb", tex:null, ttype:CONST},
+{input:"min", tag:"mo", output:"min", tex:null, ttype:UNDEROVER},
+{input:"max", tag:"mo", output:"max", tex:null, ttype:UNDEROVER},
+
+//arrows
+{input:"uarr", tag:"mo", output:"\u2191", tex:"uparrow", ttype:CONST},
+{input:"darr", tag:"mo", output:"\u2193", tex:"downarrow", ttype:CONST},
+{input:"rarr", tag:"mo", output:"\u2192", tex:"rightarrow", ttype:CONST},
+{input:"->", tag:"mo", output:"\u2192", tex:"to", ttype:CONST},
+{input:"|->", tag:"mo", output:"\u21A6", tex:"mapsto", ttype:CONST},
+{input:"larr", tag:"mo", output:"\u2190", tex:"leftarrow", ttype:CONST},
+{input:"harr", tag:"mo", output:"\u2194", tex:"leftrightarrow", ttype:CONST},
+{input:"rArr", tag:"mo", output:"\u21D2", tex:"Rightarrow", ttype:CONST},
+{input:"lArr", tag:"mo", output:"\u21D0", tex:"Leftarrow", ttype:CONST},
+{input:"hArr", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST},
+
+//commands with argument
+AMsqrt, AMroot, AMfrac, AMdiv, AMover, AMsub, AMsup,
+{input:"hat", tag:"mover", output:"\u005E", tex:null, ttype:UNARY, acc:true},
+{input:"bar", tag:"mover", output:"\u00AF", tex:"overline", ttype:UNARY, acc:true},
+{input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true},
+{input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true},
+{input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true},
+{input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true},
+AMtext, AMmbox, AMquote,
+{input:"bb", tag:"mstyle", atname:"fontweight", atval:"bold", output:"bb", tex:null, ttype:UNARY},
+{input:"mathbf", tag:"mstyle", atname:"fontweight", atval:"bold", output:"mathbf", tex:null, ttype:UNARY},
+{input:"sf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"sf", tex:null, ttype:UNARY},
+{input:"mathsf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"mathsf", tex:null, ttype:UNARY},
+{input:"bbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"bbb", tex:null, ttype:UNARY, codes:AMbbb},
+{input:"mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"mathbb", tex:null, ttype:UNARY, codes:AMbbb},
+{input:"cc", tag:"mstyle", atname:"mathvariant", atval:"script", output:"cc", tex:null, ttype:UNARY, codes:AMcal},
+{input:"mathcal", tag:"mstyle", atname:"mathvariant", atval:"script", output:"mathcal", tex:null, ttype:UNARY, codes:AMcal},
+{input:"tt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"tt", tex:null, ttype:UNARY},
+{input:"mathtt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"mathtt", tex:null, ttype:UNARY},
+{input:"fr", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"fr", tex:null, ttype:UNARY, codes:AMfrk},
+{input:"mathfrak", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"mathfrak", tex:null, ttype:UNARY, codes:AMfrk}
+];
+
+function compareNames(s1,s2) {
+ if (s1.input > s2.input) return 1
+ else return -1;
+}
+
+var AMnames = []; //list of input symbols
+
+function AMinitSymbols() {
+ var texsymbols = [], i;
+ for (i=0; i=n where str appears or would be inserted
+// assumes arr is sorted
+ if (n==0) {
+ var h,m;
+ n = -1;
+ h = arr.length;
+ while (n+1> 1;
+ if (arr[m]=str
+}
+
+function AMgetSymbol(str) {
+//return maximal initial substring of str that appears in names
+//return null if there is none
+ var k = 0; //new pos
+ var j = 0; //old pos
+ var mk; //match pos
+ var st;
+ var tagst;
+ var match = "";
+ var more = true;
+ for (var i=1; i<=str.length && more; i++) {
+ st = str.slice(0,i); //initial substring of length i
+ j = k;
+ k = AMposition(AMnames, st, j);
+ if (k=AMnames[k];
+ }
+ AMpreviousSymbol=AMcurrentSymbol;
+ if (match!=""){
+ AMcurrentSymbol=AMsymbols[mk].ttype;
+ return AMsymbols[mk];
+ }
+// if str[0] is a digit or - return maxsubstring of digits.digits
+ AMcurrentSymbol=CONST;
+ k = 1;
+ st = str.slice(0,1);
+ var integ = true;
+ while ("0"<=st && st<="9" && k<=str.length) {
+ st = str.slice(k,k+1);
+ k++;
+ }
+ if (st == decimalsign) {
+ st = str.slice(k,k+1);
+ if ("0"<=st && st<="9") {
+ integ = false;
+ k++;
+ while ("0"<=st && st<="9" && k<=str.length) {
+ st = str.slice(k,k+1);
+ k++;
+ }
+ }
+ }
+ if ((integ && k>1) || k>2) {
+ st = str.slice(0,k-1);
+ tagst = "mn";
+ } else {
+ k = 2;
+ st = str.slice(0,1); //take 1 character
+ tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
+ }
+ if (st=="-" && AMpreviousSymbol==INFIX)
+ return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
+ return {input:st, tag:tagst, output:st, ttype:CONST};
+}
+
+function AMremoveBrackets(node) {
+ var st;
+ if (node.nodeName=="mrow") {
+ st = node.firstChild.firstChild.nodeValue;
+ if (st=="(" || st=="[" || st=="{") node.removeChild(node.firstChild);
+ }
+ if (node.nodeName=="mrow") {
+ st = node.lastChild.firstChild.nodeValue;
+ if (st==")" || st=="]" || st=="}") node.removeChild(node.lastChild);
+ }
+}
+
+/*Parsing ASCII math expressions with the following grammar
+v ::= [A-Za-z] | greek letters | numbers | other constant symbols
+u ::= sqrt | text | bb | other unary symbols for font commands
+b ::= frac | root | stackrel binary symbols
+l ::= ( | [ | { | (: | {: left brackets
+r ::= ) | ] | } | :) | :} right brackets
+S ::= v | lEr | uS | bSS Simple expression
+I ::= S_S | S^S | S_S^S | S Intermediate expression
+E ::= IE | I/I Expression
+Each terminal symbol is translated into a corresponding mathml node.*/
+
+var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol;
+
+function AMparseSexpr(str) { //parses str and returns [node,tailstr]
+ var symbol, node, result, i, st,// rightvert = false,
+ newFrag = document.createDocumentFragment();
+ str = AMremoveCharsAndBlanks(str,0);
+ symbol = AMgetSymbol(str); //either a token or a bracket or empty
+ if (symbol == null || symbol.ttype == RIGHTBRACKET && AMnestingDepth > 0) {
+ return [null,str];
+ }
+ if (symbol.ttype == DEFINITION) {
+ str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
+ symbol = AMgetSymbol(str);
+ }
+ switch (symbol.ttype) {
+ case UNDEROVER:
+ case CONST:
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ return [AMcreateMmlNode(symbol.tag, //its a constant
+ document.createTextNode(symbol.output)),str];
+ case LEFTBRACKET: //read (expr+)
+ AMnestingDepth++;
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ result = AMparseExpr(str,true);
+ AMnestingDepth--;
+ if (typeof symbol.invisible == "boolean" && symbol.invisible)
+ node = AMcreateMmlNode("mrow",result[0]);
+ else {
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
+ node = AMcreateMmlNode("mrow",node);
+ node.appendChild(result[0]);
+ }
+ return [node,result[1]];
+ case TEXT:
+ if (symbol!=AMquote) str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ if (str.charAt(0)=="{") i=str.indexOf("}");
+ else if (str.charAt(0)=="(") i=str.indexOf(")");
+ else if (str.charAt(0)=="[") i=str.indexOf("]");
+ else if (symbol==AMquote) i=str.slice(1).indexOf("\"")+1;
+ else i = 0;
+ if (i==-1) i = str.length;
+ st = str.slice(1,i);
+ if (st.charAt(0) == " ") {
+ node = AMcreateElementMathML("mspace");
+ node.setAttribute("width","1ex");
+ newFrag.appendChild(node);
+ }
+ newFrag.appendChild(
+ AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
+ if (st.charAt(st.length-1) == " ") {
+ node = AMcreateElementMathML("mspace");
+ node.setAttribute("width","1ex");
+ newFrag.appendChild(node);
+ }
+ str = AMremoveCharsAndBlanks(str,i+1);
+ return [AMcreateMmlNode("mrow",newFrag),str];
+ case UNARY:
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ result = AMparseSexpr(str);
+ if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
+ document.createTextNode(symbol.output)),str];
+ if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
+ st = str.charAt(0);
+ if (st=="^" || st=="_" || st=="/" || st=="|") {
+ return [AMcreateMmlNode(symbol.tag,
+ document.createTextNode(symbol.output)),str];
+ } else {
+ node = AMcreateMmlNode("mrow",
+ AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
+ node.appendChild(result[0]);
+ return [node,result[1]];
+ }
+ }
+ AMremoveBrackets(result[0]);
+ if (symbol.input == "sqrt") { // sqrt
+ return [AMcreateMmlNode(symbol.tag,result[0]),result[1]];
+ } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
+ node = AMcreateMmlNode(symbol.tag,result[0]);
+ node.appendChild(AMcreateMmlNode("mo",document.createTextNode(symbol.output)));
+ return [node,result[1]];
+ } else { // font change command
+ if (!isIE && typeof symbol.codes != "undefined") {
+ for (i=0; i64 && st.charCodeAt(j)<91) newst = newst +
+ String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
+ else newst = newst + st.charAt(j);
+ if (result[0].nodeName=="mi")
+ result[0]=AMcreateElementMathML("mo").
+ appendChild(document.createTextNode(newst));
+ else result[0].replaceChild(AMcreateElementMathML("mo").
+ appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
+ }
+ }
+ node = AMcreateMmlNode(symbol.tag,result[0]);
+ node.setAttribute(symbol.atname,symbol.atval);
+ return [node,result[1]];
+ }
+ case BINARY:
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ result = AMparseSexpr(str);
+ if (result[0]==null) return [AMcreateMmlNode("mo",
+ document.createTextNode(symbol.input)),str];
+ AMremoveBrackets(result[0]);
+ var result2 = AMparseSexpr(result[1]);
+ if (result2[0]==null) return [AMcreateMmlNode("mo",
+ document.createTextNode(symbol.input)),str];
+ AMremoveBrackets(result2[0]);
+ if (symbol.input=="root" || symbol.input=="stackrel")
+ newFrag.appendChild(result2[0]);
+ newFrag.appendChild(result[0]);
+ if (symbol.input=="frac") newFrag.appendChild(result2[0]);
+ return [AMcreateMmlNode(symbol.tag,newFrag),result2[1]];
+ case INFIX:
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str];
+ case SPACE:
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ node = AMcreateElementMathML("mspace");
+ node.setAttribute("width","1ex");
+ newFrag.appendChild(node);
+ newFrag.appendChild(
+ AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
+ node = AMcreateElementMathML("mspace");
+ node.setAttribute("width","1ex");
+ newFrag.appendChild(node);
+ return [AMcreateMmlNode("mrow",newFrag),str];
+ case LEFTRIGHT:
+// if (rightvert) return [null,str]; else rightvert = true;
+ AMnestingDepth++;
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ result = AMparseExpr(str,false);
+ AMnestingDepth--;
+ var st = "";
+ if (result[0].lastChild!=null)
+ st = result[0].lastChild.firstChild.nodeValue;
+//alert(result[0].lastChild+"***"+st);
+ if (st == "|") { // its an absolute value subterm
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
+ node = AMcreateMmlNode("mrow",node);
+ node.appendChild(result[0]);
+ return [node,result[1]];
+ } else { // the "|" is a \mid
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
+ node = AMcreateMmlNode("mrow",node);
+ return [node,str];
+ }
+ default:
+//alert("default");
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ return [AMcreateMmlNode(symbol.tag, //its a constant
+ document.createTextNode(symbol.output)),str];
+ }
+}
+
+function AMparseIexpr(str) {
+ var symbol, sym1, sym2, node, result, underover;
+ str = AMremoveCharsAndBlanks(str,0);
+ sym1 = AMgetSymbol(str);
+ result = AMparseSexpr(str);
+ node = result[0];
+ str = result[1];
+ symbol = AMgetSymbol(str);
+ if (symbol.ttype == INFIX && symbol.input != "/") {
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+// if (symbol.input == "/") result = AMparseIexpr(str); else ...
+ result = AMparseSexpr(str);
+ if (result[0] == null) // show box in place of missing argument
+ result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
+ else AMremoveBrackets(result[0]);
+ str = result[1];
+// if (symbol.input == "/") AMremoveBrackets(node);
+ if (symbol.input == "_") {
+ sym2 = AMgetSymbol(str);
+ underover = (sym1.ttype == UNDEROVER);
+ if (sym2.input == "^") {
+ str = AMremoveCharsAndBlanks(str,sym2.input.length);
+ var res2 = AMparseSexpr(str);
+ AMremoveBrackets(res2[0]);
+ str = res2[1];
+ node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
+ node.appendChild(result[0]);
+ node.appendChild(res2[0]);
+ node = AMcreateMmlNode("mrow",node); // so sum does not stretch
+ } else {
+ node = AMcreateMmlNode((underover?"munder":"msub"),node);
+ node.appendChild(result[0]);
+ }
+ } else {
+ node = AMcreateMmlNode(symbol.tag,node);
+ node.appendChild(result[0]);
+ }
+ }
+ return [node,str];
+}
+
+function AMparseExpr(str,rightbracket) {
+ var symbol, node, result, i, nodeList = [],
+ newFrag = document.createDocumentFragment();
+ do {
+ str = AMremoveCharsAndBlanks(str,0);
+ result = AMparseIexpr(str);
+ node = result[0];
+ str = result[1];
+ symbol = AMgetSymbol(str);
+ if (symbol.ttype == INFIX && symbol.input == "/") {
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ result = AMparseIexpr(str);
+ if (result[0] == null) // show box in place of missing argument
+ result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
+ else AMremoveBrackets(result[0]);
+ str = result[1];
+ AMremoveBrackets(node);
+ node = AMcreateMmlNode(symbol.tag,node);
+ node.appendChild(result[0]);
+ newFrag.appendChild(node);
+ symbol = AMgetSymbol(str);
+ }
+ else if (node!=undefined) newFrag.appendChild(node);
+ } while ((symbol.ttype != RIGHTBRACKET &&
+ (symbol.ttype != LEFTRIGHT || rightbracket)
+ || AMnestingDepth == 0) && symbol!=null && symbol.output!="");
+ if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) {
+// if (AMnestingDepth > 0) AMnestingDepth--;
+ var len = newFrag.childNodes.length;
+ if (len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
+ newFrag.childNodes[len-2].nodeName == "mo" &&
+ newFrag.childNodes[len-2].firstChild.nodeValue == ",") { //matrix
+ var right = newFrag.childNodes[len-1].lastChild.firstChild.nodeValue;
+ if (right==")" || right=="]") {
+ var left = newFrag.childNodes[len-1].firstChild.firstChild.nodeValue;
+ if (left=="(" && right==")" && symbol.output != "}" ||
+ left=="[" && right=="]") {
+ var pos = []; // positions of commas
+ var matrix = true;
+ var m = newFrag.childNodes.length;
+ for (i=0; matrix && i1) matrix = pos[i].length == pos[i-2].length;
+ }
+ if (matrix) {
+ var row, frag, n, k, table = document.createDocumentFragment();
+ for (i=0; i(-,-,...,-,-)
+ n = node.childNodes.length;
+ k = 0;
+ node.removeChild(node.firstChild); //remove (
+ for (j=1; j2) {
+ newFrag.removeChild(newFrag.firstChild); //remove )
+ newFrag.removeChild(newFrag.firstChild); //remove ,
+ }
+ table.appendChild(AMcreateMmlNode("mtr",row));
+ }
+ node = AMcreateMmlNode("mtable",table);
+ if (typeof symbol.invisible == "boolean" && symbol.invisible) node.setAttribute("columnalign","left");
+ newFrag.replaceChild(node,newFrag.firstChild);
+ }
+ }
+ }
+ }
+ str = AMremoveCharsAndBlanks(str,symbol.input.length);
+ if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
+ node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
+ newFrag.appendChild(node);
+ }
+ }
+ return [newFrag,str];
+}
+
+function AMparseMath(str) {
+ var result, node = AMcreateElementMathML("mstyle");
+ if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
+ if (displaystyle) node.setAttribute("displaystyle","true");
+ if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
+ AMnestingDepth = 0;
+ node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false)[0]);
+ node = AMcreateMmlNode("math",node);
+ if (showasciiformulaonhover) node.setAttribute("title",str);
+ if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
+ var fnode = AMcreateElementXHTML("font");
+ fnode.setAttribute("face",mathfontfamily);
+ fnode.appendChild(node);
+ return fnode;
+ }
+ return node;
+}
+
+function AMstrarr2docFrag(arr, linebreaks) {
+ var newFrag=document.createDocumentFragment();
+ var expr = false;
+ for (var i=0; i1 || mtch) {
+ if (checkForMathML) {
+ checkForMathML = false;
+ var nd = AMisMathMLavailable();
+ AMnoMathML = nd != null
+ if (AMnoMathML && notifyIfNoMathML)
+ AMbody.insertBefore(nd,AMbody.childNodes[0]);
+ }
+ if (!AMnoMathML) {
+ frg = AMstrarr2docFrag(arr,n.nodeType==8);
+ var len = frg.childNodes.length;
+ n.parentNode.replaceChild(frg,n);
+ return len-1;
+ } else return 0;
+ }
+ }
+ } else return 0;
+ } else if (n.nodeName!="math") {
+ for (i=0; i");
+ document.write("");
+}
+
+// GO1.1 Generic onload by Brothercake
+// http://www.brothercake.com/
+//onload function (replaces the onload="translate()" in the tag)
+function generic()
+{
+ translate();
+};
+//setup onload function
+if(typeof window.addEventListener != 'undefined')
+{
+ //.. gecko, safari, konqueror and standard
+ window.addEventListener('load', generic, false);
+}
+else if(typeof document.addEventListener != 'undefined')
+{
+ //.. opera 7
+ document.addEventListener('load', generic, false);
+}
+else if(typeof window.attachEvent != 'undefined')
+{
+ //.. win/ie
+ window.attachEvent('onload', generic);
+}
+//** remove this condition to degrade older browsers
+else
+{
+ //.. mac/ie5 and anything else that gets this far
+ //if there's an existing onload function
+ if(typeof window.onload == 'function')
+ {
+ //store it
+ var existing = onload;
+ //add new onload handler
+ window.onload = function()
+ {
+ //call existing onload function
+ existing();
+ //call generic onload function
+ generic();
+ };
+ }
+ else
+ {
+ //setup onload function
+ window.onload = generic;
+ }
+}
Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/equation.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/Attic/equation.js,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/equation.js 4 Jun 2006 00:45:50 -0000 1.3
+++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/Equation/equation.js 2 Feb 2007 21:04:51 -0000 1.4
@@ -1,146 +1,198 @@
-// Table Operations Plugin for HTMLArea-3.0
-// Implementation by Nazarij Dubnytskyj. Sponsored by NasCreative
-//
-// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
-// This notice MUST stay intact for use (see license.txt).
-//
-// A free WYSIWYG editor replacement for