etherpad-lite/static/js/ace.js.old

30 lines
122 KiB
JavaScript
Raw Normal View History

2011-03-26 14:10:41 +01:00
Ace2Editor.registry={nextId:1};function Ace2Editor(){var K="Ace2Editor";var F=Ace2Editor;var B={};var A={editor:B,id:(F.registry.nextId++)};
var D=false;var E=[];function C(R,Q){return function(){var T=this;var S=arguments;function U(){R.apply(T,S);
}if(Q){Q.apply(T,S);}if(D){U();}else{E.push(U);}};}function I(){for(var Q=0;Q<E.length;Q++){E[Q]();}E=[];
}F.registry[A.id]=A;B.importText=C(function(R,Q){A.ace_importText(R,Q);});B.importAText=C(function(R,S,Q){A.ace_importAText(R,S,Q);
});B.exportText=function(){if(!D){return"(awaiting init)\n";}return A.ace_exportText();};B.getFrame=function(){return A.frame||null;
};B.focus=C(function(){A.ace_focus();});B.setEditable=C(function(Q){A.ace_setEditable(Q);});B.getFormattedCode=function(){return A.ace_getFormattedCode();
};B.setOnKeyPress=C(function(Q){A.ace_setOnKeyPress(Q);});B.setOnKeyDown=C(function(Q){A.ace_setOnKeyDown(Q);
});B.setNotifyDirty=C(function(Q){A.ace_setNotifyDirty(Q);});B.setProperty=C(function(Q,R){A.ace_setProperty(Q,R);
});B.getDebugProperty=function(Q){return A.ace_getDebugProperty(Q);};B.setBaseText=C(function(Q){A.ace_setBaseText(Q);
});B.setBaseAttributedText=C(function(R,Q){A.ace_setBaseAttributedText(R,Q);});B.applyChangesToBase=C(function(R,Q,S){A.ace_applyChangesToBase(R,Q,S);
});B.prepareUserChangeset=function(){if(!D){return null;}return A.ace_prepareUserChangeset();};B.applyPreparedChangesetToBase=C(function(){A.ace_applyPreparedChangesetToBase();
});B.setUserChangeNotificationCallback=C(function(Q){A.ace_setUserChangeNotificationCallback(Q);});B.setAuthorInfo=C(function(R,Q){A.ace_setAuthorInfo(R,Q);
});B.setAuthorSelectionRange=C(function(R,S,Q){A.ace_setAuthorSelectionRange(R,S,Q);});B.getUnhandledErrors=function(){if(!D){return[];
}return A.ace_getUnhandledErrors();};B.callWithAce=C(function(S,R,Q){return A.ace_callWithAce(S,R,Q);
});B.execCommand=C(function(R,Q){A.ace_execCommand(R,Q);});B.replaceRange=C(function(S,Q,R){A.ace_replaceRange(S,Q,R);
});var H=function(Q){return'<link rel="stylesheet" type="text/css" href="'+Q+'"/>';};var J=function(Q){return'\x3cscript type="text/javascript" src="'+Q+'">\x3c/script>';
};var M=J;var N=H;var L=function(Q){return'\'<link rel="stylesheet" type="text/css" href="'+Q+"\"/>'";
};var G=function(Q){return'\'\\x3cscript type="text/javascript" src="'+Q+"\">\\x3c/script>'";};var P=G;
var O=L;B.destroy=C(function(){A.ace_dispose();A.frame.parentNode.removeChild(A.frame);delete F.registry[A.id];
A=null;});B.init=function(Q,S,R){B.importText(S);A.onEditorReady=function(){D=true;I();R();};(function(){var W='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
var T=["'"+W+"<html><head>'"];plugins.callHook("aceInitInnerdocbodyHead",{iframeHTML:T});T.push(("('<style type=\"text/css\">'+'body{margin:0;white-space:nowrap;}#outerdocbody{background-color:#fff;}body.grayedout{background-color:#eee!important;}#innerdocbody{font-size:12px;font-family:monospace;line-height:16px;}body.doesWrap{white-space:normal;}#innerdocbody{padding-top:1px;padding-right:10px;padding-bottom:8px;padding-left:1px;overflow:hidden;background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==);}#sidediv{font-size:11px;font-family:monospace;line-height:16px;padding-top:8px;padding-right:3px;position:absolute;width:20px;top:0;left:0;cursor:default;color:white;}#sidedivinner{text-align:right;}.sidedivdelayed{background-color:#eee;color:#888!important;border-right:1px solid #999;}.sidedivhidden{display:none;}#outerdocbody iframe{display:block;position:relative;left:32px;top:7px;border:0;width:1px;height:1px;}#outerdocbody .hotrect{border:1px solid #999;position:absolute;}body.mozilla,body.safari{display:table-cell;}body.doesWrap{display:block!important;}.safari div{padding-right:1px;}p{margin:0;}#linemetricsdiv{position:absolute;left:-1000px;top:-1000px;color:white;z-index:-1;font-size:12px;font-family:monospace;}#overlaysdiv{position:absolute;left:-1000px;top:-1000px;}.syntax .c{color:#bd3f00;font-style:italic;}.syntax .o{font-weight:bold;}.syntax .p{font-weight:bold;}.syntax .k{color:blue;}.syntax .kc{color:purple;}.syntax .mf{color:purple;}.syntax .mh{color:purple;}.syntax .mi{color:purple;}.syntax .sr{color:purple;}.syntax .s2{color:purple;}.syntax .s1{color:purple;}.syntax .sd{color:purple;}.syntax .cs{color:#0a3;font-weight:bold;font-style:italic;}.syntax .err{color:#c00;font-weight:bold;text-decoration:underline;}.syntax .nt{font-weight:bold;}.syntax .nc{color:#336;}.syntax .nf{color:#336;}.syntax .nd{color:#999;}.syntax .m{color:purple;}.syntax .nb{color:purple;}.syntax .cp{color:#bd3f00;}.syntax .flash{background-color:#adf!important;}.syntax .flashbad{background-color:#f55!important;}html{cursor:text;}span{cursor:auto;}a{cursor:pointer!important;}ul,ol,li{padding:0;margin:0;}ul{margin-left:1.5em;}ul ul{margin-left:0!important;}ul.list-bullet1{margin-left:1.5em;}ul.list-bullet2{margin-left:3em;}ul.list-bullet3{margin-left:4.5em;}ul.list-bullet4{margin-left:6em;}ul.list-bullet5{margin-left:7.5em;}ul.list-bullet6{margin-left:9em;}ul.list-bullet7{margin-left:10.5em;}ul.list-bullet8{margin-left:12em;}ul{list-style-type:disc;}ul.list-bullet1{list-style-type:disc;}ul.list-bullet2{list-style-type:circle;}ul.list-bullet3{list-style-type:square;}ul.list-bullet4{list-style-type:disc;}ul.list-bullet5{list-style-type:circle;}ul.list-bullet6{list-style-type:square;}ul.list-bullet7{list-style-type:disc;}ul.list-bullet8{list-style-type:circle;}'+'\\x3c/style>')"));
T.push(('(\'\\x3cscript type="text/javascript">//<!--\\n\'+\'function isNodeText(A){return(A.nodeType==3);}function object(B){var A=function(){};A.prototype=B;return new A();\\n}function extend(C,A){for(var B in A){C[B]=A[B];}return C;}function forEach(B,D){for(var A=0;A\\x3cB.length;\\nA++){var C=D(B[A],A);if(C){break;}}}function map(C,D){var B=[];for(var A=0;A\\x3cC.length;A++){if(D){B.push(D(C[A],A));\\n}else{B.push(C[A]);}}return B;}function filter(B,D){var C=[];for(var A=0;A\\x3cB.length;A++){if(D(B[A],A)){C.push(B[A]);\\n}}return C;}function isArray(A){return A&&typeof A==="object"&&!(A.propertyIsEnumerable("length"))&&typeof A.length==="number";\\n}var userAgent=navigator.userAgent.toLowerCase();var browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\\\\\\x2f: ]([\\\\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent),windows:/windows/.test(userAgent)};\\nfunction getAssoc(B,A){return B["_magicdom_"+A];}function setAssoc(C,A,B){C["_magicdom_"+A]=B;}function binarySearch(A,E){if(A\\x3c1){return 0;\\n}if(E(0)){return 0;}if(!E(A-1)){return A;}var D=0;var B=A-1;while((B-D)>1){var C=Math.floor((D+B)/2);\\nif(E(C)){B=C;}else{D=C;}}return B;}function binarySearchInfinite(C,B){var A=0;while(!B(A)){A+=C;}return binarySearch(A,B);\\n}function htmlPrettyEscape(A){return A.replace(/&/g,"&amp;").replace(/\\x3c/g,"&lt;").replace(/>/g,"&gt;").replace(/\\\\r?\\\\n/g,"\\\\\\\\n");\\n}function newSkipList(){var H=window.PROFILER;if(!H){H=function(){return{start:G,mark:G,literal:G,end:G,cancel:G};\\n};}function G(){}var B={key:null,levels:1,upPtrs:[null],downPtrs:[null],downSkips:[1],downSkipWidths:[0]};\\nvar E={key:null,levels:1,upPtrs:[null],downPtrs:[null],downSkips:[null],downSkipWidths:[null]};var A=0;\\nvar D=0;var I={};B.downPtrs[0]=E;E.upPtrs[0]=B;function J(Z){var W=B.levels;var T=W-1;var X=-1,b=0;var V=new Array(W);\\nvar Y=new Array(W);var a=new Array(W);V[T]=B;Y[T]=-1;a[T]=0;while(T>=0){var U=V[T];while(U.downPtrs[T]&&(X+U.downSkips[T]\\x3cZ)){X+=U.downSkips[T];\\nb+=U.downSkipWidths[T];U=U.downPtrs[T];}V[T]=U;Y[T]=X;a[T]=b;T--;if(T>=0){V[T]=U;}}return{nodes:V,idxs:Y,loc:Z,widthSkips:a,toString:function(){return"getPoint("+Z+")";\\n}};}function P(W){var V=0;var T=B;var U=B.levels-1;while(U>=0&&T.downPtrs[U]){while(T.downPtrs[U]&&(V+T.downSkipWidths[U]\\x3c=W)){V+=T.downSkipWidths[U];\\nT=T.downPtrs[U];}U--;}if(T===B){return(B.downPtrs[0]||null);}else{if(T===E){return(W==D?(E.upPtrs[0]||null):null);\\n}}return T;}function K(T){return(T&&T.width)||0;}function N(V,f,h){var X=H("insertKey",false);var W={key:f,levels:0,upPtrs:[],downPtrs:[],downSkips:[],downSkipWidths:[]};\\nX.mark("donealloc");var Y=V.nodes;var e=V.idxs;var k=V.loc;var j=V.widthSkips[0]+V.nodes[0].downSkipWidths[0];\\nvar a=K(h);X.mark("loop1");while(W.levels==0||Math.random()\\x3c0.01){var T=W.levels;W.levels++;if(T==Y.length){Y[T]=B;\\ne[T]=-1;B.levels++;E.levels++;B.downPtrs[T]=E;E.upPtrs[T]=B;B.downSkips[T]=A+1;B.downSkipWidths[T]=D;\\nV.widthSkips[T]=0;}var Z=W;var U=Y[T];var d=U.downPtrs[T];var b=k-e[T];var g=U.downSkips[T]+1-b;U.downSkips[T]=b;\\nU.downPtrs[T]=Z;Z.downSkips[T]=g;Z.upPtrs[T]=U;Z.downPtrs[T]=d;d.upPtrs[T]=Z;var c=j-V.widthSkips[T];\\nvar i=U.downSkipWidths[T]+a-c;U.downSkipWidths[T]=c;Z.downSkipWidths[T]=i;}X.mark("loop2");X.literal(Y.length,"PNL");\\nfor(var T=W.levels;T\\x3cY.length;T++){var U=Y[T];U.downSkips[T]++;U.downSkipWidths[T]+=a;}X.mark("map");\\nI["$KEY$"+f]=W;A++;D+=a;X.end();}function O(T){return T.nodes[0].downPtrs[0];}function S(U){U.loc++;for(var T=0;\\nT\\x3cU.nodes.length;T++){if(U.idxs[T]+U.nodes[T].downSkips[T]\\x3cU.loc){U.idxs[T]+=U.nodes[T].downSkips[T];\\nU.widthSkips[T]+=U.nodes[T].downSkipWidths[T];U.nodes[T]=U.nodes[T].downPtrs[T];}}}function M(W){var V=W.nodes[0].downPtrs[0];\\nvar X=K(V.entry);for(var T=0;T\\x3cW.nodes.length;T++){if(T\\x3cV.levels){var U=V.upPtrs[T];var Y=V.downPtrs[T];\\nvar a=U.downSkips[T]+V.downSkips[T]-1;U.downPtrs[T]=Y;Y.upPtrs[
T.push(('(\'\\x3cscript type="text/javascript">//<!--\\n\'+\'function OUTER(Ck){var AK=false;var B4=false;var Ad=" ";var BW=8;var BO=4;var CD=4;var Ah=20;var Bj=8;\\nvar BS=8;var BU=[];var e="";var BL=false;var C=parent.editorInfo;var f=window.frameElement;var F=f.ace_outerWin;\\nf.ace_outerWin=null;var W=f.nextSibling;var u=W.nextSibling;var Cc=u.nextSibling;BX();var At=function(i){};\\nvar Ar=function(i){return true;};var An=function(){};var A={lines:newSkipList(),selStart:null,selEnd:null,selFocusAtStart:false,alltext:"",alines:[],apool:new AttribPool()};\\nif(undoModule.enabled){undoModule.apool=A.apool;}var B,E;var q=true;var K=true;var AP=true;var AX=true;\\nvar n=Ah+BO+BS;var Aj=Bj;var Bo=0,CR=0;var V=(AK&&top.console);if(!V){var Al=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];\\nV={};for(var Ag=0;Ag\\x3cAl.length;++Ag){V[Al[Ag]]=function(){};}}var Q=window.PROFILER;if(!Q){Q=function(){return{start:I,mark:I,literal:I,end:I,cancel:I};\\n};}function I(){}function Cf(i){return i;}var t=I;window.dmesg=I;var O=parent;var AQ="monospace";var s=12;\\nfunction AV(){return Math.round(s*4/3);}var Y=null;function Bi(){Y=makeCSSManager("dynamicsyntax");}var M=makeChangesetTracker(O,A.apool,{withCallbacks:function(i,Cq){T(i,function(){G(1);\\nCq({setDocumentAttributedText:function(Cr){Aa(Cr);},applyChangesetToDocument:function(Ct,Cs){var Cr=D.editEvent.eventType;\\nD.startNewEvent("nonundoable");c(Ct,Cs);D.startNewEvent(Cr);}});});}});var Ao={};function CW(i,Cq){if((typeof i)!="string"){throw new Error("setAuthorInfo: author ("+i+") is not a string");\\n}if(!Cq){delete Ao[i];if(Y){Y.removeSelectorStyle(Au(BP(i)));}}else{Ao[i]=Cq;if(Cq.bgcolor){if(Y){var Cr=Cq.bgcolor;\\nif((typeof Cq.fade)=="number"){Cr=BZ(Cr,Cq.fade);}Y.selectorStyle(Au(BP(i))).backgroundColor=Cr;}}}}function BP(i){return"author-"+i.replace(/[^a-y0-9]/g,function(Cq){if(Cq=="."){return"-";\\n}return"z"+Cq.charCodeAt(0)+"z";});}function Bd(i){if(i.substring(0,7)=="author-"){return i.substring(7).replace(/[a-y0-9]+|-|z.+?z/g,function(Cq){if(Cq=="-"){return".";\\n}else{if(Cq.charAt(0)=="z"){return String.fromCharCode(Number(Cq.slice(1,-1)));}else{return Cq;}}});}return null;\\n}function Au(i){return".authorColors ."+i;}function AT(){if(Y){var Cq=u.offsetHeight;var Cr=AV();var i=0;\\nvar Ct=0;if(Cq\\x3cCr){i=Math.ceil((Cr-Cq)/2);Ct=Cr-Cq-i;}var Cs=Y.selectorStyle("#innerdocbody span");Cs.paddingTop=Ct+"px";\\nCs.paddingBottom=i+"px";}}function Cj(Cq){var i=colorutils.css2triple(Cq);i=colorutils.saturate(i);i=colorutils.scaleColor(i,0,0.5/colorutils.luminosity(i));\\nreturn colorutils.triple2css(i);}function BZ(Cq,Cr){var i=colorutils.css2triple(Cq);i=colorutils.blend(i,[1,1,1],Cr);\\nreturn colorutils.triple2css(i);}function By(i){O.setTimeout(function(){alert(i);},0);}C.ace_getRep=function(){return A;\\n};var D=null;function N(Cr,Cy){if(BL){return;}if(D){V.error("Can\\\'t enter callstack "+Cr+", already in "+D.type);\\n}var Cu=false;function Cx(){Cu=true;V.profile();}function Cs(C0){return{eventType:C0,backset:null};}function Ct(C0){if(A.selStart&&A.selEnd){var C3=A.lines.offsetOfIndex(A.selStart[0])+A.selStart[1];\\nvar C2=A.lines.offsetOfIndex(A.selEnd[0])+A.selEnd[1];C0.selStart=C3;C0.selEnd=C2;C0.selFocusAtStart=A.selFocusAtStart;\\n}if(undoModule.enabled){var C1=false;try{if(C0.eventType=="setup"||C0.eventType=="importText"||C0.eventType=="setBaseText"){undoModule.clearHistory();\\n}else{if(C0.eventType=="nonundoable"){if(C0.changeset){undoModule.reportExternalChange(C0.changeset);\\n}}else{undoModule.reportEvent(C0);}}C1=true;}finally{if(!C1){undoModule.enabled=false;}}}}function Cz(C2,C1){var C0=D.editEvent;\\nif(!C1){Ct(C0);}D.editEvent=Cs(C2);return C0;}D={type:Cr,docTextChanged:false,selectionAffected:false,userChangedSelection:false,domClean:false,profileRest:Cx,isUserChange:false,repChanged:false,editEvent:Cs(Cr),startNewEvent:Cz};\\nvar Cv=false;var Cw;try{Cw=Cy();Cv=true;}catch(Cq){BU.push({error:Cq,time:+new Date()});t(Cq.toString());\\nthrow Cq;}finally{
T.push('\'\\n<style type="text/css" title="dynamicsyntax"></style>\\n\'');T.push('\'</head><body id="innerdocbody" class="syntax" spellcheck="false">&nbsp;</body></html>\'');
var X='editorId = "'+A.id+'"; editorInfo = parent.'+K+'.registry[editorId]; window.onload = function() { window.onload = null; setTimeout(function() { var iframe = document.createElement("IFRAME"); iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); iframe.frameBorder = 0; iframe.allowTransparency = true; outerdocbody.insertBefore(iframe, outerdocbody.firstChild); iframe.ace_outerWin = window; readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; var doc = iframe.contentWindow.document; doc.open(); doc.write('+T.join("+")+"); doc.close(); }, 0); }";
var Y=[W,"<html><head>",('<style type="text/css">body{margin:0;white-space:nowrap;}#outerdocbody{background-color:#fff;}body.grayedout{background-color:#eee!important;}#innerdocbody{font-size:12px;font-family:monospace;line-height:16px;}body.doesWrap{white-space:normal;}#innerdocbody{padding-top:1px;padding-right:10px;padding-bottom:8px;padding-left:1px;overflow:hidden;background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==);}#sidediv{font-size:11px;font-family:monospace;line-height:16px;padding-top:8px;padding-right:3px;position:absolute;width:20px;top:0;left:0;cursor:default;color:white;}#sidedivinner{text-align:right;}.sidedivdelayed{background-color:#eee;color:#888!important;border-right:1px solid #999;}.sidedivhidden{display:none;}#outerdocbody iframe{display:block;position:relative;left:32px;top:7px;border:0;width:1px;height:1px;}#outerdocbody .hotrect{border:1px solid #999;position:absolute;}body.mozilla,body.safari{display:table-cell;}body.doesWrap{display:block!important;}.safari div{padding-right:1px;}p{margin:0;}#linemetricsdiv{position:absolute;left:-1000px;top:-1000px;color:white;z-index:-1;font-size:12px;font-family:monospace;}#overlaysdiv{position:absolute;left:-1000px;top:-1000px;}</style>'),'<link rel="stylesheet" type="text/css" href="data:text/css,"/>',"\x3cscript>",X,"\x3c/script>",'</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>'];
if(!Array.prototype.map){Array.prototype.map=function(b){if(typeof b!="function"){throw new TypeError();
}var a=this.length;var c=new Array(a);var d=arguments[1];for(var Z=0;Z<a;Z++){if(Z in this){c[Z]=b.call(d,this[Z],Z,this);
}}return c;};}var U=document.createElement("IFRAME");U.frameBorder=0;A.frame=U;document.getElementById(Q).appendChild(U);
var V=U.contentWindow.document;V.open();V.write(Y.join(""));V.close();})();};return B;}