மீடியாவிக்கி:Gadget-friendlytalkback.js: திருத்தங்களுக்கு இடையிலான வேறுபாடு

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
Fixed minor issue caused by previous security fix, phab:T241950#5794909
Shanmugamp7 (பேச்சு | பங்களிப்புகள்)
update from enwiki
 
வரிசை 1: வரிசை 1:
//<nowiki>
// <nowiki>




(function($){
(function($) {




வரிசை 10: வரிசை 10:
****************************************
****************************************
* Mode of invocation: Tab ("TB")
* Mode of invocation: Tab ("TB")
* Active on: Existing user talk pages
* Active on: Any page with relevant user name (userspace, contribs, etc.)
* Config directives in: FriendlyConfig
* Config directives in: FriendlyConfig
*/
*/
வரிசை 16: வரிசை 16:
Twinkle.talkback = function() {
Twinkle.talkback = function() {


if ( !mw.config.get('wgRelevantUserName') ) {
if (!mw.config.get('wgRelevantUserName')) {
return;
return;
}
}


Twinkle.addPortletLink( Twinkle.talkback.callback, "பேச்சு", "friendly-talkback", "இலகுவான பேச்சு" );
Twinkle.addPortletLink(Twinkle.talkback.callback, 'TB', 'friendly-talkback', 'Easy talkback');
};
};


Twinkle.talkback.callback = function( ) {
Twinkle.talkback.callback = function() {
if( mw.config.get('wgRelevantUserName') === mw.config.get("wgUserName") && !confirm("உங்களுடனேயே நீங்கள் கதைக்கப் போகின்றீர்களா?") ){
if (mw.config.get('wgRelevantUserName') === mw.config.get('wgUserName') && !confirm("Is it really so bad that you're talking back to yourself?")) {
return;
return;
}
}


var Window = new Morebits.simpleWindow( 600, 350 );
var Window = new Morebits.simpleWindow(600, 350);
Window.setTitle("பேச்சு");
Window.setTitle('Talkback');
Window.setScriptName("மின்னல்");
Window.setScriptName('Twinkle');
Window.addFooterLink( "{{பேச்சு}} பற்றி", "வார்ப்புரு:Talkback" );
Window.addFooterLink('Talkback prefs', 'WP:TW/PREF#talkback');
Window.addFooterLink( "மின்னல் உதவி", "WP:TW/DOC#talkback" );
Window.addFooterLink('Twinkle help', 'WP:TW/DOC#talkback');
Window.addFooterLink('Give feedback', 'WT:TW');


var form = new Morebits.quickForm( callback_evaluate );
var form = new Morebits.quickForm(Twinkle.talkback.evaluate);


form.append({ type: "radio", name: "tbtarget",
form.append({ type: 'radio', name: 'tbtarget',
list: [
list: [
{
{
label: 'Talkback: my talk page',
label: "பேச்சு: என் பேச்சுப் பக்கம்",
value: "mytalk",
value: 'mytalk',
checked: "true"
checked: 'true'
},
},
{
{
label: 'Talkback: other user talk page',
label: "பேச்சு: வேறு பயனரின் பேச்சுப் பக்கம்",
value: "usertalk"
value: 'usertalk'
},
},
{
{
label: "பேச்சு: வேறு பக்கம்",
label: 'Talkback: other page',
value: "other"
value: 'other'
},
},
{
{
label: '"Please see"',
label: "\"அருள்கூர்ந்து காண்க\"",
value: "see"
value: 'see'
},
},
{
{
label: 'Noticeboard notification',
label: "அறிவிப்புப்பலகை அறிவிப்பு",
value: "notice"
value: 'notice'
},
},
{
{
label: "\"You've got mail\"",
label: "\"உங்களுக்கு மின்னஞ்சல் கிடைத்துள்ளது\"",
value: "mail"
value: 'mail'
}
}
],
],
event: callback_change_target
event: Twinkle.talkback.changeTarget
});
});


form.append({
form.append({
type: "field",
type: 'field',
label: "பணிப் பரப்பு",
label: 'Work area',
name: "work_area"
name: 'work_area'
});
});


var previewlink = document.createElement('a');
form.append({ type: "submit" });
$(previewlink).click(function() {
Twinkle.talkback.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
previewlink.textContent = 'Preview';
form.append({ type: 'div', id: 'talkbackpreview', label: [ previewlink ] });
form.append({ type: 'div', id: 'friendlytalkback-previewbox', style: 'display: none' });

form.append({ type: 'submit' });


var result = form.render();
var result = form.render();
Window.setContent( result );
Window.setContent(result);
Window.display();
Window.display();
result.previewer = new Morebits.wiki.preview($(result).find('div#friendlytalkback-previewbox').last()[0]);


// We must init the
// We must init the
var evt = document.createEvent("Event");
var evt = document.createEvent('Event');
evt.initEvent( "change", true, true );
evt.initEvent('change', true, true);
result.tbtarget[0].dispatchEvent( evt );
result.tbtarget[0].dispatchEvent(evt);


// Check whether the user has opted out from talkback
// Check whether the user has opted out from talkback
var query = {
// TODO: wgCategories is only set on action=view (bug 45033)
action: 'query',
var wgcat = mw.config.get("wgCategories");
prop: 'extlinks',
if (wgcat.length && wgcat.indexOf("Users who do not wish to receive talkbacks") === -1) {
titles: 'User talk:' + mw.config.get('wgRelevantUserName'),
Twinkle.talkback.optout = false;
elquery: 'userjs.invalid/noTalkback',
} else {
ellimit: '1',
var query = {
action: 'query',
format: 'json'
};
prop: 'extlinks',
var wpapi = new Morebits.wiki.api('Fetching talkback opt-out status', query, Twinkle.talkback.callback.optoutStatus);
titles: mw.config.get('wgPageName'),
wpapi.post();
elquery: 'userjs.invalid/noTalkback',
ellimit: '1'
};
var wpapi = new Morebits.wiki.api("Fetching talkback opt-out status", query, Twinkle.talkback.callback.optoutStatus);
wpapi.post();
}
};
};


Twinkle.talkback.optout = null;
Twinkle.talkback.optout = '';


Twinkle.talkback.callback.optoutStatus = function(apiobj) {
Twinkle.talkback.callback.optoutStatus = function(apiobj) {
var xml = apiobj.getXML();
var el = apiobj.getResponse().query.pages[0].extlinks;
var $el = $(xml).find('el');
if (el && el.length) {
Twinkle.talkback.optout = mw.config.get('wgRelevantUserName') + ' prefers not to receive talkbacks';

var url = el[0].url;
if ($el.length) {
var reason = mw.util.getParamValue('reason', url);
Twinkle.talkback.optout = mw.config.get('wgRelevantUserName') + " பேச்சு வார்ப்புருக்களைப் பெற விரும்பவில்லை";
Twinkle.talkback.optout += reason ? ': ' + reason : '.';
var url = $el.text();
if (url.indexOf("reason=") > -1) {
Twinkle.talkback.optout += ": " + decodeURIComponent(url.substring(url.indexOf("reason=") + 7)) + ".";
} else {
Twinkle.talkback.optout += ".";
}
} else {
Twinkle.talkback.optout = false;
}

var $status = $("#twinkle-talkback-optout-message");
if ($status.length && Twinkle.talkback.optout) {
$status.text(Twinkle.talkback.optout);
}
}
$('#twinkle-talkback-optout-message').text(Twinkle.talkback.optout);
};
};


var prev_page = "";
var prev_page = '';
var prev_section = "";
var prev_section = '';
var prev_message = "";
var prev_message = '';


var callback_change_target = function( e ) {
Twinkle.talkback.changeTarget = function(e) {
var value = e.target.values;
var value = e.target.values;
var root = e.target.form;
var root = e.target.form;
var old_area = Morebits.quickForm.getElements(root, "work_area")[0];
var old_area = Morebits.quickForm.getElements(root, 'work_area')[0];


if(root.section) {
if (root.section) {
prev_section = root.section.value;
prev_section = root.section.value;
}
}
if(root.message) {
if (root.message) {
prev_message = root.message.value;
prev_message = root.message.value;
}
}
if(root.page) {
if (root.page) {
prev_page = root.page.value;
prev_page = root.page.value;
}
}


var work_area = new Morebits.quickForm.element({
var work_area = new Morebits.quickForm.element({
type: "field",
type: 'field',
label: "பேச்சுத் தகவல்",
label: 'Talkback information',
name: "work_area"
name: 'work_area'
});
});


root.previewer.closePreview();
switch( value ) {

case "mytalk":
switch (value) {
case 'mytalk':
/* falls through */
/* falls through */
default:
default:
work_area.append({
work_area.append({
type: "div",
type: 'div',
label: "",
label: '',
style: "color: red",
style: 'color: red',
id: "twinkle-talkback-optout-message"
id: 'twinkle-talkback-optout-message'
});
});
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label: 'Linked section (optional)',
label:"இணைத்த பகுதி (விருப்பத்தேர்வுக்குரியது)",
tooltip: 'The section heading on your talk page where you left a message. Leave empty for no section to be linked.',
tooltip:"உங்கள் பேச்சுப் பக்கத்தில் நீங்கள் விட்டுச்சென்ற செய்தி அமைந்துள்ள பகுதியின் தலைப்பை உள்ளிடவும். எந்தவொரு பகுதியையும் இணைக்காதிருக்க எதனையும் உள்ளிடவேண்டாம்.",
value: prev_section
value: prev_section
});
});
break;
break;

case "usertalk":
case 'usertalk':
work_area.append({
work_area.append({
type: "div",
type: 'div',
label: "",
label: '',
style: "color: red",
style: 'color: red',
id: "twinkle-talkback-optout-message"
id: 'twinkle-talkback-optout-message'
});
});
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"page",
name: 'page',
label:"பயனர்",
label: 'User (required)',
tooltip: 'The username of the user on whose talk page you left a message. Required.',
tooltip:"நீங்கள் எப்பயனருடைய பேச்சுப் பக்கத்தில் செய்தியை விட்டுச்சென்றீர்களோ, அவரின் பயனர் பெயர்.",
value: prev_page
value: prev_page,
});
required: true
});


work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label: 'Linked section (optional)',
label:"இணைத்த பகுதி (விருப்பத்தேர்வுக்குரியது)",
tooltip: 'The section heading on the page where you left a message. Leave empty for no section to be linked.',
tooltip:"பக்கத்தில் நீங்கள் விட்டுச்சென்ற செய்தி அமைந்துள்ள பகுதியின் தலைப்பை உள்ளிடவும். எந்தவொரு பகுதியையும் இணைக்காதிருக்க எதனையும் உள்ளிடவேண்டாம்.",
value: prev_section
value: prev_section
});
});
break;
break;

