Anonymous user
MediaWiki:Gadget-friendlytalkback.js: Difference between revisions
Repo at d404881: Greatly expand style guidelines, enforce linting rules (#657)
imported>AzaToth m (v2.0-556-g0beacc0: use .utc() for timestamps and format them the sme way as the wiki does) |
imported>Amorymeltzer (Repo at d404881: Greatly expand style guidelines, enforce linting rules (#657)) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1:
// <nowiki>
(function($) {
Line 16:
Twinkle.talkback = function() {
if (!mw.config.get('wgRelevantUserName')) {
return;
}
Twinkle.addPortletLink(
};
Twinkle.talkback.callback = function(
if
return;
}
var Window = new Morebits.simpleWindow(
Window.setTitle(
Window.setScriptName(
Window.addFooterLink(
Window.addFooterLink(
var form = new Morebits.quickForm(
form.append({ type:
label: "\"You've got mail\"",
value: 'mail'
}
],
event: callback_change_target
});
form.append({
form.append({ type:
var result = form.render();
Window.setContent(
Window.display();
// We must init the
var evt = document.createEvent(
evt.initEvent(
result.tbtarget[0].dispatchEvent(
// Check whether the user has opted out from talkback
var query = {
action: 'query',
prop: 'extlinks',
titles: mw.config.get('wgPageName'),
elquery: 'userjs.invalid/noTalkback',
ellimit: '1'
};
var wpapi = new Morebits.wiki.api('Fetching talkback opt-out status', query, Twinkle.talkback.callback.optoutStatus);
wpapi.post();
};
Line 105 ⟶ 103:
if ($el.length) {
Twinkle.talkback.optout =
var url = $el.text();
if (url.indexOf(
Twinkle.talkback.optout +=
} else {
Twinkle.talkback.optout +=
}
} else {
Line 116 ⟶ 114:
}
var $status = $(
if ($status.length) {
$status.append(Twinkle.talkback.optout);
Line 122 ⟶ 120:
};
var prev_page =
var prev_section =
var prev_message =
var callback_change_target = function(
var value = e.target.values;
var root = e.target.form;
var old_area = Morebits.quickForm.getElements(root,
if (root.section) {
prev_section = root.section.value;
}
if (root.message) {
prev_message = root.message.value;
}
if (root.page) {
prev_page = root.page.value;
}
var work_area = new Morebits.quickForm.element({
switch (
case
/* falls through */
default:
work_area.append({
type:
label:
style:
id:
});
work_area.append({
break;
case
work_area.append({
type:
label:
style:
id:
});
work_area.append({
work_area.append({
break;
case
var noticeboard = work_area.append({
if (e.target.value === 'afchd') {
Morebits.quickForm.overrideElementLabel(e.target.form.section, 'Title of draft (excluding the prefix): ');
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, false);
} else {
Morebits.quickForm.resetElementLabel(e.target.form.section);
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, true);
}
}
});
noticeboard.append({
noticeboard.append({
});
noticeboard.append({
// let's keep AN and its cousins at the top
noticeboard.append({
noticeboard.append({
noticeboard.append({
noticeboard.append({
noticeboard.append({
noticeboard.append({
type: 'option',
label: 'WP:THQ (Teahouse question forum)',
value: 'th'
});
work_area.append({
break;
case
work_area.append({
type:
label:
style:
id:
});
work_area.append({
work_area.append({
break;
case
work_area.append({
break;
case 'see':
work_area.append({
type: 'input',
name: 'page',
label: 'Full page name',
tooltip: "The full page name of where the discussion is being held. For example: 'Wikipedia talk:Twinkle'.",
value: prev_page
});
work_area.append({
type: 'input',
name: 'section',
label: 'Linked section (optional)',
tooltip: "The section heading where the discussion is being held. For example: 'Merge proposal'.",
value: prev_section
});
break;
}
if (value !==
work_area.append({ type:
}
work_area = work_area.render();
root.replaceChild(
if (root.message) {
root.message.value = prev_message;
Line 288 ⟶ 316:
if (Twinkle.talkback.optout) {
$(
}
};
var callback_evaluate = function(
var tbtarget = e.target.getChecked(
var page = null;
var section = e.target.section.value;
var fullUserTalkPageName = mw.config.get(
if
page = e.target.page.value;
if (
if (
alert(
return;
}
} else {
if (
alert(
return;
}
}
} else if (tbtarget ===
page = e.target.noticeboard.value;
}
Line 322 ⟶ 350:
}
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
Morebits.wiki.actionCompleted.redirect = fullUserTalkPageName;
Morebits.wiki.actionCompleted.notice =
var talkpage = new Morebits.wiki.page(fullUserTalkPageName,
var tbPageName =
var text;
if (
switch (page) {
case
text =
talkpage.setEditSummary('You have replies at the [[Wikipedia:AFCHD|Articles for Creation Help Desk]]' + Twinkle.getPref('summaryAd'));
break;
case
text =
talkpage.setEditSummary("Notice of discussion at [[Wikipedia:Administrators' noticeboard]]" + Twinkle.getPref('summaryAd'));
break;
case
text =
break;
case
text =
text += '{{subst:ANI-notice|thread=' + section + "|noticeboard=Wikipedia:Administrators' noticeboard/Incidents}} ~~~~";
talkpage.setEditSummary("Notice of discussion at [[Wikipedia:Administrators' noticeboard/Incidents]]" + Twinkle.getPref('summaryAd'));
break;
case
text =
talkpage.setEditSummary(
break;
case
text =
talkpage.setEditSummary('Notice of discussion at [[Wikipedia:Dispute resolution noticeboard]]' + Twinkle.getPref('summaryAd'));
break;
case
text =
text += '{{helpdeskreply|1=' + section + '|ts=~~~~~}}';
talkpage.setEditSummary('You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]' + Twinkle.getPref('summaryAd'));
break;
case
text =
talkpage.setEditSummary(
break;
case 'th':
text = "\n\n== Teahouse talkback: you've got messages! ==\n{{WP:Teahouse/Teahouse talkback|WP:Teahouse/Questions|" + section + '|ts=~~~~}}';
talkpage.setEditSummary('You have replies at the [[Wikipedia:Teahouse/Questions|Teahouse question board]]' + Twinkle.getPref('summaryAd'));
break;
default:
throw
}
} else if (
text =
text += section +
if (
text +=
} else if (
text +=
}
talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref(
} else if (tbtarget === 'see') {
text = '\n\n{{subst:Please see|location=' + tbPageName;
if (section) {
text += '#' + section;
}
text += '|more=' + message.trim() + '}}';
talkpage.setEditSummary('Please check the discussion at [[:' + tbPageName +
(section ? '#' + section : '') + ']]' + Twinkle.getPref('summaryAd'));
} else { // tbtarget one of mytalk, usertalk, other
// clean talkback heading: strip section header markers that were erroneously suggested in the documentation
text = '\n\n==' + Twinkle.getFriendlyPref('talkbackHeading').replace(/^\s*=+\s*(.*?)\s*=+$\s*/, '$1') + '==\n{{talkback|';
text += tbPageName;
if (
text +=
}
text +=
if (
text +=
} else if (
text +=
}
var editSummary = 'Talkback ([[:';
if (tbtarget !== 'other' && !/^\s*user talk:/i.test(tbPageName)) {
editSummary += 'User talk:';
}
editSummary += tbPageName + (section ? '#' + section : '') + ']])';
talkpage.setEditSummary(editSummary + Twinkle.getPref('summaryAd'));
}
talkpage.setAppendText(
talkpage.setCreateOption(
talkpage.setMinorEdit(Twinkle.getFriendlyPref(
talkpage.setFollowRedirect(
talkpage.append();
};
Line 416 ⟶ 461:
// </nowiki>
|