// QuickEK script by [[:pl:User:ChP94]]
// based on quickimgdelete.js script written by [[:en:User:Howcheng]]
// Released under the [http://www.gnu.org/licenses/gpl.txt GNU Public License (GPL)]
// <nowiki>
var quickEkGadget = {
version: 1,
autosave: true,
reasonPrompt: "Dlaczego uważasz, że ta strona powinna zostać usunięta?",
quickEkCaption: "Ekspresowe kasowanie",
quickEkTooltip: "Zgłoś artykuł do ekspresowego kasowania",
quickEkSummary: "[[Category:Other speedy deletions" + "|sd]]",
quickEkTemplate: "{" + "{ek|1=$1}}\n",
fastEkCaption: "Błyskawiczne kasowanie",
fastEkTooltip: "Zgłoś artykuł do ekspresowego kasowania bez podawania powodu",
fastEkSummary: "[[Category:Other speedy deletions" + "|sd]]",
fastEkTemplate: "{" + "{ek}}\n",
ekRegex: /\{\{(?:ek|delete)/,
errorMissingCookie: "Akcja QuickEk została przerwana, ponieważ nie odnaleziono ciasteczka z informacją potwierdzającą wykonanie operacji przez użytkownika",
quickEk: function() {
var reason = prompt( this.reasonPrompt, '' );
if ( ( reason ) && ( reason != "" ) ) {
var titleEncoded = encodeURIComponent( mw.config.get( 'wgPageName' ) );
var reasonEncoded = encodeURIComponent( reason );
jQuery.cookie( 'quickEkPage', mw.config.get( 'wgPageName' ), {
path: '/'
} );
window.location.href = mw.config.get( 'wgScript' ) + '?title=' + titleEncoded + '&action=edit&quickEkAction=quickek&reason=' + reasonEncoded;
}
},
fastEk: function() {
var titleEncoded = encodeURIComponent( mw.config.get( 'wgPageName' ) );
jQuery.cookie( 'quickEkPage', mw.config.get( 'wgPageName' ), {
path: '/'
} );
window.location.href = mw.config.get( 'wgScript' ) + '?title=' + titleEncoded + '&action=edit&quickEkAction=fastek';
},
init: function() {
if ( document.getElementById( 'ca-edit' ) == null ) { // not editable by non-admin
return;
}
mw.util.addPortletLink( 'p-tb', 'javascript:quickEkGadget.fastEk()', this.fastEkCaption, 'fast-ek', this.fastEkTooltip );
mw.util.addPortletLink( 'p-tb', 'javascript:quickEkGadget.quickEk()', this.quickEkCaption, 'quick-ek', this.quickEkTooltip );
var fakeaction = mw.util.getParamValue( 'quickEkAction' );
if ( fakeaction != null && document.editform ) {
// Protection against malicious links
var quickEkPage = jQuery.cookie( 'quickEkPage' );
if ( quickEkPage != mw.config.get( 'wgPageName' ) ) {
alert( this.errorMissingCookie );
return;
}
var content = document.editform.wpTextbox1.value;
if ( ( content == null ) || ( content == "" ) || ( content.match( this.ekRegex ) ) ) {
return;
}
if ( fakeaction == "quickek" ) {
var reason = decodeURIComponent( mw.util.getParamValue( 'reason' ) );
if ( ( reason == null ) || ( reason == "" ) ) {
return;
}
content = this.quickEkTemplate.replace( /\$1/, reason ) + content;
document.editform.wpTextbox1.value = content;
document.editform.wpSummary.value = this.quickEkSummary;
if ( this.autosave ) {
document.editform.wpSave.click();
}
} else if ( fakeaction == "fastek" ) {
content = this.fastEkTemplate + content;
document.editform.wpTextbox1.value = content;
document.editform.wpSummary.value = this.fastEkSummary;
if ( this.autosave ) {
document.editform.wpSave.click();
}
}
}
}
}
mw.loader.using( "mediawiki.util", function() {
jQuery( document ).ready( function() {
quickEkGadget.init();
} );
} );
//</nowiki>