Overview
Comment: | Éditeur de code intégré |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
133f6f96c1afa210313a22eabbf90b7d |
User & Date: | bohwaz on 2014-01-29 17:20:47 |
Other Links: | manifest | tags |
Context
2014-01-29
| ||
17:35 | Correction modification appel static cache pour les camemberts check-in: 20b164ea30 user: bohwaz tags: trunk | |
17:20 | Éditeur de code intégré check-in: 133f6f96c1 user: bohwaz tags: trunk | |
16:47 | + Ce compte est passif + Renommage des squelettes + Corrections markup check-in: b6b75e1a05 user: bohwaz tags: trunk | |
Changes
Modified src/templates/admin/config/site.tpl from [758d7caa10] to [79f26b3d27].
︙ | ︙ | |||
17 18 19 20 21 22 23 | Modifications enregistrées. </p> {/if} <fieldset class="skelEdit"> <legend>{$edit.file|escape}</legend> <p> | | > > > > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | Modifications enregistrées. </p> {/if} <fieldset class="skelEdit"> <legend>{$edit.file|escape}</legend> <p> <textarea name="content" cols="90" rows="50" id="f_content">{form_field name=content data=$edit}</textarea> </p> </fieldset> <p class="submit"> {csrf_field key=$csrf_key} <input type="submit" name="save" value="Enregistrer →" /> </p> </form> <script type="text/javascript" src="{$admin_url}static/code_editor.min.js"></script> <script type="text/javascript"> var doc_url = "{$admin_url}doc/skel/"; var skel_list = {$sources_json}; var skel_current = "{$edit.file|escape}"; </script> <script type="text/javascript" src="{$admin_url}static/skel_editor.js"></script> {else} <div class="templatesList"> <h3>Squelettes du site</h3> <ul> {foreach from=$sources item="source"} <li><a href="?edit={$source|escape:'url'}">{$source|escape}</a></li> {/foreach} </ul> </div> {/if} {include file="admin/_foot.tpl"} |
Modified src/www/admin/config/site.php from [3f77107fc4] to [c9a6330cc6].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | $error = "Impossible d'enregistrer le squelette."; } } } $tpl->assign('edit', array('file' => trim(utils::get('edit')), 'content' => $source)); $tpl->assign('csrf_key', $csrf_key); } else { $tpl->assign('sources', Squelette::listSources()); } $tpl->assign('error', $error); $tpl->display('admin/config/site.tpl'); ?> | > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | $error = "Impossible d'enregistrer le squelette."; } } } $tpl->assign('edit', array('file' => trim(utils::get('edit')), 'content' => $source)); $tpl->assign('csrf_key', $csrf_key); $tpl->assign('sources_json', json_encode(Squelette::listSources())); } else { $tpl->assign('sources', Squelette::listSources()); } $tpl->assign('error', $error); $tpl->display('admin/config/site.tpl'); ?> |
Added src/www/admin/static/code_editor.min.js version [efbd29b03e].
> | 1 | (function(){window.textEditor=function(a){if(!document.getElementById(a))throw new Error("Invalid ID parameter: "+a);this.id=a;this.textarea=document.getElementById(a);this.shortcuts=[];this._key_map={8:'backspace',9:'tab',13:'enter',16:'shift',17:'ctrl',18:'alt',20:'capslock',27:'esc',32:'space',33:'pageup',34:'pagedown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',45:'ins',46:'del',91:'meta',93:'meta',224:'meta',106:false,107:false,109:false,110:false,111:false,186:false,187:false,188:false,189:false,190:false,191:false,192:false,219:false,220:false,221:false,222:false};for(var b=1;b<20;++b)this._key_map[111+b]='f'+b;for(b=0;b<=9;++b)this._key_map[b+96]=b;this.preventKeyPress=false;var c=this;this.textarea.addEventListener('keydown',this.keyEvent,true);this.textarea.addEventListener('keypress',this.keyEvent,true);};textEditor.prototype.keyEvent=function(a){var a=a||window.event;if(that.preventKeyPress&&a.type=='keypress'){that.preventKeyPress=false;return that.preventDefault(a);}for(var b in that.shortcuts){var c=that.shortcuts[b];if(a.metaKey)continue;if((a.ctrlKey&&!c.ctrl)||(c.ctrl&&!a.ctrlKey))continue;if((a.shiftKey&&!c.shift)||(c.shift&&!a.shiftKey))continue;if((a.altKey&&!c.alt)||(c.alt&&!a.altKey))continue;if(!(b=that.matchKeyPress(c.key,a)))continue;if(typeof c.callback!='function'){var d=(c.ctrl?'Ctrl-':'')+(c.alt?'Alt-':'');d+=(c.shift?'Shift-':'')+c;throw new Error("Invalid callback type for shortcut "+d);}var e=c.callback.call(that,a,b);if(a.type=='keydown'&&e)that.preventKeyPress=true;return e?that.preventDefault(a):true;}return true;};textEditor.prototype.matchKeyPress=function(a,b){b.key=(typeof b.which==='number'&&b.charCode)?b.which:b.keyCode;a=a.toLowerCase();if(b.type=='keypress'&&b.which)return(a==String.fromCharCode(b.key).toUpperCase())?a:false;else if(this._key_map[b.key])return(this._key_map[b.key]==a)?a:false;else return(String.fromCharCode(b.key).toLowerCase()==a)?a:false;};textEditor.prototype.preventDefault=function(a){if(a.preventDefault)a.preventDefault();if(a.stopPropagation)a.stopPropagation();a.returnValue=false;a.cancelBubble=true;return false;};textEditor.prototype.getSelection=function(){var a=this.textarea;if('selectionStart' in a){var b=a.selectionEnd-a.selectionStart;return{start:a.selectionStart,end:a.selectionEnd,length:b,text:a.value.substr(a.selectionStart,b)};}else if(document.selection){a.focus();var c=document.selection.createRange();var d=a.createTextRange();var e=d.duplicate();e.moveToBookmark(c.getBookmark());d.setEndPoint('EndToStart',e);if(c==null||d==null)return{start:a.value.length,end:a.value.length,length:0,text:''};var f=c.text.replace(/[\r\n]/g,'.');var g=a.value.replace(/[\r\n]/g,'.');var h=g.indexOf(f,d.text.length);return{start:h,end:h+f.length,length:f.length,text:c.text};}else return{start:a.value.length,end:a.value.length,length:0,text:''};};textEditor.prototype.replaceSelection=function(a,b){var c=this.textarea;var d=a.start;var e=d+b.length;c.value=c.value.substr(0,d)+b+c.value.substr(a.end,c.value.length);this.setSelection(d,e);return{start:d,end:e,length:b.length,text:b};};textEditor.prototype.insertAtPosition=function(a,b,c){var d=a+b.length;var e=this.textarea;e.value=e.value.substr(0,a)+b+e.value.substr(a,e.value.length-a);if(!c)c=d;return this.setSelection(c,c);};textEditor.prototype.setSelection=function(a,b){var c=this.textarea;if('selectionStart' in c){c.focus();c.selectionStart=a;c.selectionEnd=b;}else if(document.selection){c.focus();var d=c.createTextRange();var e=a;for(i=0;i<e;i++)if(c.value[i].search(/[\r\n]/)!=-1)a=a-.5;e=b;for(i=0;i<e;i++)if(c.value[i].search(/[\r\n]/)!=-1)b=b-.5;d.moveEnd('textedit',-1);d.moveStart('character',a);d.moveEnd('character',b-a);d.select();}return this.getSelection();};textEditor.prototype.scrollToSelection=function(a){var b=this.textarea;var c=b.value.substr(a.end);b.value=b.value.substr(0,a.end);b.scrollTop=100000;var d=b.scrollTop;b.value+=c;b.scrollTop=d;this.setSelection(a.start,a.end);};textEditor.prototype.wrapSelection=function(a,b,c){var d=this.textarea;var e=d.scrollTop;var f=a.text;var a=this.replaceSelection(a,b+f+c);if(f=='')a=this.setSelection(a.start+b.length,a.start+b.length);d.scrollTop=e;return a;};}());(function(){function a(a){function b(){}b.prototype=a;return new b();}String.prototype.repeat=function(a){return new Array(a+1).join(this);};window.codeEditor=function(a){textEditor.call(this,a);this.onlinechange=null;this.onlinenumberchange=null;this.fullscreen=false;this.nb_lines=0;this.current_line=0;this.search_str=null;this.search_pos=0;this.params={indent_size:4,tab_size:8,convert_tabs:true,lang:{search:"Text to search?\n(regexps allowed, begin them with '/')",replace:"Text for replacement?\n(use $1, $2... for regexp replacement)",search_selection:"Text to replace in selection?\n(regexps allowed, begin them with '/')",replace_result:"%d occurence found and replaced.",goto:"Line to go to:",no_search_result:"No search result found."}};that=this;this.init();this.textarea.spellcheck=false;this.shortcuts.push({shift:true,key:'tab',callback:this.indent});this.shortcuts.push({key:'tab',callback:this.indent});this.shortcuts.push({ctrl:true,key:'f',callback:this.search});this.shortcuts.push({ctrl:true,key:'h',callback:this.searchAndReplace});this.shortcuts.push({ctrl:true,key:'g',callback:this.goToLine});this.shortcuts.push({key:'F3',callback:this.searchNext});this.shortcuts.push({key:'backspace',callback:this.backspace});this.shortcuts.push({key:'enter',callback:this.enter});this.shortcuts.push({key:'"',callback:this.insertBrackets});this.shortcuts.push({key:'[',callback:this.insertBrackets});this.shortcuts.push({key:'{',callback:this.insertBrackets});this.shortcuts.push({key:'(',callback:this.insertBrackets});this.shortcuts.push({key:'F11',callback:this.toggleFullscreen});this.textarea.addEventListener('keypress',this.keyEvent,true);this.textarea.addEventListener('keydown',this.keyEvent,true);};codeEditor.prototype=a(textEditor.prototype);codeEditor.prototype.init=function(){var a=this;this.nb_lines=this.countLines();this.parent=document.createElement('div');this.parent.className='codeEditor';this.lineCounter=document.createElement('span');this.lineCounter.className='lineCount';for(i=1;i<=this.nb_lines;i++)this.lineCounter.innerHTML+='<b>'+i+'</b>';this.lineCounter.innerHTML+='<i>---</i>';this.parent.appendChild(this.lineCounter);var b=document.createElement('div');b.className='container';b.appendChild(this.textarea.cloneNode(true));this.parent.appendChild(b);var c=this.textarea.parentNode;c.appendChild(this.parent);c.removeChild(this.textarea);this.textarea=this.parent.getElementsByTagName('textarea')[0];this.textarea.wrap='off';if(this.params.convert_tabs){this.textarea.value=this.textarea.value.replace(/[ ]{1,7}\t/g,' '.repeat(this.params.tab_size));this.textarea.value=this.textarea.value.replace(/\t/g,' '.repeat(this.params.tab_size));}this.textarea.addEventListener('focus',function(){a.update();},false);this.textarea.addEventListener('keyup',function(){a.update();},false);this.textarea.addEventListener('click',function(){a.update();},false);this.textarea.addEventListener('scroll',function(){a.lineCounter.scrollTop=a.textarea.scrollTop;},false);};codeEditor.prototype.update=function(){var a=this.getSelection();var b=this.getLineNumberFromPosition(a);var c=this.countLines();this.search_pos=a.end;if(c!=this.nb_lines){var d=this.lineCounter.getElementsByTagName('b');for(var e=this.nb_lines;e>c;e--)this.lineCounter.removeChild(d[e-1]);var f=this.lineCounter.lastChild;for(var e=d.length;e<c;e++){var g=document.createElement('b');g.innerHTML=e+1;this.lineCounter.insertBefore(g,f);}this.nb_lines=c;if(typeof this.onlinenumberchange==='function')this.onlinenumberchange.call(this);}if(b!=this.current_line){var d=this.lineCounter.getElementsByTagName('b');for(var e=0;e<this.nb_lines;e++)d[e].className='';d[b].className='current';this.current_line=b;if(typeof this.onlinechange==='function')this.onlinechange.call(this);}};codeEditor.prototype.countLines=function(){var a=this.textarea.value.match(/(\r?\n)/g);return a?a.length+1:1;};codeEditor.prototype.getLineNumberFromPosition=function(a){var a=a||this.getSelection();if(a.start==0)return 0;var b=this.textarea.value.substr(0,a.start).match(/(\r?\n)/g);return b?b.length:0;};codeEditor.prototype.getLines=function(){return this.textarea.value.split("\n");};codeEditor.prototype.getLine=function(a){return this.textarea.value.split("\n",a+1)[a];};codeEditor.prototype.getLinePosition=function(a,b){var c=0;for(i=0;i<a.length;i++){if(i==b)return{start:c+i,end:c+a[i].length,length:a[i].length,text:a[i]};c+=a[i].length;}return false;};codeEditor.prototype.goToLine=function(a){var b=window.prompt(that.params.lang.goto);if(!b)return;var c=this.textarea.value.split("\n",parseInt(b,10)).join("\n").length;this.scrollToSelection(this.setSelection(c,c));return true;};codeEditor.prototype.indent=function(a,b){var c=this.getSelection();var d=a.shiftKey;var e=this.getLines();var f=this.getLineNumberFromPosition(c);var g=this.getLinePosition(e,f);var h=(c.end>g.end)?true:false;if((c.length==0||!h)&&c.start!=g.start){this.insertAtPosition(c.start,' '.repeat(this.params.indent_size));return true;}if(c.length==0&&c.start==g.start){var i=(f-1 in e)?e[f-1].match(/^(\s+)/):false;if(!i||g.length!=0)var j=' '.repeat(this.params.indent_size);else var j=' '.repeat(i[1].length);this.insertAtPosition(c.start,j);return true;}var k=this.textarea.value.substr(c.start,(c.end-c.start));var e=k.split("\n");if(d){var l=new RegExp('^[ ]{1,'+this.params.indent_size+'}');for(var m=0;m<e.length;m++)e[m]=e[m].replace(l,'');}else for(var m=0;m<e.length;m++)e[m]=' '.repeat(this.params.indent_size)+e[m];k=e.join("\n");this.replaceSelection(c,k);return true;};codeEditor.prototype.search=function(){if(!(this.search_str=window.prompt(this.params.lang.search,this.search_str)))return;this.search_pos=0;return this.searchNext();};codeEditor.prototype.searchNext=function(){if(!this.search_str)return true;var a=this.getSelection();var b=a.end>=this.search_pos?this.search_pos:a.start;var c=this.textarea.value.substr(b);var d=this.getSearchRegexp(this.search_str);var e=c.search(d);if(e==-1)return window.alert(this.params.lang.no_search_result);var f=c.match(d);a.start=b+e;a.end=a.start+f[0].length;a.length=f[0].length;a.text=f[0];this.setSelection(a.start,a.end);this.search_pos=a.end;this.scrollToSelection(a);return true;};codeEditor.prototype.getSearchRegexp=function(a,b){var c,d;if(a.substr(0,1)=='/'){var e=a.lastIndexOf("/");c=a.substr(1,e-1);d=a.substr(e+1).replace(/g/,'');}else{c=a.replace(/([\/$^.?()[\]{}\\])/,'\\$1');d='i';}if(b)d+='g';return new RegExp(c,d);};codeEditor.prototype.searchAndReplace=function(a){var b=this.getSelection();var c=b.length!=0?this.params.lang.search_selection:this.params.lang.search;if(!(s=window.prompt(c,this.search_str))||!(r=window.prompt(that.params.lang.replace)))return true;var d=this.getSearchRegexp(s,true);if(b.length==0){var e=this.textarea.value.match(d).length;this.textarea.value=this.textarea.value.replace(d,r);}else{var e=b.text.match(d).length;this.replaceSelection(b,b.text.replace(d,r));}window.alert(this.params.lang.replace_result.replace(/%d/g,e));return true;};codeEditor.prototype.enter=function(a){var b=this.getSelection();var c=this.getLineNumberFromPosition(b);var d='';c=this.getLine(c);if(this.textarea.value.substr(b.start-1,1)=='{')d+=' '.repeat(this.params.indent_size);if(match=c.match(/^(\s+)/))d+=match[1];if(!d)return false;this.insertAtPosition(b.start,"\n"+d);return true;};codeEditor.prototype.backspace=function(a){var b=this.getSelection();if(b.length>0)return false;var c=this.textarea.value.substr(b.start-2,2);if(c=='""'||c=="''"||c=='{}'||c=='()'||c=='[]'){b.start-=2;this.replaceSelection(b,'');return true;}var c=this.textarea.value.substr(b.start-20,20);if((pos=c.search(/^(\s+)$/m))!=-1){b.start-=this.params.indent_size;this.replaceSelection(b,'');return true;}return false;};codeEditor.prototype.insertBrackets=function(a,b){var c=this.getSelection();var d=b;var e=d;switch(d){case '(':e=')';break;case '[':e=']';break;case '{':e='}';break;}if(c.length==0)this.insertAtPosition(c.start,d+e,c.start+1);else this.wrapSelection(c,d,e);return true;};codeEditor.prototype.toggleFullscreen=function(a){var b=this.parent.className.split(' ');for(var c=0;c<b.length;c++)if(b[c]=='fullscreen'){b.splice(c,1);this.parent.className=b.join(' ');this.fullscreen=false;return true;}b.push('fullscreen');this.parent.className=b.join(' ');this.fullscreen=true;return true;};}()); |
Added src/www/admin/static/skel_editor.css version [9d1b561b6e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | .codeEditor { width: 100%; height: 600px; border: 1px solid #999; background: #eee; position: relative; display: block; } .codeEditor .sk_help { background: #ccc; border-top: 2px solid #999; position: absolute; left: 0; right: 0; bottom: 0; height: 15px; padding: 5px 1em 0; font-family: "Deja Vu Sans Mono", "Droid Sans Mono", "Courier New", Courier, monospace; font-size: 12px; } .codeEditor .sk_toolbar { background: #ccc; border-bottom: 2px solid #999; height: 32px; } .codeEditor .sk_toolbar select { float: right; border: none; border-radius: .2em; height: 24px; padding-left: 24px; margin: 4px .5em; background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEUAAACZm4leYFyOkX1RU09MTkp9f2+ys6KwsZrn5+KanIz///+6u6vGxryDhXtVV1Otpz1oAAAAA3RSTlMA+7omiqY6AAAAgklEQVQI12NI+f9fgQEEfO7e+QBm/BGU+P8fJPrd2LgLCD4AGSCBLCDD8Pfu3bu9QCK/Z86e/esDw4/Hv+/euf0ZyEj7PXPnbCDDI+33kZDQkE8M/11D1969e9eEwRNIlpe332f421Ne0dHRcYnh75k7Z8/cudPEoOIS4uriAlQMAwDpN0taA/g97gAAAABJRU5ErkJggg==") no-repeat 5px center; cursor: pointer; } .codeEditor .sk_toolbar select:hover { background-color: #fff; } .codeEditor .sk_toolbar p { display: inline; padding: .3em .5em; border-radius: .5em; font-size: .9em; margin-left: 2em; } .codeEditor .sk_toolbar input { margin: 4px .5em; padding: 0; width: 24px; height: 24px; border: none; border-radius: .2em; cursor: pointer; text-indent: -70em; overflow: hidden; background: transparent no-repeat center center; } .codeEditor .sk_toolbar input:hover { background-color: #fff; } .codeEditor .sk_toolbar .save { margin-left: 2em; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEU6XIthfJfOXAD8rz6PpsDe3t7+/v6YrsZhe5NVV1Py8vL09PTMzc6+0upyn88gSod8oq0HAAAAAXRSTlOZyTXzhgAAAGxJREFUCNdj4P+kBAT6Hxj+XjYGAtv7DH+fbQOCfSBGKBDkgRi7gQAschQoAmbsXrVq1ToQIw0IQGregQGQ8bCjo6OvDsQ4czS04jmQ8eLMzJiDUMYZkMj3ilAIg/9h6PEjJ4AMhp8zgeD/BwBY4VdD5HZlvAAAAABJRU5ErkJggg=="); } .codeEditor .sk_toolbar .reset { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAABCklEQVR42p2TsUrDUBSGv4RM2qlLXXwBHdoncG3u5tpZx059gojgZAtC3bqqa7cQKH2FWiFZHUSIg5lChi7Xpak312Ma/eHA5Zzz/5fzHw5UMQZ0wxgDOCb5fnQ8Glxe0AR31zdcPW0mpoDOkoDPJKRI41rywdEpRRrTHeZ4drFIY15nh5w/f4jkea/D2aPafeJKTVuyI4Ut7G0NkVDmnbpxXMAHyJJgl1xPW+XT32emC0SA3z75FugO85Ic8Qf0jR33a/p0lgR6PW1pQJtbiPbNK8GzDLPhNBVAKVUphGGIJD7vdWQBi1SBuSGA/P1FFvgNb8vbH7nFaoO5Ja2Uki6Ommt8ME36t4lfRLtlZDAJ4ScAAAAASUVORK5CYII="); } .codeEditor .sk_toolbar .search { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAABGdBTUEAAK/INwWK6QAAADBQTFRF////epWwPGiTdYKPdHqB1tbWWW6Hp6enR2yQc6b/dqncME9tmcz/i5CX5e32w9PmM3gGSwAAAAd0Uk5TAAAAQoTswgXk1s4AAABySURBVAjXYxA0v+4syAAEIqXvQh1BDPN3J88Vgxj3/r07EwtmnDw58y2YcebMHLBI6p/358NADN/3Z75eFhQUZFC5/i4WqIaRwcjtdsrWa0AGEDByr2oAM5i4V82AMBh2nGmCMIBCEAbDrhVghpKS9jYA43soYFw0gPcAAAAASUVORK5CYII="); } .codeEditor .sk_toolbar .search_replace { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEUAAABnVEEAAACEhoVsaWX4liHmz2/8/Pzf398uNDawrKfn5+fOXADj4+P+/v6IioXFYmG9AAAAAnRSTlMAWv0tddIAAACKSURBVAjXY2Dg/w8EAgwMDP/evSuvWwhi7N69Y8UrATDjxurbC4CMn/P3rv9vwMDw3+/J31s9BxkYOl/vm3vjaCiEsSc0hoGhxe+J7dHUgwxckz0nAwUCGDotO3qPph4zYJg8q+P20Zg+AwbJ9rt3VE60f2BgML+76VgHiPH93bt3z8uBjP9g8AEArPJMCYP5JmIAAAAASUVORK5CYII="); } .codeEditor .sk_toolbar .gotoline { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX///9BQUEVFRWysrREREQ4ODhVVVX7+/vu7u7q6uqcnJy+vr/m5ub19fXc3Nz///89lwBDAAAAB3RSTlMAAILOakNmMhUGwgAAAHtJREFUCNdjYIABQbE0EEhkEMx793r37tdmDILZu1fv3rVqEYNgfv3/u/X/vwEZu4/Xl5eXARnbd96trS1hcPNaWdd7924Jg+///7UdHR1XGIK01lSfnDmzhUFQY8W6N2fOABl+q/a8OXfmCYOg3jugwJlJDIJKEMCAAQCfIDck8YzyWAAAAABJRU5ErkJggg=="); } .codeEditor .sk_toolbar .fullscreen { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAADFBMVEUAAABMTFFOTlBOTlCQ1uMHAAAAA3RSTlMAOcKBmOr4AAAAQUlEQVQI12P4/4D7P8N/B0Yo8XsC23+GZw+4pzM4TmBzYsAGgBKODNcecM9m+D+B7T3DPwfG/Qz/G5iABlzg+g8ANzMax/3kkQoAAAAASUVORK5CYII="); } .codeEditor.fullscreen .sk_toolbar .fullscreen { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAADFBMVEUAAABNTVFOTlBOTlBLB/faAAAAA3RSTlMAOsPdsomtAAAAQElEQVQI12NIEWCRZNi5gTePIe8D/08G6Q/8Txj0P/B/YVj/gf8fAzawHyQhD1ICJvI/8O9k2FnAl8eQosAiCQCgixb13aKGIwAAAABJRU5ErkJggg=="); } .codeEditor .lineCount, .codeEditor textarea { font-family: "Deja Vu Sans Mono", "Droid Sans Mono", "Courier New", Courier, monospace; font-size: 11pt; line-height: 11pt; } .codeEditor .lineCount { position: absolute; top: 34px; left: 0; bottom: 22px; width: 46px; text-align: right; border-right: 2px solid #999; overflow: hidden; } .codeEditor .lineCount i { display: block; padding-right: 2px; font-weight: normal; } .codeEditor .lineCount b { display: block; padding-right: 2px; font-weight: normal; } .codeEditor .lineCount b.current { background: #ccc; } .codeEditor .container { position: absolute; right: 4px; top: 34px; bottom: 22px; left: 50px; margin: 0; padding: 0; } .codeEditor textarea { height: 100%; width: 100%; padding: 0 0 0 2px; margin: 0; background: transparent; border: none; overflow: auto; resize: none; } .codeEditor.fullscreen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; } |
Added src/www/admin/static/skel_editor.js version [817c771ee9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | (function (){ var www_url = document.body.getAttribute('data-url'); var css = document.createElement('link'); css.type = 'text/css'; css.rel = 'stylesheet'; css.href = www_url + 'static/skel_editor.css'; document.head.appendChild(css); var save_btn = document.querySelector('input[name=save]'); save_btn.type = 'hidden'; var code = new codeEditor('f_content'); code.params.lang = { search: "Texte à chercher ?\n(expression régulière autorisée, pour cela commencer par un slash '/')", replace: "Texte pour le remplacement ?\n(utiliser $1, $2... pour les captures d'expression régulière)", search_selection: "Texte à chercher dans la sélection ?\n(expression régulière autorisée, pour cela commencer par un slash '/')", replace_result: "%d occurences trouvées et remplacées.", goto: "Aller à la ligne :", no_search_result: "Aucun résultat trouvé." }; code.origValue = code.textarea.value; code.saved = true; code.onlinechange = function () { if ((p = this.parent.querySelector('nav p')) && this.origValue != code.textarea.value) { toolbar.removeChild(p); } var line = this.getLine(this.current_line); var doc = []; if (match = line.match(/<BOUCLE(\d+|_[a-zA-Z0-9_-]+)\(([A-Z]+)\)(.*?)>/)) { doc.push({link: 'Boucles', title: 'BOUCLE'}); doc.push({link: 'Boucle-'+match[2], title: match[2]}); if (match[3]) { if (match[3].match(/\{".*"\}/)) doc.push({link: 'Critere-inter', title: 'Critère inter-résultat {"..."}'}); if (match[3].match(/\{\d+(,\d+)?\}/)) doc.push({link: 'Critere-de-nombre', title: 'Critère de nombre {X,Y}'}); if (match[3].match(/\{par\s+.*\}/)) doc.push({link: 'Critere-d-ordre', title: 'Critère d\'ordre {par champ}'}); if (match[3].match(/\{inverse\}/)) doc.push({link: 'Critere-inverse', title: 'Critère {inverse}'}); } } if (match = line.match(/<INCLURE\{(.*?)\}>/)) { doc.push({link: 'Inclure', title: 'Inclusion du fichier ' + match[1]}); } if (match = line.match(/#[A-Z0-9_]+(\*?(\|.*?)?\).*?\])?/g)) { for (var i = 0; i < match.length; i++) { var tag = match[i].match(/(#[A-Z0-9_]+)(\*?(\|(.*?))?\).*?\])?/); doc.push({title: 'Balise ' + tag[1]}); if (typeof tag[4] != 'undefined') { var tag = tag[4].split('|'); for (var j = 0; j < tag.length; j++) { var end = tag[j].indexOf('{'); end = (end == -1) ? tag[j].length : end; var f = tag[j].substr(0, end); doc.push({link: 'Filtre-'+f, title: 'Filtre '+f}); } } } } help.innerHTML = ''; for (var i = 0; i < doc.length; i++) { help.innerHTML += ' | '; if (doc[i].link) help.innerHTML += '<a href="' + doc_url + '#' + doc[i].link + '" onclick="return !window.open(this.href);">' + doc[i].title + '</a>'; else if (doc[i].tag) help.innerHTML += '<' + tag + '>' + doc[i].title + '</' + tag + '>'; else help.innerHTML += doc[i].title; } return false; }; code.saveFile = function (e) { if (this.fullscreen) this.textarea.form.action += '&fullscreen'; this.textarea.form.submit(); }; code.loadFile = function (e) { var file = e.target.value; if (file == skel_current) return; if (code.textarea.value != code.origValue && !window.confirm("Le fichier a été modifié, abandonner les modifications ?")) { for (var i = 0; i < e.target.options.length; i++) { e.target.options[i].selected = false; if (e.target.options[i].value == skel_current) { e.target.options[i].selected = true; } } return false; } var url = www_url + 'config/site.php?edit=' + encodeURIComponent(file); window.location.href = url + (code.fullscreen ? '#fullscreen' : ''); return true; }; code.resetFile = function (e) { if (this.textarea.value == this.origValue) return; if (!window.confirm("Le fichier a été modifié, abandonner les modifications ?")) return; this.textarea.form.reset(); }; var help = document.createElement('div'); help.className = 'sk_help'; code.parent.appendChild(help); var toolbar = document.createElement('nav'); toolbar.className = 'sk_toolbar'; var appendButton = function (name, title, action) { var btn = document.createElement('input'); btn.type = 'button'; btn.value = btn.title = title; btn.className = name; btn.onclick = function () { action.call(code); return false; }; toolbar.appendChild(btn); }; appendButton('save', 'Enregistrer les modifications', code.saveFile); appendButton('reset', 'Recharger le fichier (effacer les modifications)', code.resetFile); appendButton('search', 'Chercher', code.search); appendButton('search_replace', 'Chercher et remplacer', code.searchAndReplace); appendButton('gotoline', 'Aller à la ligne', code.goToLine); appendButton('fullscreen', 'Plein écran', code.toggleFullscreen); var sel = document.createElement('select'); sel.title = 'Charger un autre fichier'; sel.onchange = code.loadFile; for (var i in skel_list) { if (!skel_list.hasOwnProperty(i)) continue; var skel = skel_list[i]; var opt = document.createElement('option'); opt.value = skel; opt.innerHTML = skel; opt.selected = (skel == skel_current) ? true : false; sel.appendChild(opt); } toolbar.appendChild(sel); code.parent.insertBefore(toolbar, code.parent.firstChild); if (window.location.hash.match(/fullscreen/)) { code.toggleFullscreen(); if (msg = document.querySelector('p.error, p.confirm')) { var m = document.createElement('p'); m.innerHTML = msg.innerHTML; m.className = msg.className; toolbar.appendChild(m); msg.parentNode.removeChild(msg); } window.location.hash = ''; } }()); |