Użytkownik:Polskacafe/fastSDU.js: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
Polskacafe (dyskusja • edycje) |
Polskacafe (dyskusja • edycje) |
||
Linia 41: | Linia 41: | ||
var currentDay = (new Date()).getDate(); |
var currentDay = (new Date()).getDate(); |
||
var currentdate = currentYear + '-' + (currentMonth<=9 ? '0' + currentMonth : currentMonth) + '-' + (currentDay<=9 ? '0' + currentDay : currentDay); |
var currentdate = currentYear + '-' + (currentMonth<=9 ? '0' + currentMonth : currentMonth) + '-' + (currentDay<=9 ? '0' + currentDay : currentDay); |
||
var api = new mw.Api(); |
|||
api.post({ |
|||
format: 'json', |
format: 'json', |
||
action: 'edit', |
action: 'edit', |
||
Linia 48: | Linia 50: | ||
token: mw.user.tokens.get('editToken'), |
token: mw.user.tokens.get('editToken'), |
||
summary: 'Dodano szablon SDU' /* wstaw własny powód edycji */ |
summary: 'Dodano szablon SDU' /* wstaw własny powód edycji */ |
||
}) |
}); |
||
api.post({ |
|||
format: 'json', |
format: 'json', |
||
action: 'edit', |
action: 'edit', |
Wersja z 16:27, 29 cze 2019
//<pre><nowiki>
/**
* Wystawianie SDU jednym kliknięciem (no dobra, więcej niż jednym, ale to taka nazwa)
* Autor: Polskacafe
* Używać na własną odpowiedzialność!
* W przypadku kopiowania, proszę, skopiuj również komentarze, w tym autora.
**/
function initButton() {
let namespace = mw.config.get("wgNamespaceNumber");
if (namespace !== -1 && namespace % 2 === 0 && [14, 110, 2].indexOf(wgNamespaceNumber) == -1) {
$('#p-views.vectorTabs > ul').prepend('<li id="ca-sdu" class="collapsible"><span><a title="Szybkie wystawianie SDU" data-id="fastSDU">SDU</a></span></li>');
$("a[data-id='fastSDU']").click(openWindow);
}
}
function openWindow() {
$('<div title="Zgłoszenie strony na SDU" id="sdu-window"><b>Podaj uzasadnienie zgłoszenia:</b><br /><input type="text" name="sduReason"/>')
.css({textAlign:"center"})
.dialog({
open: function(event, ui) {$(event.target).dialog('widget').css({ position: 'fixed' }).position({ my: 'center', at: 'center', of: window });},
close:function(){},
minHeight:"auto",
minWidth: 500,
resizable:false,
buttons:[
{text:"Anuluj", click:function(){$( this ).dialog( "close" );}},
{text:"Przeciw", click:function(){$(this).dialog("close");}},
{text:"Wstrzymuję się", click:function(){$(this).dialog("close");}},
{text:"Za", click:function(){$(this).dialog("close");}}
]
}
);
}
if($('#ca-edit')[0]) {$(document).ready(initButton);}
function sdupage(powod, strona) {
var currentYear = (new Date()).getFullYear();
var currentMonth = (new Date()).getMonth() + 1;
var currentDay = (new Date()).getDate();
var currentdate = currentYear + '-' + (currentMonth<=9 ? '0' + currentMonth : currentMonth) + '-' + (currentDay<=9 ? '0' + currentDay : currentDay);
var api = new mw.Api();
api.post({
format: 'json',
action: 'edit',
title: mw.config.get('wgPageName'),
prependtext: '{{subst:SDU}}\n',
token: mw.user.tokens.get('editToken'),
summary: 'Dodano szablon SDU' /* wstaw własny powód edycji */
});
api.post({
format: 'json',
action: 'edit',
title: 'Nonsensopedia:SDU/' + currentdate + '/' + mw.config.get('wgPageName'),
prependtext: '{{subst:SDU-nowe|powód=' + powod + '|podpis=~~~|strona=' + strona + '}}', //jak kopiujesz, to najprawdopodobniej musisz zmienić ~~~ na ~~~~
token: mw.user.tokens.get('editToken'),
summary: 'Wystawiono głosowanie na SDU' /* wstaw własny powód edycji */
})
.done( function (data) {
window.location.reload();
})
.fail( function(error) {
console.log(error);
});
}
//</nowiki></pre>