case "notice":
case 'notice':
var noticeboard = work_area.append({
var noticeboard = work_area.append({
type: "select",
type: 'select',
name: "noticeboard",
name: 'noticeboard',
label: "அறிவிப்புப்பலகை:",
label: 'Noticeboard:',
event: function(e) {
event: function(e) {
if (e.target.value === "afchd") {
if (e.target.value === 'afchd') {
Morebits.quickForm.overrideElementLabel(e.target.form.section, "Title of draft (excluding the prefix): ");
Morebits.quickForm.overrideElementLabel(e.target.form.section, 'Title of draft (excluding the prefix): ');
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, false);
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, false);
} else {
} else {
Morebits.quickForm.resetElementLabel(e.target.form.section);
Morebits.quickForm.resetElementLabel(e.target.form.section);
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, true);
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, true);
}
}
}
}
});

$.each(Twinkle.talkback.noticeboards, function(value, data) {
noticeboard.append({
type: 'option',
label: data.label,
value: value,
selected: !!data.defaultSelected
});
});
});
noticeboard.append({

type: "option",
label: "நிருவாகிகளுக்கான அறிவிப்புப்பலகை",
value: "an"
});
// let's keep AN and its cousins at the top
noticeboard.append({
type: "option",
label: "WP:HD (ஒத்தாசைப் பக்கம்)",
value: "hd"
});
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label:"இணைத்த இழை",
label: 'Linked thread',
tooltip: 'The heading of the relevant thread on the noticeboard page.',
tooltip:"அறிவிப்புப்பலகைப் பக்கத்திலுள்ள தொடர்புடைய இழையின் தலைப்பு",
value: prev_section
value: prev_section
});
});
break;
break;

