Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <nowiki> */
/* Bharat Mitra: welcome module */
( function () {
'use strict';
var BM = window.BharatMitra;
function isIP( name ) { return mw.util.isIPAddress( name || '' ); }
function buildText( v ) {
var user = String( v.username || '' ).trim();
if ( isIP( user ) ) { return '{{subst:Welcome-anon}}'; }
var msg = BM.core.cleanParam( v.message );
return '{{subst:Welcome1' + ( msg ? '|' + msg : '' ) + '}}';
}
BM.register( 'welcome', {
open: function () {
var user = BM.targetUser() || '';
BM.core.dialog( {
title: 'Welcome',
help: 'A welcome message will be added at the end of the selected user\'s talk page. For anonymous (IP) users the Welcome-anon template will be used.',
fields: [
{ name: 'username', label: 'User name', type: 'text', value: user, required: true },
{ name: 'message', label: 'Personal message (optional)', type: 'text', placeholder: 'Registered users only' }
],
preview: function ( v ) { return buildText( v ); },
previewTitle: function ( v ) { return 'User talk:' + String( v.username || '' ).trim(); },
submitLabel: 'Send welcome',
success: 'Welcome message added.',
onSubmit: function ( v ) {
var name = String( v.username || '' ).trim();
var text = buildText( v );
if ( isIP( name ) ) { text += '\n' + BM.SIG; }
return BM.core.appendToPage( 'User talk:' + name, text, 'Added a welcome message (using [[Bharatpedia:Bharat Mitra|Bharat Mitra]])' );
}
} );
}
} );
}() );
/* </nowiki> */