//Dokumentation unter ] <nowiki>
/*global mw: true */
/*jshint evil: true*/
(function ($, libs) {
var botfrontend = {
version: 1.1,
log: function (text) {
$('#botlogs').append(mw.html.element('textarea', {rows: 20}, text));
},
loadAutoedit: function () {
mw.loader.load('jquery.async');
if (libs.autoedit === undefined) { //</nowiki>
libs.jsmodules.load(']');
} //<nowiki>
},
exec: function () {
var code = $('#codeInput').val();
code = code.replace(/ JSBot\b/g, ' libs.JSBot')
.replace(/\bbotlog\b/g, 'botfrontend.log');
eval(code);
},
init: function () {
var $sONM = $(mw.html.element('input', {type: 'button', value: 'stopOnNewMessage'})).click(libs.JSBotFn.stopOnNewMessage),
$stop = $(mw.html.element('input', {type: 'button', value: 'stop'})).click(libs.JSBotFn.stop),
$cont = $(mw.html.element('input', {type: 'button', value: 'cont'})).click(libs.JSBotFn.cont),
$abort = $(mw.html.element('input', {type: 'button', value: 'abort'})).click(libs.JSBotFn.abort),
$load = $(mw.html.element('input', {type: 'button', value: 'load autoedit.js'})).click(botfrontend.loadAutoedit),
$version = $(mw.html.element('span', {style: 'color: ' + (libs.JSBotFn.isBot() ? 'green' : 'red') + ';'},
botfrontend.version + ' (front), ' + libs.JSBotFn.version + ' (back)')),
$code = $(mw.html.element('textarea', {id: 'codeInput', rows: 20})),
$exec = $(mw.html.element('input', {type: 'button', value: 'exec'})).click(botfrontend.exec),
$logs = $(mw.html.element('div', {id: 'botlogs'}));
$('#mw-content-text').empty().append($sONM).append($stop).append($cont).append($abort).append($load).append($version).append('<br/>')
.append($code).append($exec).append($logs);
}
};
if (mw.config.get('debug')) {window.botfrontend = botfrontend;}
$(document).trigger('loadWikiScript', );
if (mw.config.get('wgCanonicalSpecialPageName') === 'Blankpage' && mw.util.getParamValue('action') === 'bot') {
$(botfrontend.init);
}
})(jQuery, mw.libs);
//</nowiki>