case "other":
case 'other':
work_area.append({
work_area.append({
type: "div",
type: 'div',
label: "",
label: '',
style: "color: red",
style: 'color: red',
id: "twinkle-talkback-optout-message"
id: 'twinkle-talkback-optout-message'
});
});
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"page",
name: 'page',
label: 'Full page name (required)',
label:"பக்கத்தின் முழுப்பெயர்",
tooltip: "The full page name where you left the message. For example: 'Wikipedia talk:Twinkle'. Required.",
tooltip:"நீங்கள் செய்தியை விட்டுச்சென்ற பக்கத்தின் முழுப்பெயர். எ-டு: 'விக்கிப்பீடியா பேச்சு:மின்னல்'",
value: prev_page
value: prev_page,
});
required: true
});


work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label: 'Linked section (optional)',
label:"இணைத்த பகுதி (விருப்பத்தேர்வுக்குரியது)",
tooltip: 'The section heading on the page where you left a message. Leave empty for no section to be linked.',
tooltip:"பக்கத்தில் நீங்கள் விட்டுச்சென்ற செய்தி அமைந்துள்ள பகுதியின் தலைப்பை உள்ளிடவும். எந்தவொரு பகுதியையும் இணைக்காதிருக்க எதனையும் உள்ளிடவேண்டாம்.",
value: prev_section
value: prev_section
});
});
break;
break;

case "mail":
case 'mail':
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label: 'Subject of email (optional)',
label:"மின்னஞ்சலின் பொருள் (விருப்பத்தேர்வுக்குரியது)",
tooltip: 'The subject line of the email you sent.'
tooltip:"நீங்கள் அனுப்பிய மின்னஞ்சலின் பொருள்"
});
});
break;
break;

case "see":
case 'see':
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"page",
name: 'page',
label: 'Full page name (required)',
label:"பக்கத்தின் முழுப்பெயர்",
tooltip: "The full page name of where the discussion is being held. For example: 'Wikipedia talk:Twinkle'. Required.",
tooltip:"உரையாடல் இடம்பெறும் பக்கத்தின் முழுப்பெயர். எ-டு: 'விக்கிப்பீடியா பேச்சு:மின்னல்'",
value: prev_page
value: prev_page,
});
required: true
});
work_area.append({
work_area.append({
type:"input",
type: 'input',
name:"section",
name: 'section',
label: 'Linked section (optional)',
label:"இணைத்த பகுதி (விருப்பத்தேர்வுக்குரியது)",
tooltip: "The section heading where the discussion is being held. For example: 'Merge proposal'.",
tooltip:"உரையாடல் இடம்பெறும் பகுதியின் தலைப்பு. எ-டு: 'ஒன்றிணைப்பு வேண்டுகோள்'",
value: prev_section
value: prev_section
});
});
break;
break;
}
}


if (value !== "notice") {
if (value !== 'notice') {
work_area.append({ type: 'textarea', label: 'Additional message (optional):', name: 'message', tooltip: 'An additional message that you would like to leave below the talkback template. Your signature will be added to the end of the message if you leave one.' });
work_area.append({ type:"textarea", label:"மேலதிகச் செய்தி (விருப்பத்தேர்வுக்குரியது):", name:"message", tooltip:"பேச்சு வார்ப்புருவின் கீழே நீங்கள் விட்டுச்செல்ல விரும்பும் மேலதிகச் செய்தியை உள்ளிடவும். ஒரு மேலதிகச் செய்தியை விட்டுச்செல்வீர்களாயின், உங்கள் கையொப்பமும் அதன் இறுதியில் சேர்க்கப்படும்." });
}
}


work_area = work_area.render();
work_area = work_area.render();
root.replaceChild( work_area, old_area );
root.replaceChild(work_area, old_area);
if (root.message) {
if (root.message) {
root.message.value = prev_message;
root.message.value = prev_message;
}
}


