MediaWiki:Gadget-friendlywelcome.js: Perbedaan revisi

Repo at 5c1e7e3: Remove uses of Object.values, not supported by IE; Update Template:W-short; retro to friendlywelcome.js; remove Morebits.queryString (#725); put all template and grouping data in a single object (#747)
(Repo at d9666d4: Update Twinkle from upstream)
(Repo at 5c1e7e3: Remove uses of Object.values, not supported by IE; Update Template:W-short; retro to friendlywelcome.js; remove Morebits.queryString (#725); put all template and grouping data in a single object (#747))
 
// <nowiki>
 
 
(function($) {
 
 
* Active on: Any page with relevant user name (userspace,
* contribs, etc.) and diff pages
* Config directives in: FriendlyConfig
*/
 
Twinkle.welcome = function friendlywelcome() {
if ( Morebitsmw.queryStringutil.existsgetParamValue( 'friendlywelcome' ) ) {
if( Morebits(mw.queryStringutil.getgetParamValue( 'friendlywelcome' ) === 'auto' ) {
Twinkle.welcome.auto();
} else {
 
Twinkle.welcome.auto = function() {
if( Morebits(mw.queryStringutil.getgetParamValue( 'action' ) !== 'edit' ) {
// userpage not empty, aborting auto-welcome
return;
 
Twinkle.welcome.semiauto = function() {
Twinkle.welcome.callback( mw.config.get( 'wgRelevantUserName' ) );
};
 
Twinkle.welcome.normal = function() {
if ( Morebitsmw.queryStringutil.existsgetParamValue( 'diff' ) ) {
// check whether the contributors' talk pages exist yet
var $oList = $("'#mw-diff-otitle2"').find("'span.mw-usertoollinks a.new:contains(talk)"').first();
var $nList = $("'#mw-diff-ntitle2"').find("'span.mw-usertoollinks a.new:contains(talk)"').first();
 
if( ($oList.length > 0 || $nList.length > 0 ) {
var spanTag = function( color, content ) {
var span = document.createElement( 'span' );
span.style.color = color;
span.appendChild( document.createTextNode( content ) );
return span;
};
var welcomeNode = document.createElement('strong');
var welcomeLink = document.createElement('a');
welcomeLink.appendChild( spanTag( 'Black', '[' ) );
welcomeLink.appendChild( spanTag( 'Goldenrod', 'welcome' ) );
welcomeLink.appendChild( spanTag( 'Black', ']' ) );
welcomeNode.appendChild(welcomeLink);
 
if ( $oList.length > 0 ) {
var oHref = $oList.attr("'href"');
 
var oWelcomeNode = welcomeNode.cloneNode( true );
oWelcomeNode.firstChild.setAttribute( 'href', oHref + '&' + Morebits$.queryString.createparam( {
'friendlywelcome': Twinkle.getFriendlyPrefgetPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
'vanarticle': Morebits.pageNameNorm
} ) );
$oList[0].parentNode.parentNode.appendChild( document.createTextNode( ' ' ) );
$oList[0].parentNode.parentNode.appendChild( oWelcomeNode );
}
 
if ( $nList.length > 0 ) {
var nHref = $nList.attr("'href"');
 
var nWelcomeNode = welcomeNode.cloneNode( true );
nWelcomeNode.firstChild.setAttribute( 'href', nHref + '&' + Morebits$.queryString.createparam( {
'friendlywelcome': Twinkle.getFriendlyPrefgetPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
'vanarticle': Morebits.pageNameNorm
} ) );
$nList[0].parentNode.parentNode.appendChild( document.createTextNode( ' ' ) );
$nList[0].parentNode.parentNode.appendChild( nWelcomeNode );
}
}
}
if ( mw.config.get( 'wgRelevantUserName' ) ) {
Twinkle.addPortletLink( function() { Twinkle.welcome.callback(mw.config.get( 'wgRelevantUserName' )); }, "Wel", "friendly-welcome", "Sambut pengguna" );
Twinkle.welcome.callback(mw.config.get('wgRelevantUserName'));
}, 'Wel', 'friendly-welcome', 'Sambut pengguna');
}
};
 
Twinkle.welcome.welcomeUser = function welcomeUser() {
Morebits.status.init( document.getElementById('mw-content-text') );
$( '#catlinks' ).remove();
 
var params = {
value: Twinkle.getFriendlyPrefgetPref('quickWelcomeTemplate'),
article: Morebitsmw.queryStringutil.existsgetParamValue( 'vanarticle' ) ? Morebits.queryString.get( 'vanarticle' ) :|| '',
mode: 'auto'
};
var userTalkPage = mw.config.get('wgFormattedNamespaces')[3] + ':' + mw.config.get('wgRelevantUserName');
Morebits.wiki.actionCompleted.redirect = userTalkPage;
Morebits.wiki.actionCompleted.notice = "'Penyambutan selesai, halaman akan dimuat ulang beberapa saat lagi"';
 
var wikipedia_page = new Morebits.wiki.page(userTalkPage, "'Mengubah halaman pembicaraan pengguna"');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
};
 
Twinkle.welcome.callback = function friendlywelcomeCallback( uid ) {
if( (uid === mw.config.get('wgUserName') && !confirm( 'Anda yakin ingin menyambut diri Anda sendiri?' )) ){
return;
}
 
var Window = new Morebits.simpleWindow( 600, 420 );
Window.setTitle( "'Sambut pengguna" ');
Window.setScriptName( "'Twinkle" ');
Window.addFooterLink('Welcoming "Panitia penyambutan"Committee', "'WP:WC" ');
Window.addFooterLink( "'Bantuan Twinkle"', "'WP:TW/DOC#welcome" ');
 
var form = new Morebits.quickForm( Twinkle.welcome.callback.evaluate );
 
form.append({
type: 'select',
name: 'type',
label: 'Type of welcome: ',
event: Twinkle.welcome.populateWelcomeList,
list: [
{ type: 'option', value: 'standard', label: 'Penyambutan biasastandar', selected: !mw.util.isIPAddress(mw.config.get('wgRelevantUserName')) },
{ type: 'option', value: 'anonymous', label: 'Penyambutan pengguna beralamat IP', selected: mw.util.isIPAddress(mw.config.get('wgRelevantUserName')) },
{ type: 'option', value: 'wikiProject', label: 'Penyambutan WikiProjectProyekWiki' },
{ type: 'option', value: 'nonEnglish', label: 'Penyambutan pengguna non-bahasa InggrisIndonesia' }
]
});
 
form.append( {
type: 'div',
id: 'welcomeWorkArea',
className: 'morebits-scrollbox'
} );
 
form.append( {
type: 'input',
name: 'article',
label: '* Artikel terkait (jika didukung oleh templat):',
value:( Morebitsmw.queryStringutil.existsgetParamValue( 'vanarticle' ) ? Morebits.queryString.get(|| 'vanarticle' ) : '' ),
tooltip: 'Artikel mungkin dapat ditautkan dari proses penyambutan ini jika didukung oleh templat. Kosongkan untuk tidak menautkan artikel. Templat yang mendukung penautan artikel ditandai dengan tanda bintang.'
} );
 
var previewlink = document.createElement( 'a' );
$(previewlink).click(function() {
Twinkle.welcome.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = "'pointer"';
previewlink.textContent = 'Preview';
form.append( { type: 'div', name: 'welcomepreview', label: [ previewlink ] } );
 
form.append( { type: 'submit' } );
 
var result = form.render();
Window.setContent( result );
Window.display();
 
// initialize the welcome list
var evt = document.createEvent( "'Event" ');
evt.initEvent( 'change', true, true );
result.type.dispatchEvent( evt );
};
 
var type = e.target.value;
 
var container = new Morebits.quickForm.element({ type: "'fragment"' });
 
if ((type === "'standard"' || type === "'anonymous"') && Twinkle.getFriendlyPrefgetPref("'customWelcomeList"').length) {
container.append({ type: 'header', label: 'Templat sambutan yang disesuaikan' });
container.append({
type: 'radio',
name: 'template',
list: Twinkle.getFriendlyPrefgetPref("'customWelcomeList"'),
event: Twinkle.welcome.selectTemplatefunction() {
e.target.form.article.disabled = false;
}
});
}
 
var sets = Twinkle.welcome.templates[type];
var appendTemplates = function(list) {
$.each(sets, function(label, templates) {
container.append({ type: 'header', label: label });
container.append({
type: 'radio',
name: 'template',
list: list$.map(templates, function(objproperties, template) {
return {
var properties = Twinkle.welcome.templates[obj];
value: template,
var result = (properties ? {
label: '{{' + template + '}}: ' + properties.description + (properties.linkedArticle ? '\u00A0*' : ''), // U+00A0 NO-BREAK SPACE
value: obj,
label: "{{" + obj + "}}: " + properties.description + (properties.linkedArticle ? "\u00A0*" : ""), // U+00A0 NO-BREAK SPACE
tooltip: properties.tooltip // may be undefined
} : {;
value: obj,
label: "{{" + obj + "}}"
});
return result;
}),
event: Twinkle.welcome.selectTemplatefunction(ev) {
ev.target.form.article.disabled = !templates[ev.target.value].linkedArticle;
}
});
});
 
switch (type) {
case "standard":
container.append({ type: 'header', label: 'Templat penyambutan umum' });
appendTemplates([
"welcome",
"welcome-short",
"welcome-personal",
"welcome-graphical",
"welcome-menu",
"welcome-screen",
"welcome-belated",
"welcome student",
"welcome teacher",
"welcome non-latin"
]);
container.append({ type: 'header', label: 'Templat penyambutan pengguna bermasalah' });
appendTemplates([
"welcomelaws",
"first article",
"welcometest",
"welcomevandal",
"welcomenpov",
"welcomespam",
"welcomeunsourced",
"welcomeauto",
"welcome-COI",
"welcome-delete",
"welcome-image"
]);
break;
case "anonymous":
container.append({ type: 'header', label: 'Templat penyambutan pengguna anonim' });
appendTemplates([
"welcome-anon",
"welcome-anon-test",
"welcome-anon-unconstructive",
"welcome-anon-constructive",
"welcome-anon-delete"
]);
break;
case "wikiProject":
container.append({ type: 'header', label: 'Templat penyambutan WikiProject tertentu' });
appendTemplates([
"welcome-anatomy",
"welcome-athletics",
"welcome-au",
"welcome-bd",
"welcome-bio",
"welcome-cal",
"welcome-conserv",
"welcome-cycling",
"welcome-dbz",
"welcome-et",
"welcome-de",
"welcome-in",
"welcome-math",
"welcome-med",
"welcome-no",
"welcome-pk",
"welcome-phys",
"welcome-pl",
"welcome-roads",
"welcome-rugbyunion",
"welcome-ru",
"welcome-starwars",
"welcome-ch",
"welcome-uk",
"welcome-videogames",
"TWA invite"
]);
break;
case "nonEnglish":
container.append({ type: 'header', label: 'Templat penyambutan pengguna bukan pengguna bahasa Inggris' });
appendTemplates([
"welcomeen",
"welcomeen-sq",
"welcomeen-ar",
"welcomeen-zh",
"welcomeen-nl",
"welcomeen-fi",
"welcomeen-fr",
"welcomeen-de",
"welcomeen-he",
"welcomeen-ja",
"welcomeen-ko",
"welcomeen-ml",
"welcomeen-mr",
"welcomeen-or",
"welcomeen-pt",
"welcomeen-ro",
"welcomeen-ru",
"welcomeen-es",
"welcomeen-sv",
"welcomeen-uk"
]);
break;
default:
container.append({ type: 'div', label: 'Twinkle.welcome.populateWelcomeList: terjadi kesalahan' });
break;
}
 
var rendered = container.render();
$(e.target.form).find("'div#welcomeWorkArea"').empty().append(rendered);
 
var firstRadio = e.target.form.template[0];
firstRadio.checked = true;
var vals = sets[Object.keys(sets)[0]];
Twinkle.welcome.selectTemplate({ target: firstRadio });
e.target.form.article.disabled = vals[firstRadio.value] ? !vals[firstRadio.value].linkedArticle : true;
};
 
Twinkle.welcome.selectTemplate = function(e) {
var properties = Twinkle.welcome.templates[e.target.values];
e.target.form.article.disabled = (properties ? !properties.linkedArticle : false);
};
 
 
// A list of welcome templates and their properties and syntax
 
Twinkle.welcome.templates = {
'standard': {
// GENERAL WELCOMES
'General welcome templates': {
'welcome': {
description: 'standard welcome',
linkedArticle: true,
syntax: '{{subst:welcome|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-retro': {
description: 'a welcome message with a small list of helpful links',
linkedArticle: true,
syntax: '{{subst:welcome-retro|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-short': {
description: 'a shorter welcome message',
syntax: '{{subst:w-short|heading=yes|$EXTRA$}}'
},
'welcome-personal': {
description: 'more personal welcome, including a plate of cookies',
syntax: '{{subst:welcome-personal|$USERNAME$}} ~~~~'
},
'welcome-graphical': {
description: 'colorful welcome message with table of about 20 links',
syntax: '$HEADER$ {{subst:welcome-graphical|$EXTRA$}}'
},
'welcome-menu': {
description: 'welcome message with large table of about 60 links',
syntax: '{{subst:welcome-menu}}'
},
'welcome-screen': {
description: 'welcome message with clear, annotated table of 10 links',
syntax: '$HEADER$ {{subst:welcome-screen}}'
},
'welcome-belated': {
description: 'welcome for users with more substantial contributions',
syntax: '{{subst:welcome-belated|$USERNAME$}}'
},
'welcome student': {
description: 'welcome for students editing as part of an educational class project',
syntax: '$HEADER$ {{subst:welcome student|$USERNAME$}} ~~~~'
},
'welcome teacher': {
description: 'welcome for course instructors involved in an educational class project',
syntax: '$HEADER$ {{subst:welcome teacher|$USERNAME$}} ~~~~'
},
'welcome non-latin': {
description: 'welcome for users with a username containing non-Latin characters',
syntax: '{{subst:welcome non-latin|$USERNAME$}} ~~~~'
}
},
 
" 'Problem user welcome" templates': {
'welcomelaws': {
description: "standard welcome",
description: 'welcome with information about copyrights, NPOV, the sandbox, and vandalism',
linkedArticle: true,
syntax: "'{{subst:welcomewelcomelaws|$USERNAME$|art=$ARTICLE$}} ~~~~"'
},
'first article': {
"welcome-short": {
description: 'for someone whose first article did not meet page creation guidelines',
description: "pesan sambutan pendek",
linkedArticle: falsetrue,
syntax: "'{{subst:welcome-shortfirst article|$ARTICLE$|$USERNAME$}} $EXTRA$ ~~~~"'
},
'welcometest': {
"welcome-personal": {
description: "sambutan'for lebihsomeone ramah,whose denganinitial semangkukefforts kue"appear to be tests',
linkedArticle: falsetrue,
syntax: "'{{subst:welcome-personalwelcometest|$ARTICLE$|$USERNAME$}} ~~~~"'
},
'welcomevandal': {
"welcome-graphical": {
description: "pesan'for sambutansomeone berwarnawhose denganinitial tabelefforts berisiappear 20to pranala"be vandalism',
linkedArticle: falsetrue,
syntax: "$HEADER$ '{{subst:welcome-graphicalwelcomevandal|$ARTICLE$|$EXTRAUSERNAME$}}"'
},
'welcomenpov': {
"welcome-menu": {
description: "pesan'for sambutansomeone denganwhose tabelinitial lebihefforts besardo (60not pranala)"adhere to the neutral point of view policy',
linkedArticle: falsetrue,
syntax: "'{{subst:welcome-menuwelcomenpov|$ARTICLE$|$USERNAME$}}" ~~~~'
},
'welcomespam': {
"welcome-screen": {
description: "pesan'welcome sambutanwith denganadditional tabeldiscussion bertandaof dananti-spamming jelas dengan 10 pranala"policies',
linkedArticle: falsetrue,
syntax: "$HEADER$ '{{subst:welcome-screenwelcomespam|$ARTICLE$|$USERNAME$}}" ~~~~'
},
'welcomeunsourced': {
"welcome-belated": {
description: "sambutan'for untuksomeone penggunawhose denganinitial kontribusiefforts berguna"are unsourced',
linkedArticle: falsetrue,
syntax: "'{{subst:welcome-belatedwelcomeunsourced|$ARTICLE$|$USERNAME$}}" ~~~~'
},
'welcomeauto': {
"welcome student": {
description: "welcome 'for studentssomeone editingwho as part ofcreated an educational classautobiographical project"article',
linkedArticle: falsetrue,
syntax: "$HEADER$ '{{subst:welcome studentwelcomeauto|$USERNAME$|art=$ARTICLE$}} ~~~~"'
},
" 'welcome teacher"-COI': {
description: "welcome 'for coursesomeone instructorswho involvedhas edited in anareas where they may have a educationalconflict classof project"interest',
linkedArticle: falsetrue,
syntax: "$HEADER$ '{{subst:welcome teacher-COI|$USERNAME$|art=$ARTICLE$}} ~~~~"'
},
" 'welcome non-latin"delete': {
description: "welcome 'for userssomeone who withhas abeen usernameremoving containinginformation non-Latinfrom characters"articles',
linkedArticle: falsetrue,
syntax: "'{{subst:welcome non-latindelete|$ARTICLE$|$USERNAME$}} ~~~~"'
},
'welcome-image': {
description: 'welcome with additional information about images (policy and procedure)',
linkedArticle: true,
syntax: '{{subst:welcome-image|$USERNAME$|art=$ARTICLE$}}'
}
}
},
 
'anonymous': {
// PROBLEM USER WELCOMES
'Anonymous user welcome templates': {
 
'welcome-anon': {
"welcomelaws": {
description: "welcome'for withanonymous informationusers; aboutencourages copyrights,creating NPOV,an the sandbox, and vandalism"account',
linkedArticle: falsetrue,
syntax: "'{{subst:welcomelawswelcome-anon|art=$USERNAMEARTICLE$}} ~~~~"'
},
'welcome-anon-test': {
"first article": {
description: "'for someoneanonymous whoseusers firstwho articlehave didperformed nottest meet page creation guidelines"edits',
linkedArticle: true,
syntax: "'{{subst:first articlewelcome-anon-test|$ARTICLE$|$USERNAME$}}" ~~~~'
},
'welcome-anon-unconstructive': {
"welcometest": {
description: "'for someoneanonymous whoseusers initialwho effortshave appearvandalized toor bemade tests"unhelpful edits',
linkedArticle: true,
syntax: "'{{subst:welcometestwelcome-anon-unconstructive|$ARTICLE$|$USERNAME$}} ~~~~"'
},
'welcome-anon-constructive': {
"welcomevandal": {
description: "'for someoneanonymous whoseusers initialwho effortsfight appearvandalism toor beedit vandalism"constructively',
linkedArticle: true,
syntax: "'{{subst:welcomevandalwelcome-anon-constructive|art=$ARTICLE$|$USERNAME$}}"'
},
'welcome-anon-delete': {
"welcomenpov": {
description: "'for someoneanonymous whoseusers initialwho effortshave doremoved notcontent adherefrom to the neutral point of view policy"pages',
linkedArticle: true,
syntax: "'{{subst:welcomenpovwelcome-anon-delete|$ARTICLE$|$USERNAME$}} ~~~~"'
}
},
}
"welcomespam": {
description: "welcome with additional discussion of anti-spamming policies",
linkedArticle: true,
syntax: "{{subst:welcomespam|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcomeunsourced": {
description: "for someone whose initial efforts are unsourced",
linkedArticle: true,
syntax: "{{subst:welcomeunsourced|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcomeauto": {
description: "for someone who created an autobiographical article",
linkedArticle: true,
syntax: "{{subst:welcomeauto|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-COI": {
description: "for someone who has edited in areas where they may have a conflict of interest",
linkedArticle: true,
syntax: "{{subst:welcome-COI|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-delete": {
description: "for someone who has been removing information from articles",
linkedArticle: true,
syntax: "{{subst:welcome-delete|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcome-image": {
description: "welcome with additional information about images (policy and procedure)",
linkedArticle: true,
syntax: "{{subst:welcome-image|$USERNAME$|art=$ARTICLE$}}"
},
 
'wikiProject': {
// ANONYMOUS USER WELCOMES
'WikiProject-specific welcome templates': {
 
" 'welcome-anon"anatomy': {
description: "'welcome for anonymous users; encourages creatingwith an account"apparent interest in anatomy topics',
syntax: '{{subst:welcome-anatomy}} ~~~~'
linkedArticle: true,
},
syntax: "{{subst:welcome-anon|art=$ARTICLE$}} ~~~~"
'welcome-athletics': {
},
description: 'welcome for users with an apparent interest in athletics (track and field) topics',
"welcome-anon-test": {
syntax: '{{subst:welcome-athletics}}'
description: "for anonymous users who have performed test edits",
},
linkedArticle: true,
'welcome-au': {
syntax: "{{subst:welcome-anon-test|$ARTICLE$|$USERNAME$}} ~~~~"
description: 'welcome for users with an apparent interest in Australia topics',
},
syntax: '{{subst:welcome-au}} ~~~~'
"welcome-anon-unconstructive": {
},
description: "for anonymous users who have vandalized or made unhelpful edits",
'welcome-bd': {
linkedArticle: true,
description: 'welcome for users with an apparent interest in Bangladesh topics',
syntax: "{{subst:welcome-anon-unconstructive|$ARTICLE$|$USERNAME$}}"
linkedArticle: true,
},
syntax: '{{subst:welcome-bd|$USERNAME$||$EXTRA$|art=$ARTICLE$}} ~~~~'
"welcome-anon-constructive": {
},
description: "for anonymous users who fight vandalism or edit constructively",
'welcome-bio': {
linkedArticle: true,
description: 'welcome for users with an apparent interest in biographical topics',
syntax: "{{subst:welcome-anon-constructive|art=$ARTICLE$}}"
syntax: '{{subst:welcome-bio}} ~~~~'
},
},
"welcome-anon-delete": {
'welcome-cal': {
description: "for anonymous users who have removed content from pages",
description: 'welcome for users with an apparent interest in California topics',
linkedArticle: true,
syntax: "'{{subst:welcome-anon-delete|$ARTICLE$|$USERNAME$cal}} ~~~~"'
},
'welcome-conserv': {
description: 'welcome for users with an apparent interest in conservatism topics',
syntax: '{{subst:welcome-conserv}}'
},
'welcome-cycling': {
description: 'welcome for users with an apparent interest in cycling topics',
syntax: '{{subst:welcome-cycling}} ~~~~'
},
'welcome-dbz': {
description: 'welcome for users with an apparent interest in Dragon Ball topics',
syntax: '{{subst:welcome-dbz|$EXTRA$|sig=~~~~}}'
},
'welcome-et': {
description: 'welcome for users with an apparent interest in Estonia topics',
syntax: '{{subst:welcome-et}}'
},
'welcome-de': {
description: 'welcome for users with an apparent interest in Germany topics',
syntax: '{{subst:welcome-de}} ~~~~'
},
'welcome-in': {
description: 'welcome for users with an apparent interest in India topics',
linkedArticle: true,
syntax: '{{subst:welcome-in|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-math': {
description: 'welcome for users with an apparent interest in mathematical topics',
linkedArticle: true,
syntax: '{{subst:welcome-math|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-med': {
description: 'welcome for users with an apparent interest in medicine topics',
linkedArticle: true,
syntax: '{{subst:welcome-med|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-no': {
description: 'welcome for users with an apparent interest in Norway topics',
syntax: '{{subst:welcome-no}} ~~~~'
},
'welcome-pk': {
description: 'welcome for users with an apparent interest in Pakistan topics',
linkedArticle: true,
syntax: '{{subst:welcome-pk|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-phys': {
description: 'welcome for users with an apparent interest in physics topics',
linkedArticle: true,
syntax: '{{subst:welcome-phys|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-pl': {
description: 'welcome for users with an apparent interest in Poland topics',
syntax: '{{subst:welcome-pl}} ~~~~'
},
'welcome-rugbyunion': {
description: 'welcome for users with an apparent interest in rugby union topics',
syntax: '{{subst:welcome-rugbyunion}} ~~~~'
},
'welcome-ru': {
description: 'welcome for users with an apparent interest in Russia topics',
syntax: '{{subst:welcome-ru}} ~~~~'
},
'welcome-starwars': {
description: 'welcome for users with an apparent interest in Star Wars topics',
syntax: '{{subst:welcome-starwars}} ~~~~'
},
'welcome-ch': {
description: 'welcome for users with an apparent interest in Switzerland topics',
linkedArticle: true,
syntax: '{{subst:welcome-ch|$USERNAME$|art=$ARTICLE$}} ~~~~'
},
'welcome-uk': {
description: 'welcome for users with an apparent interest in Ukraine topics',
syntax: '{{subst:welcome-uk}} ~~~~'
},
'welcome-roads': {
description: 'welcome for users with an apparent interest in roads and highways topics',
syntax: '{{subst:welcome-roads}}'
},
'welcome-videogames': {
description: 'welcome for users with an apparent interest in video game topics',
syntax: '{{subst:welcome-videogames}}'
},
'TWA invite': {
description: 'invite the user to The Wikipedia Adventure (not a welcome template)',
syntax: '{{WP:TWA/InviteTW|signature=~~~~}}'
}
}
},
 
'nonEnglish': {
// WIKIPROJECT-SPECIFIC WELCOMES
'Non-English welcome templates': {
'welcomeen': {
description: 'welcome for users whose first language is not listed here',
syntax: '{{subst:welcomeen}}'
},
'welcomeen-ar': {
description: 'welcome for users whose first language appears to be Arabic',
syntax: '{{subst:welcomeen-ar}}'
},
'welcomeen-sq': {
description: 'welcome for users whose first language appears to be Albanian',
syntax: '{{subst:welcomeen-sq}}'
},
'welcomeen-zh': {
description: 'welcome for users whose first language appears to be Chinese',
syntax: '{{subst:welcomeen-zh}}'
},
'welcomeen-nl': {
description: 'welcome for users whose first language appears to be Dutch',
syntax: '{{subst:welcomeen-nl}}'
},
'welcomeen-fi': {
description: 'welcome for users whose first language appears to be Finnish',
syntax: '{{subst:welcomeen-fi}}'
},
'welcomeen-fr': {
description: 'welcome for users whose first language appears to be French',
syntax: '{{subst:welcomeen-fr}}'
},
'welcomeen-de': {
description: 'welcome for users whose first language appears to be German',
syntax: '{{subst:welcomeen-de}}'
},
'welcomeen-he': {
description: 'welcome for users whose first language appears to be Hebrew',
syntax: '{{subst:welcomeen-he}}'
},
'welcomeen-ja': {
description: 'welcome for users whose first language appears to be Japanese',
syntax: '{{subst:welcomeen-ja}}'
},
'welcomeen-ko': {
description: 'welcome for users whose first language appears to be Korean',
syntax: '{{subst:welcomeen-ko}}'
},
'welcomeen-ml': {
description: 'welcome for users whose first language appears to be Malayalam',
syntax: '{{subst:welcomeen-ml}}'
},
'welcomeen-mr': {
description: 'welcome for users whose first language appears to be Marathi',
syntax: '{{subst:welcomeen-mr}}'
},
'welcomeen-or': {
description: 'welcome for users whose first language appears to be Oriya (Odia)',
syntax: '{{subst:welcomeen-or}}'
},
'welcomeen-pt': {
description: 'welcome for users whose first language appears to be Portuguese',
syntax: '{{subst:welcomeen-pt}}'
},
'welcomeen-ro': {
description: 'welcome for users whose first language appears to be Romanian',
syntax: '{{subst:welcomeen-ro}}'
},
'welcomeen-ru': {
description: 'welcome for users whose first language appears to be Russian',
syntax: '{{subst:welcomeen-ru}}'
},
'welcomeen-es': {
description: 'welcome for users whose first language appears to be Spanish',
syntax: '{{subst:welcomeen-es}}'
},
'welcomeen-sv': {
description: 'welcome for users whose first language appears to be Swedish',
syntax: '{{subst:welcomeen-sv}}'
},
'welcomeen-uk': {
description: 'welcome for users whose first language appears to be Ukrainian',
syntax: '{{subst:welcomeen-uk}}'
}
}
}
 
"welcome-anatomy": {
description: "welcome for users with an apparent interest in anatomy topics",
linkedArticle: false,
syntax: "{{subst:welcome-anatomy}} ~~~~"
},
"welcome-athletics": {
description: "welcome for users with an apparent interest in athletics (track and field) topics",
linkedArticle: false,
syntax: "{{subst:welcome-athletics}}"
},
"welcome-au": {
description: "welcome for users with an apparent interest in Australia topics",
linkedArticle: false,
syntax: "{{subst:welcome-au}} ~~~~"
},
"welcome-bd": {
description: "welcome for users with an apparent interest in Bangladesh topics",
linkedArticle: true,
syntax: "{{subst:welcome-bd|$USERNAME$||$EXTRA$|art=$ARTICLE$}} ~~~~"
},
"welcome-bio": {
description: "welcome for users with an apparent interest in biographical topics",
linkedArticle: false,
syntax: "{{subst:welcome-bio}} ~~~~"
},
"welcome-cal": {
description: "welcome for users with an apparent interest in California topics",
linkedArticle: false,
syntax: "{{subst:welcome-cal}} ~~~~"
},
"welcome-conserv": {
description: "welcome for users with an apparent interest in conservatism topics",
linkedArticle: false,
syntax: "{{subst:welcome-conserv}}"
},
"welcome-cycling": {
description: "welcome for users with an apparent interest in cycling topics",
linkedArticle: false,
syntax: "{{subst:welcome-cycling}} ~~~~"
},
"welcome-dbz": {
description: "welcome for users with an apparent interest in Dragon Ball topics",
linkedArticle: false,
syntax: "{{subst:welcome-dbz|$EXTRA$|sig=~~~~}}"
},
"welcome-et": {
description: "welcome for users with an apparent interest in Estonia topics",
linkedArticle: false,
syntax: "{{subst:welcome-et}}"
},
"welcome-de": {
description: "welcome for users with an apparent interest in Germany topics",
linkedArticle: false,
syntax: "{{subst:welcome-de}} ~~~~"
},
"welcome-in": {
description: "welcome for users with an apparent interest in India topics",
linkedArticle: true,
syntax: "{{subst:welcome-in|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-math": {
description: "welcome for users with an apparent interest in mathematical topics",
linkedArticle: true,
syntax: "{{subst:welcome-math|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-med": {
description: "welcome for users with an apparent interest in medicine topics",
linkedArticle: true,
syntax: "{{subst:welcome-med|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-no": {
description: "welcome for users with an apparent interest in Norway topics",
linkedArticle: false,
syntax: "{{subst:welcome-no}} ~~~~"
},
"welcome-pk": {
description: "welcome for users with an apparent interest in Pakistan topics",
linkedArticle: true,
syntax: "{{subst:welcome-pk|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-phys": {
description: "welcome for users with an apparent interest in physics topics",
linkedArticle: true,
syntax: "{{subst:welcome-phys|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-pl": {
description: "welcome for users with an apparent interest in Poland topics",
linkedArticle: false,
syntax: "{{subst:welcome-pl}} ~~~~"
},
"welcome-rugbyunion": {
description: "welcome for users with an apparent interest in rugby union topics",
linkedArticle: false,
syntax: "{{subst:welcome-rugbyunion}} ~~~~"
},
"welcome-ru": {
description: "welcome for users with an apparent interest in Russia topics",
linkedArticle: false,
syntax: "{{subst:welcome-ru}} ~~~~"
},
"welcome-starwars": {
description: "welcome for users with an apparent interest in Star Wars topics",
linkedArticle: false,
syntax: "{{subst:welcome-starwars}} ~~~~"
},
"welcome-ch": {
description: "welcome for users with an apparent interest in Switzerland topics",
linkedArticle: true,
syntax: "{{subst:welcome-ch|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-uk": {
description: "welcome for users with an apparent interest in Ukraine topics",
linkedArticle: false,
syntax: "{{subst:welcome-uk}} ~~~~"
},
"welcome-roads": {
description: "welcome for users with an apparent interest in roads and highways topics",
linkedArticle: false,
syntax: "{{subst:welcome-roads}}"
},
"welcome-videogames": {
description: "welcome for users with an apparent interest in video game topics",
linkedArticle: false,
syntax: "{{subst:welcome-videogames}}"
},
"TWA invite": {
description: "invite the user to The Wikipedia Adventure (not a welcome template)",
linkedArticle: false,
syntax: "{{WP:TWA/InviteTW|signature=~~~~}}"
},
 
// NON-ENGLISH WELCOMES
 
"welcomeen": {
description: "welcome for users whose first language is not listed here",
linkedArticle: false,
syntax: "{{subst:welcomeen}}"
},
"welcomeen-ar": {
description: "welcome for users whose first language appears to be Arabic",
linkedArticle: false,
syntax: "{{subst:welcomeen-ar}}"
},
"welcomeen-sq": {
description: "welcome for users whose first language appears to be Albanian",
linkedArticle: false,
syntax: "{{subst:welcomeen-sq}}"
},
"welcomeen-zh": {
description: "welcome for users whose first language appears to be Chinese",
linkedArticle: false,
syntax: "{{subst:welcomeen-zh}}"
},
"welcomeen-nl": {
description: "welcome for users whose first language appears to be Dutch",
linkedArticle: false,
syntax: "{{subst:welcomeen-nl}}"
},
"welcomeen-fi": {
description: "welcome for users whose first language appears to be Finnish",
linkedArticle: false,
syntax: "{{subst:welcomeen-fi}}"
},
"welcomeen-fr": {
description: "welcome for users whose first language appears to be French",
linkedArticle: false,
syntax: "{{subst:welcomeen-fr}}"
},
"welcomeen-de": {
description: "welcome for users whose first language appears to be German",
linkedArticle: false,
syntax: "{{subst:welcomeen-de}}"
},
"welcomeen-he": {
description: "welcome for users whose first language appears to be Hebrew",
linkedArticle: false,
syntax: "{{subst:welcomeen-he}}"
},
"welcomeen-ja": {
description: "welcome for users whose first language appears to be Japanese",
linkedArticle: false,
syntax: "{{subst:welcomeen-ja}}"
},
"welcomeen-ko": {
description: "welcome for users whose first language appears to be Korean",
linkedArticle: false,
syntax: "{{subst:welcomeen-ko}}"
},
"welcomeen-ml": {
description: "welcome for users whose first language appears to be Malayalam",
linkedArticle: false,
syntax: "{{subst:welcomeen-ml}}"
},
"welcomeen-mr": {
description: "welcome for users whose first language appears to be Marathi",
linkedArticle: false,
syntax: "{{subst:welcomeen-mr}}"
},
"welcomeen-or": {
description: "welcome for users whose first language appears to be Oriya (Odia)",
linkedArticle: false,
syntax: "{{subst:welcomeen-or}}"
},
"welcomeen-pt": {
description: "welcome for users whose first language appears to be Portuguese",
linkedArticle: false,
syntax: "{{subst:welcomeen-pt}}"
},
"welcomeen-ro": {
description: "welcome for users whose first language appears to be Romanian",
linkedArticle: false,
syntax: "{{subst:welcomeen-ro}}"
},
"welcomeen-ru": {
description: "welcome for users whose first language appears to be Russian",
linkedArticle: false,
syntax: "{{subst:welcomeen-ru}}"
},
"welcomeen-es": {
description: "welcome for users whose first language appears to be Spanish",
linkedArticle: false,
syntax: "{{subst:welcomeen-es}}"
},
"welcomeen-sv": {
description: "welcome for users whose first language appears to be Swedish",
linkedArticle: false,
syntax: "{{subst:welcomeen-sv}}"
},
"welcomeen-uk": {
description: "welcome for users whose first language appears to be Ukrainian",
linkedArticle: false,
syntax: "{{subst:welcomeen-uk}}"
}
};
 
Twinkle.welcome.getTemplateWikitext = function(type, template, article) {
// the iteration is required as the type=standard has two groups
var properties = Twinkle.welcome.templates[template];
var properties;
$.each(Twinkle.welcome.templates[type], function(label, templates) {
properties = templates[template];
if (properties) {
return false; // break
}
});
if (properties) {
return properties.syntax.
replace("'$USERNAME$"', Twinkle.getFriendlyPrefgetPref("'insertUsername"') ? mw.config.get("'wgUserName"') : ""'').
replace("'$ARTICLE$"', article ? article : ""'').
replace(/\$HEADER\$\s*/, "'== Welcome ==\n\n"').
replace("'$EXTRA$"', ""''); // EXTRA is not implemented yet
} else {
return "{{subst:" + template + (article ? ("|art=" + article) : "") + "}}" +
(Twinkle.getFriendlyPref("customWelcomeSignature") ? " ~~~~" : "");
}
return '{{subst:' + template + (article ? '|art=' + article : '') + '}}' +
(Twinkle.getPref('customWelcomeSignature') ? ' ~~~~' : '');
};
 
preview: function(form) {
var previewDialog = new Morebits.simpleWindow(750, 400);
previewDialog.setTitle("'Welcome template preview"');
previewDialog.setScriptName("'Welcome user"');
previewDialog.setModality(true);
 
var previewdiv = document.createElement("'div"');
previewdiv.style.marginLeft = previewdiv.style.marginRight = "'0.5em"';
previewdiv.style.fontSize = "'small"';
previewDialog.setContent(previewdiv);
 
var previewer = new Morebits.wiki.preview(previewdiv);
previewer.beginRender(Twinkle.welcome.getTemplateWikitext(form.type.value, form.getChecked("'template"'), form.article.value), 'User talk:' + mw.config.get('wgRelevantUserName')); // Force wikitext/correct username
 
var submit = document.createElement("'input"');
submit.setAttribute("'type"', "'submit"');
submit.setAttribute("'value"', "'Close"');
previewDialog.addContent(submit);
 
});
},
main: function( pageobj ) {
var params = pageobj.getCallbackParameters();
var text = pageobj.getPageText();
 
// abort if mode is auto and form is not empty
if( (pageobj.exists() && params.mode === 'auto' ) {
Morebits.status.info( 'Warning', 'User talk page not empty; aborting automatic welcome' );
Morebits.wiki.actionCompleted.event();
return;
}
 
var welcomeText = Twinkle.welcome.getTemplateWikitext(params.type, params.value, params.article);
 
if ( Twinkle.getFriendlyPrefgetPref('topWelcomes') ) {
text = welcomeText + '\n\n' + text;
} else {
text += "'\n"' + welcomeText;
}
 
var summaryText = "'Welcome to Wikipedia!"';
pageobj.setPageText(text);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setWatchlist(Twinkle.getFriendlyPrefgetPref('watchWelcomes'));
pageobj.setCreateOption('recreate');
pageobj.save();
 
var params = {
valuetype: form.getChecked("template")type.value,
value: form.getChecked('template'),
article: form.article.value,
mode: 'manual'
};
 
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
 
var userTalkPage = mw.config.get('wgFormattedNamespaces')[3] + ':' + mw.config.get('wgRelevantUserName');
Morebits.wiki.actionCompleted.redirect = userTalkPage;
Morebits.wiki.actionCompleted.notice = "'Welcoming complete, reloading talk page in a few seconds"';
 
var wikipedia_page = new Morebits.wiki.page(userTalkPage, "'User talk page modification"');
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
 
 
// </nowiki>