User:BZPN/Email.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
mw.loader.using(['mediawiki.api', 'jquery'], function () { |
mw.loader.using(['mediawiki.api', 'jquery'], function () { |
||
$(function () { |
$(function () { |
||
// Sprawdź, czy jesteśmy na stronie EmailUser |
|||
if (mw.config.get('wgCanonicalSpecialPageName') !== 'EmailUser') return; |
if (mw.config.get('wgCanonicalSpecialPageName') !== 'EmailUser ') return; |
||
// |
// Użyj niezawodnego selektora dla pola "Wyślij mi kopię mojej wiadomości" |
||
var $copyField = $(' |
var $copyField = $('input[name="wpCCMe"]').closest('.mw-htmlform-field-HTMLCheckField'); |
||
if (!$copyField.length) |
if (!$copyField.length) { |
||
⚫ | |||
⚫ | |||
⚫ | |||
// Stwórz nowe pole checkbox |
// Stwórz nowe pole checkbox |
||
var $notifyCheckbox = $( |
var $notifyCheckbox = $( |
||
'<div class="mw-htmlform-field-HTMLCheckField">' + |
'<div class="mw-htmlform-field-HTMLCheckField">' + |
||
Line 25: | Line 29: | ||
); |
); |
||
// Dodaj checkbox do formularza |
|||
$copyField.after($notifyCheckbox); |
$copyField.after($notifyCheckbox); |
||
// Obsługa |
// Obsługa zdarzenia submit |
||
$('form.mw-htmlform').on('submit', function (e) { |
$('form.mw-htmlform').on('submit', function (e) { |
||
e.preventDefault(); // Zatrzymaj domyślne działanie formularza |
|||
⚫ | |||
e.preventDefault(); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
new mw.Api().postWithToken('csrf', { |
|||
⚫ | |||
⚫ | |||
title: talkPage, |
|||
⚫ | |||
⚫ | |||
⚫ | |||
// Wykonaj operację API |
|||
new mw.Api().postWithToken('csrf', { |
|||
⚫ | |||
⚫ | |||
title: talkPage, |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
format: 'json' |
|||
⚫ | |||
}).done(function() { |
|||
⚫ | |||
⚫ | |||
}).fail(function(err) { |
|||
console.error('Error posting notification:', err); |
|||
⚫ | |||
⚫ | |||
}); |
|||
}); |
}); |
||
}); |
}); |