if (Twinkle.talkback.optout) {
$('#twinkle-talkback-optout-message').text(Twinkle.talkback.optout);
};
$("#twinkle-talkback-optout-message").text(Twinkle.talkback.optout);

Twinkle.talkback.noticeboards = {
an: {
label: "WP:AN (Administrators' noticeboard)",
text: '{{subst:AN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Administrators\' noticeboard]]'
},
an3: {
label: "WP:AN3 (Administrators' noticeboard/Edit warring)",
text: '{{subst:An3-notice|$SECTION}} ~~~~',
editSummary: "Notice of discussion at [[Wikipedia:Administrators' noticeboard/Edit warring]]"
},
ani: {
label: "WP:ANI (Administrators' noticeboard/Incidents)",
text: "== Notice of Administrators' noticeboard/Incidents discussion ==\n" +
'{{subst:ANI-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Administrators\' noticeboard/Incidents]]',
defaultSelected: true
},
// let's keep AN and its cousins at the top
afchd: {
label: 'WP:AFCHD (Articles for creation/Help desk)',
text: '{{subst:AFCHD/u|$SECTION}} ~~~~',
editSummary: 'You have replies at the [[Wikipedia:AFCHD|Articles for Creation Help Desk]]'
},
blpn: {
label: 'WP:BLPN (Biographies of living persons noticeboard)',
text: '{{subst:BLPN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Biographies of living persons/Noticeboard]]'
},
coin: {
label: 'WP:COIN (Conflict of interest noticeboard)',
text: '{{subst:Coin-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Conflict of interest/Noticeboard]]'
},
drn: {
label: 'WP:DRN (Dispute resolution noticeboard)',
text: '{{subst:DRN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Dispute resolution noticeboard]]'
},
effp: {
label: 'WP:EFFP/R (Edit filter false positive report)',
text: '{{EFFPReply|1=$SECTION|2=~~~~}}',
editSummary: 'You have replies to your [[Wikipedia:Edit filter/False positives/Reports|edit filter false positive report]]'
},
eln: {
label: 'WP:ELN (External links noticeboard)',
text: '{{subst:ELN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:External links/Noticeboard]]'
},
ftn: {
label: 'WP:FTN (Fringe theories noticeboard)',
text: '{{subst:Ftn-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Fringe theories/Noticeboard]]'
},
hd: {
label: 'WP:HD (Help desk)',
text: '== Your question at the Help desk ==\n' + '{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
editSummary: 'You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]'
},
norn: {
label: 'WP:NORN (Reliable sources noticeboard)',
text: '{{subst:Norn-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Reliable sources/Noticeboard]]'
},
npovn: {
label: 'WP:NPOVN (Neutral point of view noticeboard)',
text: '{{subst:NPOVN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Neutral point of view/Noticeboard]]'
},
rsn: {
label: 'WP:RSN (Reliable sources noticeboard)',
text: '{{subst:RSN-notice|thread=$SECTION}} ~~~~',
editSummary: 'Notice of discussion at [[Wikipedia:Reliable sources/Noticeboard]]'
},
th: {
label: 'WP:THQ (Teahouse question forum)',
text: "== Teahouse talkback: you've got messages! ==\n{{WP:Teahouse/Teahouse talkback|WP:Teahouse/Questions|$SECTION|ts=~~~~}}",
editSummary: 'You have replies at the [[Wikipedia:Teahouse/Questions|Teahouse question board]]'
},
otrs: {
label: 'WP:OTRS/N (OTRS noticeboard)',
text: '{{OTRSreply|1=$SECTION|2=~~~~}}',
editSummary: 'You have replies at the [[Wikipedia:OTRS noticeboard|OTRS noticeboard]]'
}
}
};
};


