function EAL ( ) {
var t = this ; t . version = "0.8.2" ; date = new Date ( ) ; t . start _time = date . getTime ( ) ; t . win = "loading" ; t . error = false ; t . baseURL = "" ; t . template = "" ; t . lang = { } ; t . load _syntax = { } ; t . syntax = { } ; t . loadedFiles = [ ] ; t . waiting _loading = { } ; t . scripts _to _load = [ ] ; t . sub _scripts _to _load = [ ] ; t . syntax _display _name = { 'basic' : 'Basic' , 'brainfuck' : 'Brainfuck' , 'c' : 'C' , 'coldfusion' : 'Coldfusion' , 'cpp' : 'CPP' , 'css' : 'CSS' , 'html' : 'HTML' , 'java' : 'Java' , 'js' : 'Javascript' , 'pas' : 'Pascal' , 'perl' : 'Perl' , 'php' : 'Php' , 'python' : 'Python' , 'robotstxt' : 'Robots txt' , 'ruby' : 'Ruby' , 'sql' : 'SQL' , 'tsql' : 'T-SQL' , 'vb' : 'Visual Basic' , 'xml' : 'XML' , 'bash' : 'Bash' , 'mock' : 'Mock' } ; t . resize = [ ] ; t . hidden = { } ; t . default _settings = { debug : false , smooth _selection : true , font _size : "10" , font _family : "monospace" , start _highlight : false , toolbar : "search,go_to_line,fullscreen,|,undo,redo,|,select_font,|,change_smooth_selection,highlight,reset_highlight,word_wrap,|,help" , begin _toolbar : "" , end _toolbar : "" , is _multi _files : false , allow _resize : "both" , show _line _colors : false , min _width : 400 , min _height : 125 , replace _tab _by _spaces : false , allow _toggle : true , language : "en" , syntax : "" , syntax _selection _allow : "basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml,bash, mock" , display : "onload" , max _undo : 30 , browsers : "known" , plugins : "" , gecko _spellcheck : false , fullscreen : false , is _editable : true , cursor _position : "begin" , word _wrap : false , autocompletion : false , load _callback : "" , save _callback : "" , change _callback : "" , submit _callback : "" , EA _init _callback : "" , EA _delete _callback : "" , EA _load _callback : "" , EA _unload _callback : "" , EA _toggle _on _callback : "" , EA _toggle _off _callback : "" , EA _file _switch _on _callback : "" , EA _file _switch _off _callback : "" , EA _file _close _callback : "" } ; t . advanced _buttons = [ [ 'new_document' , 'newdocument.gif' , 'new_document' , false ] , [ 'search' , 'search.gif' , 'show_search' , false ] , [ 'go_to_line' , 'go_to_line.gif' , 'go_to_line' , false ] , [ 'undo' , 'undo.gif' , 'undo' , true ] , [ 'redo' , 'redo.gif' , 'redo' , true ] , [ 'change_smooth_selection' , 'smooth_selection.gif' , 'change_smooth_selection_mode' , true ] , [ 'reset_highlight' , 'reset_highlight.gif' , 'resync_highlight' , true ] , [ 'highlight' , 'highlight.gif' , 'change_highlight' , true ] , [ 'help' , 'help.gif' , 'show_help' , false ] , [ 'save' , 'save.gif' , 'save' , false ] , [ 'load' , 'load.gif' , 'load' , false ] , [ 'fullscreen' , 'fullscreen.gif' , 'toggle_full_screen' , false ] , [ 'word_wrap' , 'word_wrap.gif' , 'toggle_word_wrap' , true ] , [ 'autocompletion' , 'autocompletion.gif' , 'toggle_autocompletion' , true ] ] ; t . set _browser _infos ( t ) ; if ( t . isIE >= 6 || t . isGecko || ( t . isWebKit && ! t . isSafari < 3 ) || t . isOpera >= 9 || t . isCamino ) t . isValidBrowser = true ;
else t . isValidBrowser = false ; t . set _base _url ( ) ; for ( var i = 0 ; i < t . scripts _to _load . length ; i ++ ) { setTimeout ( "eAL.load_script('" + t . baseURL + t . scripts _to _load [ i ] + ".js');" , 1 ) ; t . waiting _loading [ t . scripts _to _load [ i ] + ".js" ] = false ; } t . add _event ( window , "load" , EAL . prototype . window _loaded ) ;
} ; EAL . prototype = {
has _error : function ( ) { this . error = true ; for ( var i in EAL . prototype ) { EAL . prototype [ i ] = function ( ) { } ; } } , set _browser _infos : function ( o ) { ua = navigator . userAgent ; o . isWebKit = /WebKit/ . test ( ua ) ; o . isGecko = ! o . isWebKit && /Gecko/ . test ( ua ) ; o . isMac = /Mac/ . test ( ua ) ; o . isIE = ( navigator . appName == "Microsoft Internet Explorer" ) ; if ( o . isIE ) { o . isIE = ua . replace ( /^.*?MSIE\s+([0-9\.]+).*$/ , "$1" ) ; if ( o . isIE < 6 ) o . has _error ( ) ; } if ( o . isOpera = ( ua . indexOf ( 'Opera' ) != - 1 ) ) { o . isOpera = ua . replace ( /^.*?Opera.*?([0-9\.]+).*$/i , "$1" ) ; if ( o . isOpera < 9 ) o . has _error ( ) ; o . isIE = false ; } if ( o . isFirefox = ( ua . indexOf ( 'Firefox' ) != - 1 ) ) o . isFirefox = ua . replace ( /^.*?Firefox.*?([0-9\.]+).*$/i , "$1" ) ; if ( ua . indexOf ( 'Iceweasel' ) != - 1 ) o . isFirefox = ua . replace ( /^.*?Iceweasel.*?([0-9\.]+).*$/i , "$1" ) ; if ( ua . indexOf ( 'GranParadiso' ) != - 1 ) o . isFirefox = ua . replace ( /^.*?GranParadiso.*?([0-9\.]+).*$/i , "$1" ) ; if ( ua . indexOf ( 'BonEcho' ) != - 1 ) o . isFirefox = ua . replace ( /^.*?BonEcho.*?([0-9\.]+).*$/i , "$1" ) ; if ( ua . indexOf ( 'SeaMonkey' ) != - 1 ) o . isFirefox = ( ua . replace ( /^.*?SeaMonkey.*?([0-9\.]+).*$/i , "$1" ) ) + 1 ; if ( o . isCamino = ( ua . indexOf ( 'Camino' ) != - 1 ) ) o . isCamino = ua . replace ( /^.*?Camino.*?([0-9\.]+).*$/i , "$1" ) ; if ( o . isSafari = ( ua . indexOf ( 'Safari' ) != - 1 ) ) o . isSafari = ua . replace ( /^.*?Version\/([0-9]+\.[0-9]+).*$/i , "$1" ) ; if ( o . isChrome = ( ua . indexOf ( 'Chrome' ) != - 1 ) ) { o . isChrome = ua . replace ( /^.*?Chrome.*?([0-9\.]+).*$/i , "$1" ) ; o . isSafari = false ; } } , window _loaded : function ( ) { eAL . win = "loaded" ; if ( document . forms ) { for ( var i = 0 ; i < document . forms . length ; i ++ ) { var form = document . forms [ i ] ; form . edit _area _replaced _submit = null ; try { form . edit _area _replaced _submit = form . onsubmit ; form . onsubmit = "" ; } catch ( e ) { } eAL . add _event ( form , "submit" , EAL . prototype . submit ) ; eAL . add _event ( form , "reset" , EAL . prototype . reset ) ; } } eAL . add _event ( window , "unload" , function ( ) { for ( var i in eAs ) { eAL . delete _instance ( i ) ; } } ) ; } , init _ie _textarea : function ( id ) { var a = document . getElementById ( id ) ; try { if ( a && typeof ( a . focused ) == "undefined" ) { a . focus ( ) ; a . focused = true ; a . selectionStart = a . selectionEnd = 0 ; get _IE _selection ( a ) ; eAL . add _event ( a , "focus" , IE _textarea _focus ) ; eAL . add _event ( a , "blur" , IE _textarea _blur ) ; } } catch ( ex ) { } } , init : function ( settings ) { var t = this , s = settings , i ; if ( ! s [ "id" ] ) t . has _error ( ) ; if ( t . error ) return ; if ( eAs [ s [ "id" ] ] ) t . delete _instance ( s [ "id" ] ) ; for ( i in t . default _settings ) { if ( typeof ( s [ i ] ) == "undefined" ) s [ i ] = t . default _settings [ i ] ; } if ( s [ "browsers" ] == "known" && t . isValidBrowser == false ) { return ; } if ( s [ "begin_toolbar" ] . length > 0 ) s [ "toolbar" ] = s [ "begin_toolbar" ] + "," + s [ "toolbar" ] ; if ( s [ "end_toolbar" ] . length > 0 ) s [ "toolbar" ] = s [ "toolbar" ] + "," + s [ "end_toolbar" ] ; s [ "tab_toolbar" ] = s [ "toolbar" ] . replace ( / /g , "" ) . split ( "," ) ; s [ "plugins" ] = s [ "plugins" ] . replace ( / /g , "" ) . split ( "," ) ; for ( i = 0 ; i < s [ "plugins" ] . length ; i ++ ) { if ( s [ "plugins" ] [ i ] . length == 0 ) s [ "plugins" ] . splice ( i , 1 ) ; } t . get _template ( ) ; t . load _script ( t . baseURL + "langs/" + s [ "language" ] + ".js" ) ; if ( s [ "syntax" ] . length > 0 ) { s [ "syntax" ] = s [ "syntax" ] . toLowerCase ( ) ; t . load _script ( t . baseURL + "reg_syntax/" + s [ "syntax" ] + ".js" ) ; } eAs [ s [ "id" ] ] = { "settings" : s } ; eAs [ s [ "id" ] ] [ "displayed" ] = false ; eAs [ s [ "id" ] ] [ "hidden" ] = false ; t . start ( s [ "id" ] ) ; } , delete _instance : function ( id ) { var d = document , fs = window . frames , span , iframe ; eAL . execCommand ( id , "EA_delete" ) ; if ( fs [ "frame_" + id ] && fs [ "frame_" + id ] . editArea ) { if ( eAs [ id ] [ "displayed" ] ) eAL . toggle ( id , "off" ) ; fs [ "frame_" + id ] . editArea . execCommand ( "EA_unload" ) ; } span = d . getElementById ( "EditAreaArroundInfos_" + id ) ; if ( span ) span . parentNode . removeChild ( span ) ; iframe = d . getElementById ( "frame_" + id ) ; if ( iframe ) { iframe . parentNode . removeChild ( iframe ) ; try { delete fs [ "frame_" + id ] ; } catch ( e ) { } } delete eAs [ id ] ; } , start : function ( id ) {
var t = this , d = document , f , span , father , next , html = '' , html _toolbar _content = '' , template , content , i ; if ( t . win != "loaded" ) { setTimeout ( "eAL.start('" + id + "');" , 50 ) ; return ; } for ( i in t . waiting _loading ) { if ( t . waiting _loading [ i ] != "loaded" && typeof ( t . waiting _loading [ i ] ) != "function" ) { setTimeout ( "eAL.start('" + id + "');" , 50 ) ; return ; } } if ( ! t . lang [ eAs [ id ] [ "settings" ] [ "language" ] ] || ( eAs [ id ] [ "settings" ] [ "syntax" ] . length > 0 && ! t . load _syntax [ eAs [ id ] [ "settings" ] [ "syntax" ] ] ) ) { setTimeout ( "eAL.start('" + id + "');" , 50 ) ; return ; } if ( eAs [ id ] [ "settings" ] [ "syntax" ] . length > 0 ) t . init _syntax _regexp ( ) ; if ( ! d . getElementById ( "EditAreaArroundInfos_" + id ) && ( eAs [ id ] [ "settings" ] [ "debug" ] || eAs [ id ] [ "settings" ] [ "allow_toggle" ] ) ) {
span = d . createElement ( "span" ) ; span . id = "EditAreaArroundInfos_" + id ; if ( eAs [ id ] [ "settings" ] [ "allow_toggle" ] ) { checked = ( eAs [ id ] [ "settings" ] [ "display" ] == "onload" ) ? "checked='checked'" : "" ; html += "<div id='edit_area_toggle_" + i + "'>" ; html += "<input id='edit_area_toggle_checkbox_" + id + "' class='toggle_" + id + "' type='checkbox' onclick='eAL.toggle(\"" + id + "\");' accesskey='e' " + checked + " />" ; html += "<label for='edit_area_toggle_checkbox_" + id + "'>{$toggle}</label></div>" ; } if ( eAs [ id ] [ "settings" ] [ "debug" ] ) html += "<textarea id='edit_area_debug_" + id + "' spellcheck='off' style='z-index:20;width:100%;height:120px;overflow:auto;border:solid black 1px;'></textarea><br />" ; html = t . translate ( html , eAs [ id ] [ "settings" ] [ "language" ] ) ; span . innerHTML = html ; father = d . getElementById ( id ) . parentNode ; next = d . getElementById ( id ) . nextSibling ; if ( next == null ) father . appendChild ( span ) ;
else father . insertBefore ( span , next ) ;
} if ( ! eAs [ id ] [ "initialized" ] ) { t . execCommand ( id , "EA_init" ) ; if ( eAs [ id ] [ "settings" ] [ "display" ] == "later" ) { eAs [ id ] [ "initialized" ] = true ; return ; } } if ( t . isIE ) { t . init _ie _textarea ( id ) ; } var area = eAs [ id ] ; for ( i = 0 ; i < area [ "settings" ] [ "tab_toolbar" ] . length ; i ++ ) { html _toolbar _content += t . get _control _html ( area [ "settings" ] [ "tab_toolbar" ] [ i ] , area [ "settings" ] [ "language" ] ) ; } html _toolbar _content = t . translate ( html _toolbar _content , area [ "settings" ] [ "language" ] , "template" ) ; if ( ! t . iframe _script ) { t . iframe _script = "" ; for ( i = 0 ; i < t . sub _scripts _to _load . length ; i ++ ) t . iframe _script += '<script language="javascript" type="text/javascript" src="' + t . baseURL + t . sub _scripts _to _load [ i ] + '.js"></script>' ; } for ( i = 0 ; i < area [ "settings" ] [ "plugins" ] . length ; i ++ ) { if ( ! t . all _plugins _loaded ) t . iframe _script += '<script language="javascript" type="text/javascript" src="' + t . baseURL + 'plugins/' + area [ "settings" ] [ "plugins" ] [ i ] + '/' + area [ "settings" ] [ "plugins" ] [ i ] + '.js"></script>' ; t . iframe _script += '<script language="javascript" type="text/javascript" src="' + t . baseURL + 'plugins/' + area [ "settings" ] [ "plugins" ] [ i ] + '/langs/' + area [ "settings" ] [ "language" ] + '.js"></script>' ; } if ( ! t . iframe _css ) { t . iframe _css = "<link href='" + t . baseURL + "edit_area.css' rel='stylesheet' type='text/css' />" ; } template = t . template . replace ( /\[__BASEURL__\]/g , t . baseURL ) ; template = template . replace ( "[__TOOLBAR__]" , html _toolbar _content ) ; template = t . translate ( template , area [ "settings" ] [ "language" ] , "template" ) ; template = template . replace ( "[__CSSRULES__]" , t . iframe _css ) ; template = template . replace ( "[__JSCODE__]" , t . iframe _script ) ; template = template . replace ( "[__EA_VERSION__]" , t . version ) ; area . textarea = d . getElementById ( area [ "settings" ] [ "id" ] ) ; eAs [ area [ "settings" ] [ "id" ] ] [ "textarea" ] = area . textarea ; if ( typeof ( window . frames [ "frame_" + area [ "settings" ] [ "id" ] ] ) != 'undefined' ) delete window . frames [ "frame_" + area [ "settings" ] [ "id" ] ] ; father = area . textarea . parentNode ; content = d . createElement ( "iframe" ) ; content . name = "frame_" + area [ "settings" ] [ "id" ] ; content . id = "frame_" + area [ "settings" ] [ "id" ] ; content . style . borderWidth = "0px" ; setAttribute ( content , "frameBorder" , "0" ) ; content . style . overflow = "hidden" ; content . style . display = "none" ; next = area . textarea . nextSibling ; if ( next == null ) father . appendChild ( content ) ;
else father . insertBefore ( content , next ) ; f = window . frames [ "frame_" + area [ "settings" ] [ "id" ] ] ; f . document . open ( ) ; f . eAs = eAs ; f . area _id = area [ "settings" ] [ "id" ] ; f . document . area _id = area [ "settings" ] [ "id" ] ; f . document . write ( template ) ; f . document . close ( ) ;
} , toggle : function ( id , toggle _to ) {
if ( ! toggle _to ) toggle _to = ( eAs [ id ] [ "displayed" ] == true ) ? "off" : "on" ; if ( eAs [ id ] [ "displayed" ] == true && toggle _to == "off" ) { this . toggle _off ( id ) ; }
else if ( eAs [ id ] [ "displayed" ] == false && toggle _to == "on" ) { this . toggle _on ( id ) ; } return false ;
} , toggle _off : function ( id ) {
var fs = window . frames , f , t , parNod , nxtSib , selStart , selEnd , scrollTop , scrollLeft ; if ( fs [ "frame_" + id ] ) {
f = fs [ "frame_" + id ] ; t = eAs [ id ] [ "textarea" ] ; if ( f . editArea . fullscreen [ 'isFull' ] ) f . editArea . toggle _full _screen ( false ) ; eAs [ id ] [ "displayed" ] = false ; t . wrap = "off" ; setAttribute ( t , "wrap" , "off" ) ; parNod = t . parentNode ; nxtSib = t . nextSibling ; parNod . removeChild ( t ) ; parNod . insertBefore ( t , nxtSib ) ; t . value = f . editArea . textarea . value ; selStart = f . editArea . last _selection [ "selectionStart" ] ; selEnd = f . editArea . last _selection [ "selectionEnd" ] ; scrollTop = f . document . getElementById ( "result" ) . scrollTop ; scrollLeft = f . document . getElementById ( "result" ) . scrollLeft ; document . getElementById ( "frame_" + id ) . style . display = 'none' ; t . style . display = "inline" ; try { t . focus ( ) ; } catch ( e ) { } ; if ( this . isIE ) { t . selectionStart = selStart ; t . selectionEnd = selEnd ; t . focused = true ; set _IE _selection ( t ) ; }
else { if ( this . isOpera && this . isOpera < 9.6 ) { t . setSelectionRange ( 0 , 0 ) ; } try { t . setSelectionRange ( selStart , selEnd ) ; } catch ( e ) { } ; } t . scrollTop = scrollTop ; t . scrollLeft = scrollLeft ; f . editArea . execCommand ( "toggle_off" ) ;
}
} , toggle _on : function ( id ) {
var fs = window . frames , f , t , selStart = 0 , selEnd = 0 , scrollTop = 0 , scrollLeft = 0 , curPos , elem ; if ( fs [ "frame_" + id ] ) {
f = fs [ "frame_" + id ] ; t = eAs [ id ] [ "textarea" ] ; area = f . editArea ; area . textarea . value = t . value ; curPos = eAs [ id ] [ "settings" ] [ "cursor_position" ] ; if ( t . use _last == true ) { selStart = t . last _selectionStart ; selEnd = t . last _selectionEnd ; scrollTop = t . last _scrollTop ; scrollLeft = t . last _scrollLeft ; t . use _last = false ; }
else if ( curPos == "auto" ) { try { selStart = t . selectionStart ; selEnd = t . selectionEnd ; scrollTop = t . scrollTop ; scrollLeft = t . scrollLeft ; } catch ( ex ) { } } this . set _editarea _size _from _textarea ( id , document . getElementById ( "frame_" + id ) ) ; t . style . display = "none" ; document . getElementById ( "frame_" + id ) . style . display = "inline" ; area . execCommand ( "focus" ) ; eAs [ id ] [ "displayed" ] = true ; area . execCommand ( "update_size" ) ; f . document . getElementById ( "result" ) . scrollTop = scrollTop ; f . document . getElementById ( "result" ) . scrollLeft = scrollLeft ; area . area _select ( selStart , selEnd - selStart ) ; area . execCommand ( "toggle_on" ) ;
}
else { elem = document . getElementById ( id ) ; elem . last _selectionStart = elem . selectionStart ; elem . last _selectionEnd = elem . selectionEnd ; elem . last _scrollTop = elem . scrollTop ; elem . last _scrollLeft = elem . scrollLeft ; elem . use _last = true ; eAL . start ( id ) ; }
} , set _editarea _size _from _textarea : function ( id , frame ) { var elem , width , height ; elem = document . getElementById ( id ) ; width = Math . max ( eAs [ id ] [ "settings" ] [ "min_width" ] , elem . offsetWidth ) + "px" ; height = Math . max ( eAs [ id ] [ "settings" ] [ "min_height" ] , elem . offsetHeight ) + "px" ; if ( elem . style . width . indexOf ( "%" ) != - 1 ) width = elem . style . width ; if ( elem . style . height . indexOf ( "%" ) != - 1 ) height = elem . style . height ; frame . style . width = width ; frame . style . height = height ; } , set _base _url : function ( ) { var t = this , elems , i , docBasePath ; if ( ! this . baseURL ) { elems = document . getElementsByTagName ( 'script' ) ; for ( i = 0 ; i < elems . length ; i ++ ) { if ( elems [ i ] . src && elems [ i ] . src . match ( /edit_area_[^\\\/]*$/i ) ) { var src = unescape ( elems [ i ] . src ) ; src = src . substring ( 0 , src . lastIndexOf ( '/' ) ) ; this . baseURL = src ; this . file _name = elems [ i ] . src . substr ( elems [ i ] . src . lastIndexOf ( "/" ) + 1 ) ; break ; } } } docBasePath = document . location . href ; if ( docBasePath . indexOf ( '?' ) != - 1 ) docBasePath = docBasePath . substring ( 0 , docBasePath . indexOf ( '?' ) ) ; docBasePath = docBasePath . substring ( 0 , docBasePath . lastIndexOf ( '/' ) ) ; if ( t . baseURL . indexOf ( '://' ) == - 1 && t . baseURL . charAt ( 0 ) != '/' ) { t . baseURL = docBasePath + "/" + t . baseURL ; } t . baseURL += "/" ; } , get _button _html : function ( id , img , exec , isFileSpecific , baseURL ) { var cmd , html ; if ( ! baseURL ) baseURL = this . baseURL ; cmd = 'editArea.execCommand(\'' + exec + '\')' ; html = '<a id="a_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self" fileSpecific="' + ( isFileSpecific ? 'yes' : 'no' ) + '">' ; html += '<img id="' + id + '" src="' + baseURL + 'images/' + img + '" title="{$' + id + '}" width="20" height="20" class="editAreaButtonNormal" onmouseover="editArea.switchClass(this,\'editAreaButtonOver\');" onmouseout="editArea.restoreClass(this);" onmousedown="editArea.restoreAndSwitchClass(this,\'editAreaButtonDown\');" /></a>' ; return html ; } , get _control _html : function ( button _name , lang ) { var t = this , i , but , html , si ; for ( i = 0 ; i < t . advanced _buttons . length ; i ++ ) { but = t . advanced _buttons [ i ] ; if ( but [ 0 ] == button _name ) { return t . get _button _html ( but [ 0 ] , but [ 1 ] , but [ 2 ] , but [ 3 ] ) ; } } switch ( button _name ) { case "*" : case "return" : return "<br />" ; case "|" : case "separator" : return '<img src="' + t . baseURL + 'images/spacer.gif" width="1" height="15" class="editAreaSeparatorLine">' ; case "select_font" : html = "<select id='area_font_size' onchange='javascript:editArea.execCommand(\"change_font_size\")' fileSpecific='yes'>" ; html += "<option value='-1'>{$font_size}</option>" ; si = [ 8 , 9 , 10 , 11 , 12 , 14 ] ; for ( i = 0 ; i < si . length ; i ++ ) { html += "<option value='" + si [ i ] + "'>" + si [ i ] + " pt</option>" ; } html += "</select>" ; return html ; case "syntax_selection" : html = "<select id='syntax_selection' onchange='javascript:editArea.execCommand(\"change_syntax\",this.value)' fileSpecific='yes'>" ; html += "<option value='-1'>{$syntax_selection}</option>" ; html += "</select>" ; return html ; } return "<span id='tmp_tool_" + button _name + "'>[" + button _name + "]</span>" ; } , get _template : function ( ) {
if ( this . template == "" ) {
var xhr _object = null ; if ( window . XMLHttpRequest ) xhr _object = new XMLHttpRequest ( ) ;
else if ( window . ActiveXObject ) xhr _object = new ActiveXObject ( "Microsoft.XMLHTTP" ) ;
else { alert ( "XMLHTTPRequest not supported. EditArea not loaded" ) ; return ; } xhr _object . open ( "GET" , this . baseURL + "template.html" , false ) ; xhr _object . send ( null ) ; if ( xhr _object . readyState == 4 ) this . template = xhr _object . responseText ;
else this . has _error ( ) ;
}
} , translate : function ( text , lang , mode ) {
if ( mode == "word" ) text = eAL . get _word _translation ( text , lang ) ;
else if ( mode = "template" ) { eAL . current _language = lang ; text = text . replace ( /\{\$([^\}]+)\}/gm , eAL . translate _template ) ; } return text ;
} , translate _template : function ( ) { return eAL . get _word _translation ( EAL . prototype . translate _template . arguments [ 1 ] , eAL . current _language ) ; } , get _word _translation : function ( val , lang ) { var i ; for ( i in eAL . lang [ lang ] ) { if ( i == val ) return eAL . lang [ lang ] [ i ] ; } return "_" + val ; } , load _script : function ( url ) { var t = this , d = document , script , head ; if ( t . loadedFiles [ url ] ) return ; try { script = d . createElement ( "script" ) ; script . type = "text/javascript" ; script . src = url ; script . charset = "UTF-8" ; d . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( script ) ; } catch ( e ) { d . write ( '<sc' + 'ript language="javascript" type="text/javascript" src="' + url + '" charset="UTF-8"></sc' + 'ript>' ) ; } t . loadedFiles [ url ] = true ; } , add _event : function ( obj , name , handler ) {
try {
if ( obj . attachEvent ) { obj . attachEvent ( "on" + name , handler ) ; }
else { obj . addEventListener ( name , handler , false ) ; }
} catch ( e ) { }
} , remove _event : function ( obj , name , handler ) {
try {
if ( obj . detachEvent ) obj . detachEvent ( "on" + name , handler ) ;
else obj . removeEventListener ( name , handler , false ) ;
} catch ( e ) { }
} , reset : function ( e ) { var formObj , is _child , i , x ; formObj = eAL . isIE ? window . event . srcElement : e . target ; if ( formObj . tagName != 'FORM' ) formObj = formObj . form ; for ( i in eAs ) { is _child = false ; for ( x = 0 ; x < formObj . elements . length ; x ++ ) { if ( formObj . elements [ x ] . id == i ) is _child = true ; } if ( window . frames [ "frame_" + i ] && is _child && eAs [ i ] [ "displayed" ] == true ) { var exec = 'window.frames["frame_' + i + '"].editArea.textarea.value=document.getElementById("' + i + '").value;' ; exec += 'window.frames["frame_' + i + '"].editArea.execCommand("focus");' ; exec += 'window.frames["frame_' + i + '"].editArea.check_line_selection();' ; exec += 'window.frames["frame_' + i + '"].editArea.execCommand("reset");' ; window . setTimeout ( exec , 10 ) ; } } return ; } , submit : function ( e ) {
var formObj , is _child , fs = window . frames , i , x ; formObj = eAL . isIE ? window . event . srcElement : e . target ; if ( formObj . tagName != 'FORM' ) formObj = formObj . form ; for ( i in eAs ) { is _child = false ; for ( x = 0 ; x < formObj . elements . length ; x ++ ) { if ( formObj . elements [ x ] . id == i ) is _child = true ; } if ( is _child ) { if ( fs [ "frame_" + i ] && eAs [ i ] [ "displayed" ] == true ) document . getElementById ( i ) . value = fs [ "frame_" + i ] . editArea . textarea . value ; eAL . execCommand ( i , "EA_submit" ) ; } } if ( typeof ( formObj . edit _area _replaced _submit ) == "function" ) {
res = formObj . edit _area _replaced _submit ( ) ; if ( res == false ) {
if ( eAL . isIE ) return false ;
else e . preventDefault ( ) ;
}
} return ;
} , getValue : function ( id ) {
if ( window . frames [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { return window . frames [ "frame_" + id ] . editArea . textarea . value ; }
else if ( elem = document . getElementById ( id ) ) { return elem . value ; } return false ;
} , setValue : function ( id , new _val ) {
var fs = window . frames ; if ( ( f = fs [ "frame_" + id ] ) && eAs [ id ] [ "displayed" ] == true ) { f . editArea . textarea . value = new _val ; f . editArea . execCommand ( "focus" ) ; f . editArea . check _line _selection ( false ) ; f . editArea . execCommand ( "onchange" ) ; }
else if ( elem = document . getElementById ( id ) ) { elem . value = new _val ; }
} , getSelectionRange : function ( id ) {
var sel , eA , fs = window . frames ; sel = { "start" : 0 , "end" : 0 } ; if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { eA = fs [ "frame_" + id ] . editArea ; sel [ "start" ] = eA . textarea . selectionStart ; sel [ "end" ] = eA . textarea . selectionEnd ; }
else if ( elem = document . getElementById ( id ) ) { sel = getSelectionRange ( elem ) ; } return sel ;
} , setSelectionRange : function ( id , new _start , new _end ) {
var fs = window . frames ; if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { fs [ "frame_" + id ] . editArea . area _select ( new _start , new _end - new _start ) ; if ( ! this . isIE ) { fs [ "frame_" + id ] . editArea . check _line _selection ( false ) ; fs [ "frame_" + id ] . editArea . scroll _to _view ( ) ; } }
else if ( elem = document . getElementById ( id ) ) { setSelectionRange ( elem , new _start , new _end ) ; }
} , getSelectedText : function ( id ) { var sel = this . getSelectionRange ( id ) ; return this . getValue ( id ) . substring ( sel [ "start" ] , sel [ "end" ] ) ; } , setSelectedText : function ( id , new _val ) {
var fs = window . frames , d = document , sel , text , scrollTop , scrollLeft , new _sel _end ; new _val = new _val . replace ( /\r/g , "" ) ; sel = this . getSelectionRange ( id ) ; text = this . getValue ( id ) ; if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { scrollTop = fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollTop ; scrollLeft = fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollLeft ; }
else { scrollTop = d . getElementById ( id ) . scrollTop ; scrollLeft = d . getElementById ( id ) . scrollLeft ; } text = text . substring ( 0 , sel [ "start" ] ) + new _val + text . substring ( sel [ "end" ] ) ; this . setValue ( id , text ) ; new _sel _end = sel [ "start" ] + new _val . length ; this . setSelectionRange ( id , sel [ "start" ] , new _sel _end ) ; if ( new _val != this . getSelectedText ( id ) . replace ( /\r/g , "" ) ) { this . setSelectionRange ( id , sel [ "start" ] , new _sel _end + new _val . split ( "\n" ) . length - 1 ) ; } if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollTop = scrollTop ; fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollLeft = scrollLeft ; fs [ "frame_" + id ] . editArea . execCommand ( "onchange" ) ; }
else { d . getElementById ( id ) . scrollTop = scrollTop ; d . getElementById ( id ) . scrollLeft = scrollLeft ; }
} , insertTags : function ( id , open _tag , close _tag ) {
var old _sel , new _sel ; old _sel = this . getSelectionRange ( id ) ; text = open _tag + this . getSelectedText ( id ) + close _tag ; eAL . setSelectedText ( id , text ) ; new _sel = this . getSelectionRange ( id ) ; if ( old _sel [ "end" ] > old _sel [ "start" ] ) this . setSelectionRange ( id , new _sel [ "end" ] , new _sel [ "end" ] ) ;
else this . setSelectionRange ( id , old _sel [ "start" ] + open _tag . length , old _sel [ "start" ] + open _tag . length ) ;
} , hide : function ( id ) {
var fs = window . frames , d = document , t = this , scrollTop , scrollLeft , span ; if ( d . getElementById ( id ) && ! t . hidden [ id ] ) {
t . hidden [ id ] = { } ; t . hidden [ id ] [ "selectionRange" ] = t . getSelectionRange ( id ) ; if ( d . getElementById ( id ) . style . display != "none" ) { t . hidden [ id ] [ "scrollTop" ] = d . getElementById ( id ) . scrollTop ; t . hidden [ id ] [ "scrollLeft" ] = d . getElementById ( id ) . scrollLeft ; } if ( fs [ "frame_" + id ] ) {
t . hidden [ id ] [ "toggle" ] = eAs [ id ] [ "displayed" ] ; if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { scrollTop = fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollTop ; scrollLeft = fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollLeft ; }
else { scrollTop = d . getElementById ( id ) . scrollTop ; scrollLeft = d . getElementById ( id ) . scrollLeft ; } t . hidden [ id ] [ "scrollTop" ] = scrollTop ; t . hidden [ id ] [ "scrollLeft" ] = scrollLeft ; if ( eAs [ id ] [ "displayed" ] == true ) eAL . toggle _off ( id ) ;
} span = d . getElementById ( "EditAreaArroundInfos_" + id ) ; if ( span ) { span . style . display = 'none' ; } d . getElementById ( id ) . style . display = "none" ;
}
} , show : function ( id ) {
var fs = window . frames , d = document , t = this , span ; if ( ( elem = d . getElementById ( id ) ) && t . hidden [ id ] ) {
elem . style . display = "inline" ; elem . scrollTop = t . hidden [ id ] [ "scrollTop" ] ; elem . scrollLeft = t . hidden [ id ] [ "scrollLeft" ] ; span = d . getElementById ( "EditAreaArroundInfos_" + id ) ; if ( span ) { span . style . display = 'inline' ; } if ( fs [ "frame_" + id ] ) {
elem . style . display = "inline" ; if ( t . hidden [ id ] [ "toggle" ] == true ) eAL . toggle _on ( id ) ; scrollTop = t . hidden [ id ] [ "scrollTop" ] ; scrollLeft = t . hidden [ id ] [ "scrollLeft" ] ; if ( fs [ "frame_" + id ] && eAs [ id ] [ "displayed" ] == true ) { fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollTop = scrollTop ; fs [ "frame_" + id ] . document . getElementById ( "result" ) . scrollLeft = scrollLeft ; }
else { elem . scrollTop = scrollTop ; elem . scrollLeft = scrollLeft ; }
} sel = t . hidden [ id ] [ "selectionRange" ] ; t . setSelectionRange ( id , sel [ "start" ] , sel [ "end" ] ) ; delete t . hidden [ id ] ;
}
} , getCurrentFile : function ( id ) { return this . execCommand ( id , 'get_file' , this . execCommand ( id , 'curr_file' ) ) ; } , getFile : function ( id , file _id ) { return this . execCommand ( id , 'get_file' , file _id ) ; } , getAllFiles : function ( id ) { return this . execCommand ( id , 'get_all_files()' ) ; } , openFile : function ( id , file _infos ) { return this . execCommand ( id , 'open_file' , file _infos ) ; } , closeFile : function ( id , file _id ) { return this . execCommand ( id , 'close_file' , file _id ) ; } , setFileEditedMode : function ( id , file _id , to ) { var reg1 , reg2 ; reg1 = new RegExp ( '\\\\' , 'g' ) ; reg2 = new RegExp ( '"' , 'g' ) ; return this . execCommand ( id , 'set_file_edited_mode("' + file _id . replace ( reg1 , '\\\\' ) . replace ( reg2 , '\\"' ) + '",' + to + ')' ) ; } , execCommand : function ( id , cmd , fct _param ) {
switch ( cmd ) { case "EA_init" : if ( eAs [ id ] [ 'settings' ] [ "EA_init_callback" ] . length > 0 ) eval ( eAs [ id ] [ 'settings' ] [ "EA_init_callback" ] + "('" + id + "');" ) ; break ; case "EA_delete" : if ( eAs [ id ] [ 'settings' ] [ "EA_delete_callback" ] . length > 0 ) eval ( eAs [ id ] [ 'settings' ] [ "EA_delete_callback" ] + "('" + id + "');" ) ; break ; case "EA_submit" : if ( eAs [ id ] [ 'settings' ] [ "submit_callback" ] . length > 0 ) eval ( eAs [ id ] [ 'settings' ] [ "submit_callback" ] + "('" + id + "');" ) ; break ; } if ( window . frames [ "frame_" + id ] && window . frames [ "frame_" + id ] . editArea ) {
if ( fct _param != undefined ) return eval ( 'window.frames["frame_' + id + '"].editArea.' + cmd + '(fct_param);' ) ;
else return eval ( 'window.frames["frame_' + id + '"].editArea.' + cmd + ';' ) ;
} return false ;
}
} ; var eAL = new EAL ( ) ; var eAs = { } ; function getAttribute ( elm , aName ) { var aValue , taName , i ; try { aValue = elm . getAttribute ( aName ) ; } catch ( exept ) { } if ( ! aValue ) { for ( i = 0 ; i < elm . attributes . length ; i ++ ) { taName = elm . attributes [ i ] . name . toLowerCase ( ) ; if ( taName == aName ) { aValue = elm . attributes [ i ] . value ; return aValue ; } } } return aValue ; } ; function setAttribute ( elm , attr , val ) {
if ( attr == "class" ) { elm . setAttribute ( "className" , val ) ; elm . setAttribute ( "class" , val ) ; }
else { elm . setAttribute ( attr , val ) ; }
} ; function getChildren ( elem , elem _type , elem _attribute , elem _attribute _match , option , depth ) {
if ( ! option ) var option = "single" ; if ( ! depth ) var depth = - 1 ; if ( elem ) {
var children = elem . childNodes ; var result = null ; var results = [ ] ; for ( var x = 0 ; x < children . length ; x ++ ) {
strTagName = new String ( children [ x ] . tagName ) ; children _class = "?" ; if ( strTagName != "undefined" ) {
child _attribute = getAttribute ( children [ x ] , elem _attribute ) ; if ( ( strTagName . toLowerCase ( ) == elem _type . toLowerCase ( ) || elem _type == "" ) && ( elem _attribute == "" || child _attribute == elem _attribute _match ) ) {
if ( option == "all" ) { results . push ( children [ x ] ) ; }
else { return children [ x ] ; }
} if ( depth != 0 ) {
result = getChildren ( children [ x ] , elem _type , elem _attribute , elem _attribute _match , option , depth - 1 ) ; if ( option == "all" ) { if ( result . length > 0 ) { results = results . concat ( result ) ; } }
else if ( result != null ) { return result ; }
}
}
} if ( option == "all" ) return results ;
} return null ;
} ; function isChildOf ( elem , parent ) { if ( elem ) { if ( elem == parent ) return true ; while ( elem . parentNode != 'undefined' ) { return isChildOf ( elem . parentNode , parent ) ; } } return false ; } ; function getMouseX ( e ) {
if ( e != null && typeof ( e . pageX ) != "undefined" ) { return e . pageX ; }
else { return ( e != null ? e . x : event . x ) + document . documentElement . scrollLeft ; }
} ; function getMouseY ( e ) {
if ( e != null && typeof ( e . pageY ) != "undefined" ) { return e . pageY ; }
else { return ( e != null ? e . y : event . y ) + document . documentElement . scrollTop ; }
} ; function calculeOffsetLeft ( r ) { return calculeOffset ( r , "offsetLeft" ) } ; function calculeOffsetTop ( r ) { return calculeOffset ( r , "offsetTop" ) } ; function calculeOffset ( element , attr ) { var offset = 0 ; while ( element ) { offset += element [ attr ] ; element = element . offsetParent } return offset ; } ; function get _css _property ( elem , prop ) {
if ( document . defaultView ) { return document . defaultView . getComputedStyle ( elem , null ) . getPropertyValue ( prop ) ; }
else if ( elem . currentStyle ) { var prop = prop . replace ( /-\D/gi , function ( sMatch ) { return sMatch . charAt ( sMatch . length - 1 ) . toUpperCase ( ) ; } ) ; return elem . currentStyle [ prop ] ; }
else return null ;
} var _mCE ; function start _move _element ( e , id , frame ) { var elem _id = ( e . target || e . srcElement ) . id ; if ( id ) elem _id = id ; if ( ! frame ) frame = window ; if ( frame . event ) e = frame . event ; _mCE = frame . document . getElementById ( elem _id ) ; _mCE . frame = frame ; frame . document . onmousemove = move _element ; frame . document . onmouseup = end _move _element ; mouse _x = getMouseX ( e ) ; mouse _y = getMouseY ( e ) ; _mCE . start _pos _x = mouse _x - ( _mCE . style . left . replace ( "px" , "" ) || calculeOffsetLeft ( _mCE ) ) ; _mCE . start _pos _y = mouse _y - ( _mCE . style . top . replace ( "px" , "" ) || calculeOffsetTop ( _mCE ) ) ; return false ; } ; function end _move _element ( e ) { _mCE . frame . document . onmousemove = "" ; _mCE . frame . document . onmouseup = "" ; _mCE = null ; } ; function move _element ( e ) { var newTop , newLeft , maxLeft ; if ( _mCE . frame && _mCE . frame . event ) e = _mCE . frame . event ; newTop = getMouseY ( e ) - _mCE . start _pos _y ; newLeft = getMouseX ( e ) - _mCE . start _pos _x ; maxLeft = _mCE . frame . document . body . offsetWidth - _mCE . offsetWidth ; max _top = _mCE . frame . document . body . offsetHeight - _mCE . offsetHeight ; newTop = Math . min ( Math . max ( 0 , newTop ) , max _top ) ; newLeft = Math . min ( Math . max ( 0 , newLeft ) , maxLeft ) ; _mCE . style . top = newTop + "px" ; _mCE . style . left = newLeft + "px" ; return false ; } ; var nav = eAL . nav ; function getSelectionRange ( textarea ) { return { "start" : textarea . selectionStart , "end" : textarea . selectionEnd } ; } ; function setSelectionRange ( t , start , end ) { t . focus ( ) ; start = Math . max ( 0 , Math . min ( t . value . length , start ) ) ; end = Math . max ( start , Math . min ( t . value . length , end ) ) ; if ( nav . isOpera && nav . isOpera < 9.6 ) { t . selectionEnd = 1 ; t . selectionStart = 0 ; t . selectionEnd = 1 ; t . selectionStart = 0 ; } t . selectionStart = start ; t . selectionEnd = end ; if ( nav . isIE ) set _IE _selection ( t ) ; } ; function get _IE _selection ( t ) { var d = document , div , range , stored _range , elem , scrollTop , relative _top , line _start , line _nb , range _start , range _end , tab ; if ( t && t . focused ) { if ( ! t . ea _line _height ) { div = d . createElement ( "div" ) ; div . style . fontFamily = get _css _property ( t , "font-family" ) ; div . style . fontSize = get _css _property ( t , "font-size" ) ; div . style . visibility = "hidden" ; div . innerHTML = "0" ; d . body . appendChild ( div ) ; t . ea _line _height = div . offsetHeight ; d . body . removeChild ( div ) ; } range = d . selection . createRange ( ) ; try { stored _range = range . duplicate ( ) ; stored _range . moveToElementText ( t ) ; stored _range . setEndPoint ( 'EndToEnd' , range ) ; if ( stored _range . parentElement ( ) == t ) { elem = t ; scrollTop = 0 ; while ( elem . parentNode ) { scrollTop += elem . scrollTop ; elem = elem . parentNode ; } relative _top = range . offsetTop - calculeOffsetTop ( t ) + scrollTop ; line _start = Math . round ( ( relative _top / t . ea _line _height ) + 1 ) ; line _nb = Math . round ( range . boundingHeight / t . ea _line _height ) ; range _start = stored _range . text . length - range . text . length ; tab = t . value . substr ( 0 , range _start ) . split ( "\n" ) ; range _start += ( line _start - tab . length ) * 2 ; t . selectionStart = range _start ; range _end = t . selectionStart + range . text . length ; tab = t . value . substr ( 0 , range _start + range . text . length ) . split ( "\n" ) ; range _end += ( line _start + line _nb - 1 - tab . length ) * 2 ; t . selectionEnd = range _end ; } } catch ( e ) { } } if ( t && t . id ) { setTimeout ( "get_IE_selection(document.getElementById('" + t . id + "'));" , 50 ) ; } } ; function IE _textarea _focus ( ) { event . srcElement . focused = true ; } function IE _textarea _blur ( ) { event . srcElement . focused = false ; } function set _IE _selection ( t ) { var nbLineStart , nbLineStart , nbLineEnd , range ; if ( ! window . closed ) { nbLineStart = t . value . substr ( 0 , t . selectionStart ) . split ( "\n" ) . length - 1 ; nbLineEnd = t . value . substr ( 0 , t . selectionEnd ) . split ( "\n" ) . length - 1 ; try { range = document . selection . createRange ( ) ; range . moveToElementText ( t ) ; range . setEndPoint ( 'EndToStart' , range ) ; range . moveStart ( 'character' , t . selectionStart - nbLineStart ) ; range . moveEnd ( 'character' , t . selectionEnd - nbLineEnd - ( t . selectionStart - nbLineStart ) ) ; range . select ( ) ; } catch ( e ) { } } } ; eAL . waiting _loading [ "elements_functions.js" ] = "loaded" ;
EAL . prototype . start _resize _area = function ( ) { var d = document , a , div , width , height , father ; d . onmouseup = eAL . end _resize _area ; d . onmousemove = eAL . resize _area ; eAL . toggle ( eAL . resize [ "id" ] ) ; a = eAs [ eAL . resize [ "id" ] ] [ "textarea" ] ; div = d . getElementById ( "edit_area_resize" ) ; if ( ! div ) { div = d . createElement ( "div" ) ; div . id = "edit_area_resize" ; div . style . border = "dashed #888888 1px" ; } width = a . offsetWidth - 2 ; height = a . offsetHeight - 2 ; div . style . display = "block" ; div . style . width = width + "px" ; div . style . height = height + "px" ; father = a . parentNode ; father . insertBefore ( div , a ) ; a . style . display = "none" ; eAL . resize [ "start_top" ] = calculeOffsetTop ( div ) ; eAL . resize [ "start_left" ] = calculeOffsetLeft ( div ) ; } ; EAL . prototype . end _resize _area = function ( e ) { var d = document , div , a , width , height ; d . onmouseup = "" ; d . onmousemove = "" ; div = d . getElementById ( "edit_area_resize" ) ; a = eAs [ eAL . resize [ "id" ] ] [ "textarea" ] ; width = Math . max ( eAs [ eAL . resize [ "id" ] ] [ "settings" ] [ "min_width" ] , div . offsetWidth - 4 ) ; height = Math . max ( eAs [ eAL . resize [ "id" ] ] [ "settings" ] [ "min_height" ] , div . offsetHeight - 4 ) ; if ( eAL . isIE == 6 ) { width -= 2 ; height -= 2 ; } a . style . width = width + "px" ; a . style . height = height + "px" ; div . style . display = "none" ; a . style . display = "inline" ; a . selectionStart = eAL . resize [ "selectionStart" ] ; a . selectionEnd = eAL . resize [ "selectionEnd" ] ; eAL . toggle ( eAL . resize [ "id" ] ) ; return false ; } ; EAL . prototype . resize _area = function ( e ) { var allow , newHeight , newWidth ; allow = eAs [ eAL . resize [ "id" ] ] [ "settings" ] [ "allow_resize" ] ; if ( allow == "both" || allow == "y" ) { newHeight = Math . max ( 20 , getMouseY ( e ) - eAL . resize [ "start_top" ] ) ; document . getElementById ( "edit_area_resize" ) . style . height = newHeight + "px" ; } if ( allow == "both" || allow == "x" ) { newWidth = Math . max ( 20 , getMouseX ( e ) - eAL . resize [ "start_left" ] ) ; document . getElementById ( "edit_area_resize" ) . style . width = newWidth + "px" ; } return false ; } ; eAL . waiting _loading [ "resize_area.js" ] = "loaded" ;
EAL . prototype . get _regexp = function ( text _array ) { res = "(\\b)(" ; for ( i = 0 ; i < text _array . length ; i ++ ) { if ( i > 0 ) res += "|" ; res += this . get _escaped _regexp ( text _array [ i ] ) ; } res += ")(\\b)" ; reg = new RegExp ( res ) ; return res ; } ; EAL . prototype . get _escaped _regexp = function ( str ) { return str . toString ( ) . replace ( /(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g , "\\$1" ) ; } ; EAL . prototype . init _syntax _regexp = function ( ) {
var lang _style = { } ; for ( var lang in this . load _syntax ) {
if ( ! this . syntax [ lang ] ) {
this . syntax [ lang ] = { } ; this . syntax [ lang ] [ "keywords_reg_exp" ] = { } ; this . keywords _reg _exp _nb = 0 ; if ( this . load _syntax [ lang ] [ 'KEYWORDS' ] ) { param = "g" ; if ( this . load _syntax [ lang ] [ 'KEYWORD_CASE_SENSITIVE' ] === false ) param += "i" ; for ( var i in this . load _syntax [ lang ] [ 'KEYWORDS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'KEYWORDS' ] [ i ] ) == "function" ) continue ; this . syntax [ lang ] [ "keywords_reg_exp" ] [ i ] = new RegExp ( this . get _regexp ( this . load _syntax [ lang ] [ 'KEYWORDS' ] [ i ] ) , param ) ; this . keywords _reg _exp _nb ++ ; } } if ( this . load _syntax [ lang ] [ 'OPERATORS' ] ) { var str = "" ; var nb = 0 ; for ( var i in this . load _syntax [ lang ] [ 'OPERATORS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'OPERATORS' ] [ i ] ) == "function" ) continue ; if ( nb > 0 ) str += "|" ; str += this . get _escaped _regexp ( this . load _syntax [ lang ] [ 'OPERATORS' ] [ i ] ) ; nb ++ ; } if ( str . length > 0 ) this . syntax [ lang ] [ "operators_reg_exp" ] = new RegExp ( "(" + str + ")" , "g" ) ; } if ( this . load _syntax [ lang ] [ 'DELIMITERS' ] ) { var str = "" ; var nb = 0 ; for ( var i in this . load _syntax [ lang ] [ 'DELIMITERS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'DELIMITERS' ] [ i ] ) == "function" ) continue ; if ( nb > 0 ) str += "|" ; str += this . get _escaped _regexp ( this . load _syntax [ lang ] [ 'DELIMITERS' ] [ i ] ) ; nb ++ ; } if ( str . length > 0 ) this . syntax [ lang ] [ "delimiters_reg_exp" ] = new RegExp ( "(" + str + ")" , "g" ) ; } var syntax _trace = [ ] ; this . syntax [ lang ] [ "quotes" ] = { } ; var quote _tab = [ ] ; if ( this . load _syntax [ lang ] [ 'QUOTEMARKS' ] ) { for ( var i in this . load _syntax [ lang ] [ 'QUOTEMARKS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'QUOTEMARKS' ] [ i ] ) == "function" ) continue ; var x = this . get _escaped _regexp ( this . load _syntax [ lang ] [ 'QUOTEMARKS' ] [ i ] ) ; this . syntax [ lang ] [ "quotes" ] [ x ] = x ; quote _tab [ quote _tab . length ] = "(" + x + "(\\\\.|[^" + x + "])*(?:" + x + "|$))" ; syntax _trace . push ( x ) ; } } this . syntax [ lang ] [ "comments" ] = { } ; if ( this . load _syntax [ lang ] [ 'COMMENT_SINGLE' ] ) { for ( var i in this . load _syntax [ lang ] [ 'COMMENT_SINGLE' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'COMMENT_SINGLE' ] [ i ] ) == "function" ) continue ; var x = this . get _escaped _regexp ( this . load _syntax [ lang ] [ 'COMMENT_SINGLE' ] [ i ] ) ; quote _tab [ quote _tab . length ] = "(" + x + "(.|\\r|\\t)*(\\n|$))" ; syntax _trace . push ( x ) ; this . syntax [ lang ] [ "comments" ] [ x ] = "\n" ; } } if ( this . load _syntax [ lang ] [ 'COMMENT_MULTI' ] ) { for ( var i in this . load _syntax [ lang ] [ 'COMMENT_MULTI' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'COMMENT_MULTI' ] [ i ] ) == "function" ) continue ; var start = this . get _escaped _regexp ( i ) ; var end = this . get _escaped _regexp ( this . load _syntax [ lang ] [ 'COMMENT_MULTI' ] [ i ] ) ; quote _tab [ quote _tab . length ] = "(" + start + "(.|\\n|\\r)*?(" + end + "|$))" ; syntax _trace . push ( start ) ; syntax _trace . push ( end ) ; this . syntax [ lang ] [ "comments" ] [ i ] = this . load _syntax [ lang ] [ 'COMMENT_MULTI' ] [ i ] ; } } if ( quote _tab . length > 0 ) this . syntax [ lang ] [ "comment_or_quote_reg_exp" ] = new RegExp ( "(" + quote _tab . join ( "|" ) + ")" , "gi" ) ; if ( syntax _trace . length > 0 ) this . syntax [ lang ] [ "syntax_trace_regexp" ] = new RegExp ( "((.|\n)*?)(\\\\*(" + syntax _trace . join ( "|" ) + "|$))" , "gmi" ) ; if ( this . load _syntax [ lang ] [ 'SCRIPT_DELIMITERS' ] ) { this . syntax [ lang ] [ "script_delimiters" ] = { } ; for ( var i in this . load _syntax [ lang ] [ 'SCRIPT_DELIMITERS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'SCRIPT_DELIMITERS' ] [ i ] ) == "function" ) continue ; this . syntax [ lang ] [ "script_delimiters" ] [ i ] = this . load _syntax [ lang ] [ 'SCRIPT_DELIMITERS' ] ; } } this . syntax [ lang ] [ "custom_regexp" ] = { } ; if ( this . load _syntax [ lang ] [ 'REGEXPS' ] ) { for ( var i in this . load _syntax [ lang ] [ 'REGEXPS' ] ) { if ( typeof ( this . load _syntax [ lang ] [ 'REGEXPS' ] [ i ] ) == "function" ) continue ; var val = this . load _syntax [ lang ] [ 'REGEXPS' ] [ i ] ; if ( ! this . syntax [ lang ] [ "custom_regexp" ] [ val [ 'execute' ] ] ) this . syntax [ lang ] [ "custom_regexp" ] [ val [ 'execute' ] ] = { } ; this . syntax [ lang ] [ "custom_regexp" ] [ val [ 'execute' ] ] [ i ] = { 'regexp' : new RegExp ( val [ 'search' ] , val [ 'modifiers' ] ) , 'class' : val [ 'class' ] } ; } } if ( this . load _syntax [ lang ] [ 'STYLES' ] ) {
lang _style [ lang ] = { } ; for ( var i in this . load _syntax [ lang ] [ 'STYLES' ] ) {
if ( typeof ( this . load _syntax [ lang ] [ 'STYLES' ] [ i ] ) == "function" ) continue ; if ( typeof ( this . load _syntax [ lang ] [ 'STYLES' ] [ i ] ) != "string" ) { for ( var j in this . load _syntax [ lang ] [ 'STYLES' ] [ i ] ) { lang _style [ lang ] [ j ] = this . load _syntax [ lang ] [ 'STYLES' ] [ i ] [ j ] ; } }
else { lang _style [ lang ] [ i ] = this . load _syntax [ lang ] [ 'STYLES' ] [ i ] ; }
}
} var style = "" ; for ( var i in lang _style [ lang ] ) { if ( lang _style [ lang ] [ i ] . length > 0 ) { style += "." + lang + " ." + i . toLowerCase ( ) + " span{" + lang _style [ lang ] [ i ] + "}\n" ; style += "." + lang + " ." + i . toLowerCase ( ) + "{" + lang _style [ lang ] [ i ] + "}\n" ; } } this . syntax [ lang ] [ "styles" ] = style ;
}
}
} ; eAL . waiting _loading [ "reg_syntax.js" ] = "loaded" ;
var editAreaLoader = eAL ; var editAreas = eAs ; EditAreaLoader = EAL ; editAreaLoader . iframe _script = "<script type='text/javascript'> Ã EA(){var t=Á;t.error=Ì;t.inlinePopup=[{popup_id:\"area_search_replace\",icon_id:\"search\"},{popup_id:\"edit_area_help\",icon_id:\"help\"}];t.plugins={};t.line_number=0;È.eAL.set_browser_infos(t);if(t.isIE >=8)t.isIE=7;t.É={};t.last_text_to_highlight=\"\";t.last_hightlighted_text=\"\";t.syntax_list=[];t.allready_used_syntax={};t.check_line_selection_timer=50;t.ÂFocused=Ì;t.highlight_selection_line=null;t.previous=[];t.next=[];t.last_undo=\"\";t.files={};t.filesIdAssoc={};t.curr_file='';t.assocBracket={};t.revertAssocBracket={};t.assocBracket[\"(\"]=\")\";t.assocBracket[\"{\"]=\"}\";t.assocBracket[\"[\"]=\"]\";for(var index in t.assocBracket){t.revertAssocBracket[t.assocBracket[index]]=index;}t.is_editable=Ë;t.lineHeight=16;t.tab_nb_char=8;if(t.isOpera)t.tab_nb_char=6;t.is_tabbing=Ì;t.fullscreen={'isFull':Ì};t.isResizing=Ì;t.id=area_id;t.Å=eAs[t.id][\"Å\"];if((\"\"+t.Å['replace_tab_by_spaces']).match(/^[0-9]+$/)){t.tab_nb_char=t.Å['replace_tab_by_spaces'];t.tabulation=\"\";for(var i=0;i<t.tab_nb_char;i++)t.tabulation+=\" \";}\nelse{t.tabulation=\"\t\";}if(t.Å[\"syntax_selection_allow\"]&&t.Å[\"syntax_selection_allow\"].Æ>0)t.syntax_list=t.Å[\"syntax_selection_allow\"].replace(/ /g,\"\").split(\",\");if(t.Å['syntax'])t.allready_used_syntax[t.Å['syntax']]=Ë;};EA.Ä.init=Ã(){var t=Á,a,s=t.Å;t.Â=_$(\"Â\");t.container=_$(\"container\");t.result=_$(\"result\");t.content_highlight=_$(\"content_highlight\");t.selection_field=_$(\"selection_field\");t.selection_field_text=_$(\"selection_field_text\");t.processing_screen=_$(\"processing\");t.editor_area=_$(\"editor\");t.tab_browsing_area=_$(\"tab_browsing_area\");t.test_font_size=_$(\"test_font_size\");a=t.Â;if(!s['is_editable'])t.set_editable(Ì);t.set_show_line_colors(s['show_line_colors']);if(syntax_selec=_$(\"syntax_selection\")){for(var i=0;i<t.syntax_list.Æ;i++){var syntax=t.syntax_list[i];var option=document.createElement(\"option\");option.Ê=syntax;if(syntax==s['syntax'])option.selected=\"selected\";dispSyntax=È.eAL.syntax_display_name[ syntax ];option.innerHTML=typeof(dispSyntax)=='undefined' ? syntax.substring(0,1).toUpperCase()+syntax.substring(1):dispSyntax;syntax_selec.appendChild(option);}}spans=È.getChildren(_$(\"toolbar_1\"),\"span\",\"\",\"\",\"all\",-1);for(var i=0;i<spans.Æ;i++){id=spans[i].id.replace(/tmp_tool_(.*)/,\"$1\");if(id!=spans[i].id){for(var j in t.plugins){if(typeof(t.plugins[j].get_control_html)==\"Ã\"){html=t.plugins[j].get_control_html(id);if(html!=Ì){html=t.get_translation(html,\"template\");var new_span=document.createElement(\"span\");new_span.innerHTML=html;var father=spans[i].ÈNode;spans[i].ÈNode.replaceChild(new_span,spans[i]);break;}}}}}if(s[\"debug\"]){t.debug=È.document.getElementById(\"edit_area_debug_\"+t.id);}if(_$(\"redo\")!=null)t.switchClassSticky(_$(\"redo\"),'editAreaButtonDisabled',Ë);if(typeof(È.eAL.syntax[s[\"syntax\"]])!=\"undefined\"){for(var i in È.eAL.syntax){if(typeof(È.eAL.syntax[i][\"Çs\"])!=\"undefined\"){t.add_Ç(È.eAL.syntax[i][\"Çs\"]);}}}if(t.isOpera)_$(\"editor\").onkeypress=keyDown;\nelse _$(\"editor\").onkeydown=keyDown;for(var i=0;i<t.inlinePopup.Æ;i++){if(t.isOpera)_$(t.inlinePopup[i][\"popup_id\"]).onkeypress=keyDown;\nelse _$(t.inlinePopup[i][\"popup_id\"]).onkeydown=keyDown;}if(s[\"allow_resize\"]==\"both\"||s[\"allow_resize\"]==\"x\"||s[\"allow_resize\"]==\"y\")t.allow_resize(Ë);È.eAL.toggle(t.id,\"on\");t.change_smooth_selection_mode(eA.smooth_selection);t.execCommand(\"change_highlight\",s[\"start_highlight\"]);t.set_font(eA.Å[\"font_family\"],eA.Å[\"font_size\"]);children=È.getChildren(document.body,\"\",\"selec\",\"none\",\"all\",-1);for(var i=0;i<children.Æ;i++){if(t.isIE)children[i].unselectable=Ë;\nelse children[i].onmousedown=Ã(){return Ì};}a.spellcheck=s[\"gecko_spellcheck\"];if(t.isFirefox >='3'){t.content_highlight.Ç.paddingLeft=\"1px\";t.selection_field.Ç.paddingLeft=\"1px\" ; t . selection _field _text . Ç . paddin
editAreaLoader . template = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" > <head> <title>EditArea</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\"/> [__CSSRULES__] [__JSCODE__] </head> <body> <div id='editor'> <div class='area_toolbar' id='toolbar_1'>[__TOOLBAR__]</div> <div class='area_toolbar' id='tab_browsing_area'><ul id='tab_browsing_list' class='menu'> <li> </li> </ul></div> <div id='result'> <div id='no_file_selected'></div> <div id='container'> <div id='cursor_pos' class='edit_area_cursor'> </div> <div id='end_bracket' class='edit_area_cursor'> </div> <div id='selection_field'></div> <div id='line_number' selec='none'></div> <div id='content_highlight'></div> <div id='test_font_size'></div> <div id='selection_field_text'></div> <textarea id='textarea' wrap='off' onchange='editArea.execCommand(\"onchange\");' onfocus='javascript:editArea.textareaFocused=true;' onblur='javascript:editArea.textareaFocused=false;'> </textarea> </div> </div> <div class='area_toolbar' id='toolbar_2'> <table class='statusbar' cellspacing='0' cellpadding='0'> <tr> <td class='total' selec='none'>{$position}:</td> <td class='infos' selec='none'> {$line_abbr} <span id='linePos'>0</span>, {$char_abbr} <span id='currPos'>0</span> </td> <td class='total' selec='none'>{$total}:</td> <td class='infos' selec='none'> {$line_abbr} <span id='nbLine'>0</span>, {$char_abbr} <span id='nbChar'>0</span> </td> <td class='resize'> <span id='resize_area'><img src='[__BASEURL__]images/statusbar_resize.gif' alt='resize' selec='none'></span> </td> </tr> </table> </div> </div> <div id='processing'> <div id='processing_text'> {$processing} </div> </div> <div id='area_search_replace' class='editarea_popup'> <table cellspacing='2' cellpadding='0' style='width: 100%'> <tr> <td selec='none'>{$search}</td> <td><input type='text' id='area_search' /></td> <td id='close_area_search_replace'> <a onclick='Javascript:editArea.execCommand(\"hidden_search\")'><img selec='none' src='[__BASEURL__]images/close.gif' alt='{$close_popup}' title='{$close_popup}' /></a><br /> </tr><tr> <td selec='none'>{$replace}</td> <td><input type='text' id='area_replace' /></td> <td><img id='move_area_search_replace' onmousedown='return parent.start_move_element(event,\"area_search_replace\", parent.frames[\"frame_\"+editArea.id]);' src='[__BASEURL__]images/move.gif' alt='{$move_popup}' title='{$move_popup}' /></td> </tr> </table> <div class='button'> <input type='checkbox' id='area_search_match_case' /><label for='area_search_match_case' selec='none'>{$match_case}</label> <input type='checkbox' id='area_search_reg_exp' /><label for='area_search_reg_exp' selec='none'>{$reg_exp}</label> <br /> <a onclick='Javascript:editArea.execCommand(\"area_search\")' selec='none'>{$find_next}</a> <a onclick='Javascript:editArea.execCommand(\"area_replace\")' selec='none'>{$replace}</a> <a onclick='Javascript:editArea.execCommand(\"area_replace_all\")' selec='none'>{$replace_all}</a><br /> </div> <div id='area_search_msg' selec='none'></div> </div> <div id='edit_area_help' class='editarea_popup'> <div class='close_popup'> <a onclick='Javascript:editArea.execCommand(\"close_all_inline_popup\")'><img src='[__BASEURL__]images/close.gif' alt='{$close_popup}' title='{$close_popup}' /></a> </div> <div><h2>Editarea [__EA_VERSION__]</h2><br /> <h3>{$shortcuts}:</h3> {$tab}: {$add_tab}<br /> {$shift}+{$tab}: {$remove_tab}<br /> {$ctrl}+f: {$search_command}<br /> {$ctrl}+r: {$replace_command}<br /> {$ctrl}+h: {$highlight}<br /> {$ctrl}+g: {$go_to_line}<br /> {$ctrl}+z: {$undo}<br /> {$ctrl}+y: {$redo}<br /> {$ctrl}+e: {$help}<br /> {$ctrl}+q, {$esc}: {$close_popup}<br /> {$accesskey} E: {$toggle}<br /> <br /> <em>{$about_notice}</em> <br /><div class='copyright'>© Christophe Dolivet 2007-2010</div> </div> </div> </body> </html> " ;
editAreaLoader . iframe _css = " < style > body , html { margin : 0 ; padding : 0 ; height : 100 % ; border : none ; overflow : hidden ; background - color : # FFF ; } body , html , table , form , textarea { font : 12 px monospace , sans - serif ; } # editor { border : solid # 888 1 px ; overflow : hidden ; } # result { z - index : 4 ; overflow - x : auto ; overflow - y : scroll ; border - top : solid # 888 1 px ; border - bottom : solid # 888 1 px ; position : relative ; clear : both ; } # result . empty { overflow : hidden ; } # container { overflow : hidden ; border : solid blue 0 ; position : relative ; z - index : 10 ; padding : 0 5 px 0 45 px ; } # textarea { position : relative ; top : 0 ; left : 0 ; margin : 0 ; padding : 0 ; width : 100 % ; height : 100 % ; overflow : hidden ; z - index : 7 ; border - width : 0 ; background - color : transparent ; resize : none ; } # textarea , # textarea : hover { outline : none ; } # content _highlight { white - space : pre ; margin : 0 ; padding : 0 ; position : absolute ; z - index : 4 ; overflow : visible ; } # selection _field , # selection _field _text { margin : 0 ; background - color : # E1F2F9 ; position : absolute ; z - index : 5 ; top : - 100 px ; padding : 0 ; white - space : pre ; overflow : hidden ; } # selection _field . show _colors { z - index : 3 ; background - color : # EDF9FC ; } # selection _field strong { font - weight : normal ; } # selection _field . show _colors * , # selection _field _text * { visibility : hidden ; } # selection _field _text { background - color : transparent ; } # selection _field _text strong { font - weight : normal ; background - color : # 3399 FE ; color : # FFF ; visibility : visible ; } # container . word _wrap # content _highlight , # container . word _wrap # selection _field , # container . word _wrap # selection _field _text , # container . word _wrap # test _font _size { white - space : pre - wrap ; white - space : - moz - pre - wrap ! important ; white - space : - pre - wrap ; white - space : - o - pre - wrap ; word - wrap : break - word ; width : 99 % ; } # line _number { position : absolute ; overflow : hidden ; border - right : solid black 1 px ; z - index : 8 ; width : 38 px ; padding : 0 5 px 0 0 ; margin : 0 0 0 - 45 px ; text - align : right ; color : # AAAAAA ; } # test _font _size { padding : 0 ; margin : 0 ; visibility : hidden ; position : absolute ; white - space : pre ; } pre { margin : 0 ; padding : 0 ; } . hidden { opacity : 0.2 ; filter : alpha ( opacity = 20 ) ; } # result . edit _area _cursor { position : absolute ; z - index : 6 ; background - color : # FF6633 ; top : - 100 px ; margin : 0 ; } # result . edit _area _selection _field . overline { background - color : # 996600 ; } . editarea _popup { border : solid 1 px # 888888 ; background - color : # ECE9D8 ; width : 250 px ; padding : 4 px ; position : absolute ; visibility : hidden ; z - index : 15 ; top : - 500 px ; } . editarea _popup , . editarea _popup table { font - family : sans - serif ; font - size : 10 pt ; } . editarea _popup img { border : 0 ; } . editarea _popup . close _popup { float : right ; line - height : 16 px ; border : 0 ; padding : 0 ; } . editarea _popup h1 , . editarea _popup h2 , . editarea _popup h3 , . editarea _popup h4 , . editarea _popup h5 , . editarea _popup h6 { margin : 0 ; padding : 0 ; } . editarea _popup . copyright { text - align : right ; } div # area _search _replace { } div # area _search _replace img { border : 0 ; } div # area _search _replace div . button { text - align : center ; line - height : 1.7 em ; } div # area _search _replace . button a { cursor : pointer ; border : solid 1 px # 888888 ; background - color : # DEDEDE ; text - decoration : none ; padding : 0 2 px ; color : # 000000 ; white - space : nowrap ; } div # area _search _replace a : hover { background - color : # EDEDED ; } div # area _search _replace # move _area _search _replace { cursor : move ; border : solid 1 px # 888 ; } div # area _search _replace # close _area _search _replace { text - align : right ; vertical - align : top ; white - space : nowrap ; } div # area _search _replace # area _search _msg { height : 18 px ; overflow : hidden ; border - top : solid 1 px # 888 ; margin - top : 3 px ; } # edit _area _help { width : 350 px ; } # edit _area _help div . close _popup { float : right ; } . area _toolbar { width : 100 % ; margin : 0 ; padding : 0 ; background - color : # ECE9D8 ; text - align : center ; } . area _toolbar , . area _toolbar table { font : 11 px sans - serif ; } . area _toolbar img { border : 0 ; vertical - align : middle ; } . area _toolbar input { margin : 0 ; padding : 0 ; } . area _toolbar select { font - family : 'MS Sans Serif' , sans - serif , Verdana , Arial ; font - size : 7 pt ; font - weight : normal ; margin : 2 px 0 0 0 ; padding : 0 ; vertical - align : top ; background - color : # F0F0EE ; } table . statusbar { width : 100 % ; } . area _toolbar td . infos { text - align : center ; width : 130 px ; border - right : solid 1 px # 888 ; border - width : 0 1 px 0 0 ; padding : 0 ; } . area _toolbar td . total { text - align : right ; width : 50 px ; padding : 0 ; } . area _toolbar td . resize { text - align : right ; } . area _toolbar span # resize _area { cursor : nw - resize ; visibility : hidden ; } . editAreaButtonNorm