MediaWiki:Gadget-CodeEditor.js
Bước tới điều hướng
Bước tới tìm kiếm
Chú ý: Sau khi lưu trang, có thể bạn sẽ phải xóa bộ nhớ đệm của trình duyệt để xem các thay đổi.
- Firefox / Safari: Nhấn giữ phím Shift trong khi nhấn Tải lại (Reload), hoặc nhấn tổ hợp Ctrl-F5 hay Ctrl-R (⌘R trên Mac)
- Google Chrome: Nhấn tổ hợp Ctrl-Shift-R (⇧⌘R trên Mac)
- Internet Explorer / Edge: Nhấn giữ phím Ctrl trong khi nhấn Làm tươi (Refresh), hoặc nhấn tổ hợp Ctrl-F5
- Opera: Nhấn tổ hợp Ctrl-F5.
/**
* MediaWiki:Gadget-codeeditor.js
* Stub to load [[Extension:CodeEditor]] and Ace syntax-highlighting editor as a gadget.
*
* Requires enhanced editing toolbar (WikiEditor extension); integrates with toolbar.
*
* Gadget stub CC-BY-SA 2
* (c) 2011 Brion Vibber <brion @ pobox.com>
*
* Extension:CodeEditor JS bits are GPLv2 -- http://www.mediawiki.org/wiki/Extension:CodeEditor
*
* Syntax highlighting, auto-indenting code editor widget for on-wiki JS and CSS pages.
* Uses embedded Ajax.org Cloud9 Editor: http://ace.ajax.org/
* MPL/LGPL/GPL
*/
(function($) {
// @fixme need an SSL alternative
mw.config.set('wgCodeEditorAssetsPath', '//toolserver.org/~brion/extensions');
var moduleBase = mw.config.get('wgCodeEditorAssetsPath') + '/CodeEditor/modules',
$box = $('#wpTextbox1'),
matches = /\.(js|css)$/.exec(mw.config.get('wgTitle'));
if ($box.length && matches && (wgNamespaceNumber === 2 /* User: */ || wgNamespaceNumber === 8 /* MediaWiki: */)) {
$(function() {
var modules = [
moduleBase + '/ace/ace.js',
moduleBase + '/ace/mode-javascript.js',
moduleBase + '/ace/mode-css.js',
moduleBase + '/jquery.codeEditor.js',
moduleBase + '/ext.codeEditor.js'
];
var i = 0;
// @fixme loading serially is kinda lame, but it works for now
var ping = function() {
if ( i < modules.length ) {
var url = modules[i];
$.getScript(url, function() {
i++;
ping();
});
}
};
ping();
});
}
})
(jQuery);