var callback_evaluate = function( e ) {
Twinkle.talkback.evaluate = function(e) {
var input = Morebits.quickForm.getInputData(e.target);


var fullUserTalkPageName = new mw.Title(mw.config.get('wgRelevantUserName'), 3).toText();
var tbtarget = e.target.getChecked( "tbtarget" )[0];
var talkpage = new Morebits.wiki.page(fullUserTalkPageName, 'Adding talkback');
var page = null;
var section = e.target.section.value;
var fullUserTalkPageName = mw.config.get("wgFormattedNamespaces")[ mw.config.get("wgNamespaceIds").user_talk ] + ":" + mw.config.get('wgRelevantUserName');


Morebits.simpleWindow.setButtonsEnabled(false);
if( tbtarget === "usertalk" || tbtarget === "other" || tbtarget === "see" ) {
Morebits.status.init(e.target);
page = e.target.page.value;


Morebits.wiki.actionCompleted.redirect = fullUserTalkPageName;
if( tbtarget === "usertalk" ) {
Morebits.wiki.actionCompleted.notice = 'Talkback complete; reloading talk page in a few seconds';
if( !page ) {

alert("நீங்கள் எப்பயனருடைய பேச்சுப் பக்கத்தில் செய்தியை விட்டுச்சென்றீர்களோ, அவரின் பயனர்பெயரைக் கட்டாயம் குறிப்பிடவேண்டும்.");
// Not used for notice or mail
return;
input.page = input.page || mw.config.get('wgUserName');

switch (input.tbtarget) {
case 'notice':
talkpage.setEditSummary(Twinkle.talkback.noticeboards[input.noticeboard].editSummary);
break;
case 'mail':
talkpage.setEditSummary("Notification: You've got mail");
break;
case 'see':
talkpage.setEditSummary('Please check the discussion at [[:' + input.page +
(input.section ? '#' + input.section : '') + ']]');
break;
default: // tbtarget one of mytalk, usertalk, other
var editSummary = 'Talkback ([[:';
if (input.tbtarget !== 'other' && !new RegExp('^\\s*' + Morebits.namespaceRegex(3) + ':', 'i').test(input.page)) {
editSummary += 'User talk:';
}
}
talkpage.setEditSummary(editSummary + input.page + (input.section ? '#' + input.section : '') + ']])');
} else {
if( !page ) {
alert("உங்கள் செய்தி ஒரு பயனர் பேச்சுப் பக்கத்தில் அமைந்திராவிடின், பக்கத்தின் முழுப்பெயரை நீங்கள் கட்டாயம் குறிப்பிடவேண்டும்.");
return;
}
}
} else if (tbtarget === "notice") {
page = e.target.noticeboard.value;
}
}


talkpage.setAppendText('\n\n' + Twinkle.talkback.getNoticeWikitext(input));
var message;
talkpage.setChangeTags(Twinkle.changeTags);
if (e.target.message) {
talkpage.setCreateOption('recreate');
message = e.target.message.value;
talkpage.setMinorEdit(Twinkle.getPref('markTalkbackAsMinor'));
}
talkpage.setFollowRedirect(true);
talkpage.append();
};


Twinkle.talkback.preview = function(form) {
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( e.target );
var input = Morebits.quickForm.getInputData(form);


if (input.tbtarget !== 'notice') {
Morebits.wiki.actionCompleted.redirect = fullUserTalkPageName;
// usertalk, other, see
Morebits.wiki.actionCompleted.notice = "பேச்சு நிறைவு; ஒருசில நொடிகளில் பக்கம் மறுநினைவேற்றப்படும்.";
input.page = input.page || mw.config.get('wgUserName');
}


var noticetext = Twinkle.talkback.getNoticeWikitext(input);
var talkpage = new Morebits.wiki.page(fullUserTalkPageName, "பேச்சுச் சேர்க்கப்படுகின்றது.");
form.previewer.beginRender(noticetext, 'User_talk:' + mw.config.get('wgRelevantUserName')); // Force wikitext/correct username
var tbPageName = (tbtarget === "mytalk") ? mw.config.get("wgUserName") : page;
};


Twinkle.talkback.getNoticeWikitext = function(input) {
var text;
var text;
if ( tbtarget === "notice" ) {
switch (page) {
case "an":
text = "\n\n== " + Twinkle.getFriendlyPref("adminNoticeHeading") + " ==\n";
text += "{{subst:ANI-notice|thread=" + section + "|noticeboard=விக்கிப்பீடியா:நிருவாகிகளுக்கான அறிவிப்புப்பலகை}} ~~~~";
talkpage.setEditSummary( "[[விக்கிப்பீடியா:நிருவாகிகளுக்கான அறிவிப்புப்பலகை]]யில் உரையாடலுக்கான அறிவிப்பு" + Twinkle.getPref("summaryAd") );
break
case "hd":
text = "\n\n== ஒத்தாசைப் பக்கத்தில் உங்கள் கேள்வி ==\n";
text += "{{helpdeskreply|1=" + section + "|ts=~~~~~}}";
talkpage.setEditSummary( "[[விக்கிப்பீடியா:ஒத்தாசைப் பக்கம்|ஒத்தாசைப் பக்கத்தில்]] உங்களுக்கு மறுமொழிகள் உள்ளன." + Twinkle.getPref("summaryAd") );
break;
default:
throw "Twinkle.talkback, function callback_evaluate: default case reached";
}


} else if ( tbtarget === "mail" ) {
switch (input.tbtarget) {
case 'notice':
text = "\n\n==" + Twinkle.getFriendlyPref("mailHeading") + "==\n{{you've got mail|subject=";
text = Morebits.string.safeReplace(Twinkle.talkback.noticeboards[input.noticeboard].text, '$SECTION', input.section);
text += section + "|ts=~~~~~}}";
break;
case 'mail':
text =
'==' + Twinkle.getPref('mailHeading') + '==\n' +
"{{You've got mail|subject=" + input.section + '|ts=~~~~~}}';


if( message ) {
if (input.message) {
text += "\n" + message.trim() + " ~~~~";
text += '\n' + input.message + ' ~~~~';
} else if( Twinkle.getFriendlyPref("insertTalkbackSignature") ) {
} else if (Twinkle.getPref('insertTalkbackSignature')) {
text += "\n~~~~";
text += '\n~~~~';
}
}
break;
case 'see':
text = '{{subst:Please see|location=' + input.page + (input.section ? '#' + input.section : '') + '|more=' + input.message + '}}';
break;
default: // tbtarget one of mytalk, usertalk, other
// clean talkback heading: strip section header markers that were erroneously suggested in the documentation
text =
'==' + Twinkle.getPref('talkbackHeading').replace(/^\s*=+\s*(.*?)\s*=+$\s*/, '$1') + '==\n' +
'{{talkback|' + input.page + (input.section ? '|' + input.section : '') + '|ts=~~~~~}}';


if (input.message) {
talkpage.setEditSummary("அறிவிப்பு: உங்களுக்கு மின்னஞ்சல் கிடைத்துள்ளது." + Twinkle.getPref("summaryAd"));
text += '\n' + input.message + ' ~~~~';

} else if ( tbtarget === "see" ) {
} else if (Twinkle.getPref('insertTalkbackSignature')) {
text += '\n~~~~';
text = "\n\n{{subst:Please see|location=" + tbPageName;
}
if (section) {
text += "#" + section;
}
text += "|more=" + message.trim() + "}}";
talkpage.setEditSummary("அருள்கூர்ந்து [[" + 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( section ) {
text += "|" + section;
}

text += "|ts=~~~~~}}";

if( message ) {
text += "\n" + message.trim() + " ~~~~";
} else if( Twinkle.getFriendlyPref("insertTalkbackSignature") ) {
text += "\n~~~~";
}

var editSummary = "பேச்சு ([[";
if (tbtarget !== "other" && !/^\s*user talk:/i.test(tbPageName)) {
editSummary += "பயனர் பேச்சு:";
}
editSummary += tbPageName + (section ? ("#" + section) : "") + "]])";
talkpage.setEditSummary(editSummary + Twinkle.getPref("summaryAd"));
}
}
return text;

talkpage.setAppendText( text );
talkpage.setCreateOption("recreate");
talkpage.setMinorEdit(Twinkle.getFriendlyPref("markTalkbackAsMinor"));
talkpage.setFollowRedirect( true );
talkpage.append();
};
};


Twinkle.addInitCallback(Twinkle.talkback, 'talkback');
})(jQuery);
})(jQuery);




