User:Vadim/common.js
From CruisersWiki
(Difference between revisions)
Line 47: | Line 47: | ||
window.wikEdConfig.frameCSS = { | window.wikEdConfig.frameCSS = { | ||
'.wikEdTemplName': 'color: darkcyan;', | '.wikEdTemplName': 'color: darkcyan;', | ||
- | '.wikEdTempl': 'background: inherit;', | + | '#wikEdFrameHtml .wikEdTempl': 'background: inherit;', |
'.wikEdTemplTag': 'color: blue;', | '.wikEdTemplTag': 'color: blue;', | ||
Revision as of 17:50, 18 March 2016
addOnloadHook(function () { if (wgAction == 'edit' || wgAction == 'submit') { // if (true) { if (/\.js$/.test(wgPageName) || /\.css$/.test(wgPageName)) { // load Ace -- code editor -- https://ace.c9.io var initCodeEditor = function () { // https://ace.c9.io/#nav=embedding // https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts< var $wpTextbox1 = $( '#wpTextbox1' ); var $aceEditor = $( "<div></div>" ).insertAfter( "#wpTextbox1" ); $aceEditor.height($wpTextbox1.height()); $aceEditor.text($wpTextbox1.text()); $wpTextbox1.hide(); $('#toolbar').hide(); var editor = ace.edit($aceEditor[0]); var session = editor.getSession(); session.on( 'change', function(e) { // e.type, etc $wpTextbox1.text(editor.getValue()); }); // editor.setTheme("ace/theme/monokai"); session.setUseSoftTabs(true); session.setUseWrapMode(true); if (/\.js$/.test(wgPageName)) { session.setMode("ace/mode/javascript"); } else if (/\.css$/.test(wgPageName)) { session.setMode("ace/mode/css"); } }; loadScript('https://cdn.jsdelivr.net/ace/1.2.3/min/ace.js', initCodeEditor); //function () {}); } else { // install [[Wikipedia:WikEd]] in-browser text editor //loadWikiCss('CruisersWiki:WikiEd.css'); window.wikEdConfig = {}; window.wikEdConfig.frameCSS = { '.wikEdTemplName': 'color: darkcyan;', '#wikEdFrameHtml .wikEdTempl': 'background: inherit;', '.wikEdTemplTag': 'color: blue;', }; loadScript('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript'); } } });