User:Fubuki風吹/disableCodeEditor.js

/** * disableCodeEditor.js * * Disables code editor on css/js pages introduced with the new syntax highlighting for source editor * The editor is overall buggy, slow and annoying * This script is the ajax equivalent of the editor that was used before the code editor * Looks Monobook-ish * * @author: w:user:Fubuki風吹 */

if (/\.(css|js)/g.test(mw.config.get('wgPageName')) || mw.config.get('wgCanonicalNamespace') == 'Module') { var html = $('#mw-content-text').html; $('#ca-edit').on('click', function(e) {       e.preventDefault;        $('#mw-content-text').html('  Loading editor... ');       $.get('/wiki/' + mw.config.get('wgPageName') + '?action=raw', function(data) { $('#mw-content-text').html(' Edit summary:   Minor edit Publish Cancel '); $('#wpTextbox').val(data || ''); $('#wpSubmit').on('click', function {               $('#status').css('display', 'inline').html(' Publishing edit...');                var data = {                    action: 'edit',                    title: mw.config.get('wgPageName'),                    text: $('#wpTextbox').val,                    token: mw.user.tokens.values.editToken,                    format: 'json'                };                if ($('#wpEditSummary').val.length) data.summary = $('#wpEditSummary').val;                if ($('#wpMinorEdit:checked').length) data.minor = '';                $.post(mw.util.wikiScript('api'), data, function(data) { if (!data.error) { $('#status').css('color', 'green').html('Edit successfully made!'); window.location.reload; } else { $('#status').css('color', 'red').html('Failed to edit page. Try again.'); }               });            });            $('#wpCancel').on('click', function {                $('#mw-content-text').html(html);            }); });   }); }