//</nowiki>
// </nowiki>

10:11, 18 பெப்பிரவரி 2021 இல் கடைசித் திருத்தம்

// <nowiki>


(function($) {


/*
 ****************************************
 *** friendlytalkback.js: Talkback module
 ****************************************
 * Mode of invocation:     Tab ("TB")
 * Active on:              Any page with relevant user name (userspace, contribs, etc.)
 * Config directives in:   FriendlyConfig
 */

Twinkle.talkback = function() {

	if (!mw.config.get('wgRelevantUserName')) {
		return;
	}

	Twinkle.addPortletLink(Twinkle.talkback.callback, 'TB', 'friendly-talkback', 'Easy talkback');
};

Twinkle.talkback.callback = function() {
	if (mw.config.get('wgRelevantUserName') === mw.config.get('wgUserName') && !confirm("Is it really so bad that you're talking back to yourself?")) {
		return;
	}

	var Window = new Morebits.simpleWindow(600, 350);
	Window.setTitle('Talkback');
	Window.setScriptName('Twinkle');
	Window.addFooterLink('Talkback prefs', 'WP:TW/PREF#talkback');
	Window.addFooterLink('Twinkle help', 'WP:TW/DOC#talkback');
	Window.addFooterLink('Give feedback', 'WT:TW');

	var form = new Morebits.quickForm(Twinkle.talkback.evaluate);

	form.append({ type: 'radio', name: 'tbtarget',
		list: [
			{
				label: 'Talkback: my talk page',
				value: 'mytalk',
				checked: 'true'
			},
			{
				label: 'Talkback: other user talk page',
				value: 'usertalk'
			},
			{
				label: 'Talkback: other page',
				value: 'other'
			},
			{
				label: '"Please see"',
				value: 'see'
			},
			{
				label: 'Noticeboard notification',
				value: 'notice'
			},
			{
				label: "\"You've got mail\"",
				value: 'mail'
			}
		],
		event: Twinkle.talkback.changeTarget
	});

	form.append({
		type: 'field',
		label: 'Work area',
		name: 'work_area'
	});

	var previewlink = document.createElement('a');
	$(previewlink).click(function() {
		Twinkle.talkback.preview(result);  // |result| is defined below
	});
	previewlink.style.cursor = 'pointer';
	previewlink.textContent = 'Preview';
	form.append({ type: 'div', id: 'talkbackpreview', label: [ previewlink ] });
	form.append({ type: 'div', id: 'friendlytalkback-previewbox', style: 'display: none' });

	form.append({ type: 'submit' });

	var result = form.render();
	Window.setContent(result);
	Window.display();
	result.previewer = new Morebits.wiki.preview($(result).find('div#friendlytalkback-previewbox').last()[0]);

	// We must init the
	var evt = document.createEvent('Event');
	evt.initEvent('change', true, true);
	result.tbtarget[0].dispatchEvent(evt);

	// Check whether the user has opted out from talkback
	var query = {
		action: 'query',
		prop: 'extlinks',
		titles: 'User talk:' + mw.config.get('wgRelevantUserName'),
		elquery: 'userjs.invalid/noTalkback',
		ellimit: '1',
		format: 'json'
	};
	var wpapi = new Morebits.wiki.api('Fetching talkback opt-out status', query, Twinkle.talkback.callback.optoutStatus);
	wpapi.post();
};

Twinkle.talkback.optout = '';

Twinkle.talkback.callback.optoutStatus = function(apiobj) {
	var el = apiobj.getResponse().query.pages[0].extlinks;
	if (el && el.length) {
		Twinkle.talkback.optout = mw.config.get('wgRelevantUserName') + ' prefers not to receive talkbacks';
		var url = el[0].url;
		var reason = mw.util.getParamValue('reason', url);
		Twinkle.talkback.optout += reason ? ': ' + reason : '.';
	}
	$('#twinkle-talkback-optout-message').text(Twinkle.talkback.optout);
};

var prev_page = '';
var prev_section = '';
var prev_message = '';

Twinkle.talkback.changeTarget = function(e) {
	var value = e.target.values;
	var root = e.target.form;
	var old_area = Morebits.quickForm.getElements(root, 'work_area')[0];

	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({
		type: 'field',
		label: 'Talkback information',
		name: 'work_area'
	});

	root.previewer.closePreview();

	switch (value) {
		case 'mytalk':
			/* falls through */
		default:
			work_area.append({
				type: 'div',
				label: '',
				style: 'color: red',
				id: 'twinkle-talkback-optout-message'
			});
			work_area.append({
				type: 'input',
				name: 'section',
				label: 'Linked section (optional)',
				tooltip: 'The section heading on your talk page where you left a message. Leave empty for no section to be linked.',
				value: prev_section
			});
			break;

		case 'usertalk':
			work_area.append({
				type: 'div',
				label: '',
				style: 'color: red',
				id: 'twinkle-talkback-optout-message'
			});
			work_area.append({
				type: 'input',
				name: 'page',
				label: 'User (required)',
				tooltip: 'The username of the user on whose talk page you left a message. Required.',
				value: prev_page,
				required: true
			});

			work_area.append({
				type: 'input',
				name: 'section',
				label: 'Linked section (optional)',
				tooltip: 'The section heading on the page where you left a message. Leave empty for no section to be linked.',
				value: prev_section
			});
			break;

		case 'notice':
			var noticeboard = work_area.append({
				type: 'select',
				name: 'noticeboard',
				label: 'Noticeboard:',
				event: function(e) {
					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);
					}
				}
			});

			$.each(Twinkle.talkback.noticeboards, function(value, data) {
				noticeboard.append({
					type: 'option',
					label: data.label,
					value: value,
					selected: !!data.defaultSelected
				});
			});

			work_area.append({
				type: 'input',
				name: 'section',
				label: 'Linked thread',
				tooltip: 'The heading of the relevant thread on the noticeboard page.',
				value: prev_section
			});
			break;

		case 'other':
			work_area.append({
				type: 'div',
				label: '',
				style: 'color: red',
				id: 'twinkle-talkback-optout-message'
			});
			work_area.append({
				type: 'input',
				name: 'page',
				label: 'Full page name (required)',
				tooltip: "The full page name where you left the message. For example: 'Wikipedia talk:Twinkle'. Required.",
				value: prev_page,
				required: true
			});

			work_area.append({
				type: 'input',
				name: 'section',
				label: 'Linked section (optional)',
				tooltip: 'The section heading on the page where you left a message. Leave empty for no section to be linked.',
				value: prev_section
			});
			break;

		case 'mail':
			work_area.append({
				type: 'input',
				name: 'section',
				label: 'Subject of email (optional)',
				tooltip: 'The subject line of the email you sent.'
			});
			break;

		case 'see':
			work_area.append({
				type: 'input',
				name: 'page',
				label: 'Full page name (required)',
				tooltip: "The full page name of where the discussion is being held. For example: 'Wikipedia talk:Twinkle'. Required.",
				value: prev_page,
				required: true
			});
			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 !== 'notice') {
		work_area.append({ type: 'textarea', label: 'Additional message (optional):', name: 'message', tooltip: 'An additional message that you would like to leave below the talkback template. Your signature will be added to the end of the message if you leave one.' });
	}

	work_area = work_area.render();
	root.replaceChild(work_area, old_area);
	if (root.message) {
		root.message.value = prev_message;
	}

	$('#twinkle-talkback-optout-message').text(Twinkle.talkback.optout);
};

