@Author [[User:Info-farmer]]
*/
/*
if(mw.config.values.wgCanonicalNamespace==="Page"){
}}
*/
// <source lang="javascript">
/* global $, mw, importScript, pathoschild */
//set some global parameters for selection
var isPageNS = mw.config.get('wgNamespaceNumber') == 104;
var isDNB00 = mw.config.get('wgTitle').match('DNB');
/*
/**</source>
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
[
// puts {{right}} into footerbox
{
name: 'endword', position: 'replaceதுப்புரவு3',
script: function(editor) {
editor.forField('#wpHeaderTextbox')
.replace(/(<\/div>)/,'{{right|}}$1');
}
},
{
name: 'துப்புரவு2',
position: 'cursor',
script: function(editor) {
);
// main NS
pathoschild.TemplateScript.add(
[
// adds subst: #tag for <pages>
{ name: 'Pages', template: '<pages index=" " from= to=/>', position: 'cursor'},
// adds subst: #tag for <pages> with sections
{ name: 'Pages++', template: '<pages index=" " from= to= fromsection= tosection= />', position: 'cursor'},
// adds defaultsort for a subpage
{ name: 'defsortsubpage', template: '{{DEFAULTSORT:{{subst:SUBPAGENAME}}}}', position: 'cursor'},
// wikis Chapter -1/+1 to Prev/Next
{
name: 'PrevNext',
position: 'replace',
script: function (editor) {
var oldtitle = mw.config.get('wgTitle');
var prevtitle = parseInt(oldtitle.replace(/^.*\/Chapter (\d+)$/,'$1'))-1;
var headerprevious = '[[../Chapter '+prevtitle+'/]]';
var nexttitle = parseInt(oldtitle.replace(/^.*\/Chapter (\d+)$/,'$1'))+1;
var headernext = '[[../Chapter '+nexttitle+'/]]';
editor.replace(/\| previous \= \n \| next \= /, '| previous \= ' + headerprevious +'\n \| next \= ' + headernext );
}
},
// prev and next populated for subpages
{
name: 'pn [[//]]',
position: 'replace',
script: function (editor) {
var prevnextlink = '[[..//]]';
editor.replace(/\| previous \= \n \| next \= /, '| previous \= ' + prevnextlink +'\n \| next \= ' + prevnextlink );
}
},
// converts header template to DNB00
{
name: 'DNBset',
position: 'replace',
script: function (editor) {
editor.replace(/\{\{header[^\}]+\}\}\n/, '{{subst:DNBset\n |article= \n |previous= \n |next= \n |volume = \n |contributor = \n |wikipedia = \n |extra_notes= \n |from= \n |to= \n |section= \n}}');
},
enabled: isDNB00
},
// converts DNB endash title to a redirect
{
name: 'DNBredirect',
position: 'replace',
editSummary: 'redirect',
script: function (editor) {
editor.replace(/{{header\n \| title\s+?\= ([^–]+?)–([^\n]+?)\n[=\|\w\s\n]*}}/g, '#redirect [[$1-$2]]');
},
enabled: isDNB00
},
// add similar template
{
name: 'similar',
position: 'replace',
editSummary: '{{similar}}',
script: function (editor) {
editor.replace(/\{\{header/g, '{{similar|}}\n{{header');
}
},
// rm text quality templates
{
name: 'text quality',
position: 'replace',
script: function (editor) {
editor.replace(/\{\{TextQuality\|\d{2,3}%\}\}/, '');
}
},
],
{ category:'main', forNamespaces:0 } // common fields
);
// user talk NS
|