User:BZPN/Zgłaszarka.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary |
No edit summary |
||
| (10 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
mw.loader.using(['oojs-ui', 'mediawiki.util']).done(function () { |
mw.loader.using(['oojs-ui', 'mediawiki.util']).done(function () { |
||
function addReportButton() { |
function addReportButton() { |
||
// |
// Znajdź każdą edycję |
||
$('.mw-changeslist |
$('.mw-changeslist-diff').each(function () { |
||
var |
var diffUrl = $(this).attr('href'); |
||
var |
var diffNumber = diffUrl.match(/diff=(\d+)/)[1]; |
||
var diffNumber = diffHref.match(/oldid=(\d+)/)[1]; // Wyciągnięcie numeru edycji |
|||
// |
// Dodaj przycisk, jeśli go jeszcze nie ma |
||
if ($ |
if ($(this).siblings('.pt-report').length === 0) { |
||
| ⚫ | |||
var $button = $('<a>') |
var $button = $('<a>') |
||
.attr('href', '#') |
.attr('href', '#') |
||
| Line 16: | Line 14: | ||
.css({ 'margin-left': '10px', 'cursor': 'pointer', 'color': 'red' }); |
.css({ 'margin-left': '10px', 'cursor': 'pointer', 'color': 'red' }); |
||
$(this).after($button); |
|||
$diffLink.after($button); |
|||
// Obsługa kliknięcia w przycisk |
// Obsługa kliknięcia w przycisk |
||
| Line 23: | Line 20: | ||
e.preventDefault(); |
e.preventDefault(); |
||
// |
// Popup do wpisania uzasadnienia |
||
var reason = prompt('Podaj uzasadnienie zgłoszenia:'); |
var reason = prompt('Podaj uzasadnienie zgłoszenia:'); |
||
if (!reason || reason.trim() === '') { |
if (!reason || reason.trim() === '') { |
||
| Line 31: | Line 28: | ||
// Potwierdzenie zgłoszenia |
// Potwierdzenie zgłoszenia |
||
var |
var doThis = confirm('Czy na pewno chcesz zgłosić edycję?'); |
||
if ( |
if (doThis) { |
||
var api = new mw.Api(); |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
title: 'User:BZPN/Wikipedia:Prośby do administratorów', |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
} |
} |
||
// API do edycji strony z prośbami |
|||
var api = new mw.Api(); |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
}); |
|||
}); |
}); |
||
} |
} |
||
| Line 57: | Line 52: | ||
} |
} |
||
// Uruchomienie funkcji po załadowaniu strony |
|||
$(document).ready(function () { |
$(document).ready(function () { |
||
addReportButton(); |
addReportButton(); |
||