Twinkle.talkback.noticeboards = {
	an: {
		label: "WP:AN (Administrators' noticeboard)",
		text: '{{subst:AN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Administrators\' noticeboard]]'
	},
	an3: {
		label: "WP:AN3 (Administrators' noticeboard/Edit warring)",
		text: '{{subst:An3-notice|$SECTION}} ~~~~',
		editSummary: "Notice of discussion at [[Wikipedia:Administrators' noticeboard/Edit warring]]"
	},
	ani: {
		label: "WP:ANI (Administrators' noticeboard/Incidents)",
		text: "== Notice of Administrators' noticeboard/Incidents discussion ==\n" +
		'{{subst:ANI-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Administrators\' noticeboard/Incidents]]',
		defaultSelected: true
	},
	// let's keep AN and its cousins at the top
	afchd: {
		label: 'WP:AFCHD (Articles for creation/Help desk)',
		text: '{{subst:AFCHD/u|$SECTION}} ~~~~',
		editSummary: 'You have replies at the [[Wikipedia:AFCHD|Articles for Creation Help Desk]]'
	},
	blpn: {
		label: 'WP:BLPN (Biographies of living persons noticeboard)',
		text: '{{subst:BLPN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Biographies of living persons/Noticeboard]]'
	},
	coin: {
		label: 'WP:COIN (Conflict of interest noticeboard)',
		text: '{{subst:Coin-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Conflict of interest/Noticeboard]]'
	},
	drn: {
		label: 'WP:DRN (Dispute resolution noticeboard)',
		text: '{{subst:DRN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Dispute resolution noticeboard]]'
	},
	effp: {
		label: 'WP:EFFP/R (Edit filter false positive report)',
		text: '{{EFFPReply|1=$SECTION|2=~~~~}}',
		editSummary: 'You have replies to your [[Wikipedia:Edit filter/False positives/Reports|edit filter false positive report]]'
	},
	eln: {
		label: 'WP:ELN (External links noticeboard)',
		text: '{{subst:ELN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:External links/Noticeboard]]'
	},
	ftn: {
		label: 'WP:FTN (Fringe theories noticeboard)',
		text: '{{subst:Ftn-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Fringe theories/Noticeboard]]'
	},
	hd: {
		label: 'WP:HD (Help desk)',
		text: '== Your question at the Help desk ==\n' + '{{helpdeskreply|1=$SECTION|ts=~~~~~}}',
		editSummary: 'You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]'
	},
	norn: {
		label: 'WP:NORN (Reliable sources noticeboard)',
		text: '{{subst:Norn-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Reliable sources/Noticeboard]]'
	},
	npovn: {
		label: 'WP:NPOVN (Neutral point of view noticeboard)',
		text: '{{subst:NPOVN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Neutral point of view/Noticeboard]]'
	},
	rsn: {
		label: 'WP:RSN (Reliable sources noticeboard)',
		text: '{{subst:RSN-notice|thread=$SECTION}} ~~~~',
		editSummary: 'Notice of discussion at [[Wikipedia:Reliable sources/Noticeboard]]'
	},
	th: {
		label: 'WP:THQ (Teahouse question forum)',
		text: "== Teahouse talkback: you've got messages! ==\n{{WP:Teahouse/Teahouse talkback|WP:Teahouse/Questions|$SECTION|ts=~~~~}}",
		editSummary: 'You have replies at the [[Wikipedia:Teahouse/Questions|Teahouse question board]]'
	},
	otrs: {
		label: 'WP:OTRS/N (OTRS noticeboard)',
		text: '{{OTRSreply|1=$SECTION|2=~~~~}}',
		editSummary: 'You have replies at the [[Wikipedia:OTRS noticeboard|OTRS noticeboard]]'
	}
};

