Feature #541 - ASCIIMathML.js: The script for showing mathematical formulas has been upgraded from version 2.0.2 to version 2.1. Additional changes have been made in the online editor's plugin asciimath.

skala
Ivan Tcholakov 15 years ago
parent 56849590dc
commit fee17d67f5
  1. 1
      documentation/changelog.html
  2. 1115
      main/inc/lib/asciimath/ASCIIMathML.js
  3. 6
      main/inc/lib/fckeditor/editor/plugins/asciimath/fck_asciimath.html
  4. 2
      main/inc/lib/fckeditor/editor/plugins/asciimath/fck_asciimath.js
  5. 2
      main/inc/lib/fckeditor/editor/plugins/asciimath/fckplugin.js
  6. 2
      main/inc/lib/fckeditor/editor/plugins/asciimath/fckplugin_compressed.js
  7. 2
      main/inc/lib/fckeditor/editor/plugins/asciimath/readme.txt

@ -24,6 +24,7 @@
<h3>New Features</h3>
<ul>
<li>The mPDF library (which is used for PDF-files generation) has been upgraded from version 4.2 to version 4.6 (Feature #1656)</li>
<li>ASCIIMathML.js: The script for showing mathematical formulas has been upgraded from version 2.0.2 to version 2.1. Additional changes have been made in the online editor's plugin asciimath (Feature #541)</li>
</ul>
<h3>Debugging</h3>

File diff suppressed because it is too large Load Diff

@ -237,11 +237,13 @@ Original Author - Bernhard Pfeifer novocaine@gmx.net
<td style="width:50%;" nowrap="nowrap"><span fckLang="DlgAsciiMathInput">Input</span>&nbsp;&nbsp;<input id="clear" type="button" fckLang="DlgAsciiMathClear" onclick="javascript: Clear();" style="width: 100px; font-size: 10px;" value="Clear" />&nbsp;&nbsp;<input id="delete" type="button" fckLang="DlgAsciiMathDelete" onclick="javascript: Delete();" style="width: 100px; font-size: 10px;" value="Delete" />&nbsp;&nbsp;</td>
<td style="width:50%;"><input id="show_mathml" type="button" fckLang="DlgAsciiMathShowMathML" onclick="javascript: ShowMathML();" style="float: right; font-size: 10px;" value="Show MathML" /><span fckLang="DlgAsciiMathPreview">Preview</span></td>
</tr>
</table>
<table style="width: 100%; border: none;">
<tr>
<td>
<td style="width:50%;" >
<textarea id="inputText" onkeyup="javascript: Preview();"></textarea>
</td>
<td>
<td style="width:50%;" >
<div id="outputNode"></div>
</td>
</tr>

@ -141,7 +141,7 @@ function Preview()
{
var str = GetE( 'inputText' ).value ;
var outnode = GetE( 'outputNode' ) ;
var newnode = AMcreateElementXHTML( 'div' ) ;
var newnode = createElementXHTML( 'div' ) ;
newnode.setAttribute( 'id', 'outputNode' ) ;
outnode.parentNode.replaceChild( newnode, outnode ) ;
outnode = GetE( 'outputNode' ) ;

@ -22,7 +22,7 @@ translateASCIIMath = false ;
mathfontsize = "1.1em";
// Registering the related command.
FCKCommands.RegisterCommand( 'asciimath', new FCKDialogCommand( FCKLang['DlgAsciiMath'], FCKLang['DlgAsciiMath'], FCKConfig.PluginsPath + 'asciimath/fck_asciimath.html', 800, 550 ) ) ;
FCKCommands.RegisterCommand( 'asciimath', new FCKDialogCommand( FCKLang['DlgAsciiMath'], FCKLang['DlgAsciiMath'], FCKConfig.PluginsPath + 'asciimath/fck_asciimath.html', 800, 620 ) ) ;
// Create the "asciimath" toolbar button.
var oAsciiMathItem = new FCKToolbarButton( 'asciimath', FCKLang['DlgAsciiMath'] ) ;

@ -1 +1 @@
if (typeof AMprocessNode!='function'){LoadScript(FCKConfig.ScriptASCIIMathML);};notifyIfNoMathML=false;translateASCIIMath=false;mathfontsize="1.1em";FCKCommands.RegisterCommand('asciimath',new FCKDialogCommand(FCKLang['DlgAsciiMath'],FCKLang['DlgAsciiMath'],FCKConfig.PluginsPath+'asciimath/fck_asciimath.html',800,550));var oAsciiMathItem=new FCKToolbarButton('asciimath',FCKLang['DlgAsciiMath']);oAsciiMathItem.IconPath=FCKConfig.PluginsPath+'asciimath/asciimath.gif';FCKToolbarItems.RegisterItem('asciimath',oAsciiMathItem);FCK.ContextMenu.RegisterListener({AddItems:function(A,B,C){if (FCKAsciiMath.FindFormulaContainer(B)){A.AddSeparator();A.AddItem('asciimath',FCKLang['DlgAsciiMath'],oAsciiMathItem.IconPath);}}});FCK.RegisterDoubleClickHandler(function (A){if (FCKAsciiMath.FindFormulaContainer(A)){FCKCommands.GetCommand('asciimath').Execute();}},null);var FCKAsciiMath={};FCKAsciiMath.GetSearchElementFromSelection=function(){var A=FCK.Selection.GetSelectedElement();if (!A){A=FCK.Selection.GetBoundaryParentElement(true);};return A;};FCKAsciiMath.IsFormula=function(A){if (A&&A.nodeName&&A.nodeName.IEquals('span')&&A.className&&A.className.indexOf('AM')!=-1){return true;};return false;};FCKAsciiMath.FindFormulaContainer=function(A){var B=A;while (B){if (!B.nodeName){continue;};if (B.nodeName.IEquals('body','table')){break;};if (FCKAsciiMath.IsFormula(B)){return B;};if (B.parentNode){B=B.parentNode;}else{break;}};return null;};FCKAsciiMath.IsParsed=function(A){return A.getElementsByTagName('math')[0]?true:false;};FCKAsciiMath.GetFormula=function(A){var B='';if (FCKAsciiMath.IsFormula(A)){if (FCKAsciiMath.IsParsed(A)){if (A.title){B=A.title;}}else{B=A.innerHTML;}};return B.replace(/`/g,'');};FCKAsciiMath.Delete=function(){var A=FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection());if (A){FCK.Selection.SelectNode(A);}else{return;};if (FCKBrowserInfo.IsIE){var B=FCK.EditorDocument.createElement('span');B.innerHTML='&nbsp;';B=A.parentNode.insertBefore(B,A);FCK.Selection.SelectNode(B);};FCK.Selection.Delete();if (FCKBrowserInfo.IsIE){FCKUndo.SaveUndoStep();A.parentNode.removeChild(A);}};var FCKAsciiMathProcessor=FCKDocumentProcessor.AppendNew();FCKAsciiMathProcessor.ProcessDocument=function(A){var B=FCK.EditorDocument.getElementsByTagName('SPAN');var C;var i=B.length-1;while (i>=0&&(C=B[i--])){if (FCKAsciiMath.IsFormula(C)&&!FCKAsciiMath.IsParsed (C)){var D=C.cloneNode(true);D.title=C.innerHTML;AMprocessNode(D,false);D.setAttribute('_fckfakelement','true',0);D.setAttribute('_fckrealelement',FCKTempBin.AddElement(C),0);D.onresizestart=function(){FCK.EditorWindow.event.returnValue=false;return false;};C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);}}};FCKAsciiMath.SetListeners=function(){if (FCK.EditMode!=FCK_EDITMODE_WYSIWYG){return;};if (!FCKBrowserInfo.IsIE){FCK.EditorDocument.addEventListener('click',function(e){var A=FCKAsciiMath.FindFormulaContainer(e.target);if (A){FCKSelection.SelectNode(A);}},true);FCK.EditorDocument.addEventListener('keypress',function(e){var B=e.keyCode||e.which;switch (B){case 37:case 39:case 38:case 40:case 36:case 35:case 33:case 34:break;case 8:case 46:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){FCKAsciiMath.Delete();if (e.preventDefault) e.preventDefault();if (e.stopPropagation) e.stopPropagation();break;};default:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){if (e.preventDefault) e.preventDefault();if (e.stopPropagation) e.stopPropagation();};break;}},true);}else{FCKAsciiMath.KeyDownIE=function(e){if (!e) e=window.event;var B=e.keyCode;switch (B){case 8:case 46:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){FCKAsciiMath.Delete();e.cancelBubble=true;break;};default:break;}};FCKTools.AddEventListener(FCK.EditorDocument.body,'keydown',FCKAsciiMath.KeyDownIE);}};FCK.Events.AttachEvent('OnAfterSetHTML',FCKAsciiMath.SetListeners);FCK.UpdateLinkedField=function(){if (FCKConfig.FullPage){var A=FCK.EditorDocument.getElementsByTagName('html')[0];var B;if (typeof A=='object'){B=A.getElementsByTagName('HEAD')[0];};if (typeof B=='object'){var C=false;var D=FCK.EditorDocument.getElementsByTagName('SPAN');var E;var i=D.length-1;while (i>=0&&(E=D[i--])){if (FCKAsciiMath.IsFormula(E)){C=true;break;}};var F=false;var G=FCK.GetData(false);if (G){G=G.toString().match(/<head\s?[^>]*>(.*?)<\/head\s*>/i);if (G&&G.toString().indexOf('ASCIIMathML.js')!=-1){F=true;}};if (C&&!F){script=FCK.EditorDocument.createElement('script');script.setAttribute('src',FCKConfig.ScriptASCIIMathML);script.setAttribute('type','text/javascript');B.appendChild(script);}}};var H=FCK.GetData(FCKConfig.FormatOutput);if (FCKConfig.HtmlEncodeOutput) H=FCKTools.HTMLEncode(H);FCK.LinkedField.value=H;FCK.Events.FireEvent('OnAfterLinkedFieldUpdate');};
if (typeof AMprocessNode!='function'){LoadScript(FCKConfig.ScriptASCIIMathML);};notifyIfNoMathML=false;translateASCIIMath=false;mathfontsize="1.1em";FCKCommands.RegisterCommand('asciimath',new FCKDialogCommand(FCKLang['DlgAsciiMath'],FCKLang['DlgAsciiMath'],FCKConfig.PluginsPath+'asciimath/fck_asciimath.html',800,620));var oAsciiMathItem=new FCKToolbarButton('asciimath',FCKLang['DlgAsciiMath']);oAsciiMathItem.IconPath=FCKConfig.PluginsPath+'asciimath/asciimath.gif';FCKToolbarItems.RegisterItem('asciimath',oAsciiMathItem);FCK.ContextMenu.RegisterListener({AddItems:function(A,B,C){if (FCKAsciiMath.FindFormulaContainer(B)){A.AddSeparator();A.AddItem('asciimath',FCKLang['DlgAsciiMath'],oAsciiMathItem.IconPath);}}});FCK.RegisterDoubleClickHandler(function (A){if (FCKAsciiMath.FindFormulaContainer(A)){FCKCommands.GetCommand('asciimath').Execute();}},null);var FCKAsciiMath={};FCKAsciiMath.GetSearchElementFromSelection=function(){var A=FCK.Selection.GetSelectedElement();if (!A){A=FCK.Selection.GetBoundaryParentElement(true);};return A;};FCKAsciiMath.IsFormula=function(A){if (A&&A.nodeName&&A.nodeName.IEquals('span')&&A.className&&A.className.indexOf('AM')!=-1){return true;};return false;};FCKAsciiMath.FindFormulaContainer=function(A){var B=A;while (B){if (!B.nodeName){continue;};if (B.nodeName.IEquals('body','table')){break;};if (FCKAsciiMath.IsFormula(B)){return B;};if (B.parentNode){B=B.parentNode;}else{break;}};return null;};FCKAsciiMath.IsParsed=function(A){return A.getElementsByTagName('math')[0]?true:false;};FCKAsciiMath.GetFormula=function(A){var B='';if (FCKAsciiMath.IsFormula(A)){if (FCKAsciiMath.IsParsed(A)){if (A.title){B=A.title;}}else{B=A.innerHTML;}};return B.replace(/`/g,'');};FCKAsciiMath.Delete=function(){var A=FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection());if (A){FCK.Selection.SelectNode(A);}else{return;};if (FCKBrowserInfo.IsIE){var B=FCK.EditorDocument.createElement('span');B.innerHTML='&nbsp;';B=A.parentNode.insertBefore(B,A);FCK.Selection.SelectNode(B);};FCK.Selection.Delete();if (FCKBrowserInfo.IsIE){FCKUndo.SaveUndoStep();A.parentNode.removeChild(A);}};var FCKAsciiMathProcessor=FCKDocumentProcessor.AppendNew();FCKAsciiMathProcessor.ProcessDocument=function(A){var B=FCK.EditorDocument.getElementsByTagName('SPAN');var C;var i=B.length-1;while (i>=0&&(C=B[i--])){if (FCKAsciiMath.IsFormula(C)&&!FCKAsciiMath.IsParsed (C)){var D=C.cloneNode(true);D.title=C.innerHTML;AMprocessNode(D,false);D.setAttribute('_fckfakelement','true',0);D.setAttribute('_fckrealelement',FCKTempBin.AddElement(C),0);D.onresizestart=function(){FCK.EditorWindow.event.returnValue=false;return false;};C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);}}};FCKAsciiMath.SetListeners=function(){if (FCK.EditMode!=FCK_EDITMODE_WYSIWYG){return;};if (!FCKBrowserInfo.IsIE){FCK.EditorDocument.addEventListener('click',function(e){var A=FCKAsciiMath.FindFormulaContainer(e.target);if (A){FCKSelection.SelectNode(A);}},true);FCK.EditorDocument.addEventListener('keypress',function(e){var B=e.keyCode||e.which;switch (B){case 37:case 39:case 38:case 40:case 36:case 35:case 33:case 34:break;case 8:case 46:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){FCKAsciiMath.Delete();if (e.preventDefault) e.preventDefault();if (e.stopPropagation) e.stopPropagation();break;};default:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){if (e.preventDefault) e.preventDefault();if (e.stopPropagation) e.stopPropagation();};break;}},true);}else{FCKAsciiMath.KeyDownIE=function(e){if (!e) e=window.event;var B=e.keyCode;switch (B){case 8:case 46:if (FCKAsciiMath.FindFormulaContainer(FCKAsciiMath.GetSearchElementFromSelection())){FCKAsciiMath.Delete();e.cancelBubble=true;break;};default:break;}};FCKTools.AddEventListener(FCK.EditorDocument.body,'keydown',FCKAsciiMath.KeyDownIE);}};FCK.Events.AttachEvent('OnAfterSetHTML',FCKAsciiMath.SetListeners);FCK.UpdateLinkedField=function(){if (FCKConfig.FullPage){var A=FCK.EditorDocument.getElementsByTagName('html')[0];var B;if (typeof A=='object'){B=A.getElementsByTagName('HEAD')[0];};if (typeof B=='object'){var C=false;var D=FCK.EditorDocument.getElementsByTagName('SPAN');var E;var i=D.length-1;while (i>=0&&(E=D[i--])){if (FCKAsciiMath.IsFormula(E)){C=true;break;}};var F=false;var G=FCK.GetData(false);if (G){G=G.toString().match(/<head\s?[^>]*>(.*?)<\/head\s*>/i);if (G&&G.toString().indexOf('ASCIIMathML.js')!=-1){F=true;}};if (C&&!F){script=FCK.EditorDocument.createElement('script');script.setAttribute('src',FCKConfig.ScriptASCIIMathML);script.setAttribute('type','text/javascript');B.appendChild(script);}}};var H=FCK.GetData(FCKConfig.FormatOutput);if (FCKConfig.HtmlEncodeOutput) H=FCKTools.HTMLEncode(H);FCK.LinkedField.value=H;FCK.Events.FireEvent('OnAfterLinkedFieldUpdate');};

@ -2,7 +2,7 @@
AsciiMathML formula editor for Chamilo LMS
Author: Ivan Tcholakov <ivantcholakov@gmail.com>
February 2010 - adapted for Chamilo LMS
February 2010, July 2010 - adapted for Chamilo LMS
August 2009 - initial implementation for Dokeos LMS
This work is a port for the FCKEditor of Equation plugin for the Xinha editor (http://xinha.org)

Loading…
Cancel
Save