Twinkle.talkback.evaluate = function(e) {
	var input = Morebits.quickForm.getInputData(e.target);

	var fullUserTalkPageName = new mw.Title(mw.config.get('wgRelevantUserName'), 3).toText();
	var talkpage = new Morebits.wiki.page(fullUserTalkPageName, 'Adding talkback');

	Morebits.simpleWindow.setButtonsEnabled(false);
	Morebits.status.init(e.target);

	Morebits.wiki.actionCompleted.redirect = fullUserTalkPageName;
	Morebits.wiki.actionCompleted.notice = 'Talkback complete; reloading talk page in a few seconds';

	// Not used for notice or mail
	input.page = input.page || mw.config.get('wgUserName');

	switch (input.tbtarget) {
		case 'notice':
			talkpage.setEditSummary(Twinkle.talkback.noticeboards[input.noticeboard].editSummary);
			break;
		case 'mail':
			talkpage.setEditSummary("Notification: You've got mail");
			break;
		case 'see':
			talkpage.setEditSummary('Please check the discussion at [[:' + input.page +
			(input.section ? '#' + input.section : '') + ']]');
			break;
		default:  // tbtarget one of mytalk, usertalk, other
			var editSummary = 'Talkback ([[:';
			if (input.tbtarget !== 'other' && !new RegExp('^\\s*' + Morebits.namespaceRegex(3) + ':', 'i').test(input.page)) {
				editSummary += 'User talk:';
			}
			talkpage.setEditSummary(editSummary + input.page + (input.section ? '#' + input.section : '') + ']])');
	}

	talkpage.setAppendText('\n\n' + Twinkle.talkback.getNoticeWikitext(input));
	talkpage.setChangeTags(Twinkle.changeTags);
	talkpage.setCreateOption('recreate');
	talkpage.setMinorEdit(Twinkle.getPref('markTalkbackAsMinor'));
	talkpage.setFollowRedirect(true);
	talkpage.append();
};

Twinkle.talkback.preview = function(form) {
	var input = Morebits.quickForm.getInputData(form);

	if (input.tbtarget !== 'notice') {
		// usertalk, other, see
		input.page = input.page || mw.config.get('wgUserName');
	}

	var noticetext = Twinkle.talkback.getNoticeWikitext(input);
	form.previewer.beginRender(noticetext, 'User_talk:' + mw.config.get('wgRelevantUserName')); // Force wikitext/correct username
};

Twinkle.talkback.getNoticeWikitext = function(input) {
	var text;

	switch (input.tbtarget) {
		case 'notice':
			text = Morebits.string.safeReplace(Twinkle.talkback.noticeboards[input.noticeboard].text, '$SECTION', input.section);
			break;
		case 'mail':
			text =
				'==' + Twinkle.getPref('mailHeading') + '==\n' +
				"{{You've got mail|subject=" + input.section + '|ts=~~~~~}}';

			if (input.message) {
				text += '\n' + input.message + '  ~~~~';
			} else if (Twinkle.getPref('insertTalkbackSignature')) {
				text += '\n~~~~';
			}
			break;
		case 'see':
			text = '{{subst:Please see|location=' + input.page + (input.section ? '#' + input.section : '') + '|more=' + input.message + '}}';
			break;
		default:  // tbtarget one of mytalk, usertalk, other
			// clean talkback heading: strip section header markers that were erroneously suggested in the documentation
			text =
				'==' + Twinkle.getPref('talkbackHeading').replace(/^\s*=+\s*(.*?)\s*=+$\s*/, '$1') + '==\n' +
				'{{talkback|' + input.page + (input.section ? '|' + input.section : '') + '|ts=~~~~~}}';

			if (input.message) {
				text += '\n' + input.message + ' ~~~~';
			} else if (Twinkle.getPref('insertTalkbackSignature')) {
				text += '\n~~~~';
			}
	}
	return text;
};

Twinkle.addInitCallback(Twinkle.talkback, 'talkback');
})(jQuery);


// </nowiki>
"https://ta.wikipedia.org/w/index.php?title=மீடியாவிக்கி:Gadget-friendlytalkback.js&oldid=3108525" இலிருந்து மீள்விக்கப்பட்டது