Bikarhêner:Balyozxane/skrîpt/js/templateScript.js
Xuyakirin
(Ji Bikarhêner:Balyozxane/templateScript.js hat beralîkirin)
Zanibe: Piştî weşandinê, ji bo dîtina guhartinan dibe ku hewce be "cache"ya geroka xwe paqij bikî.
- Firefox / Safari: Pê li Shift û Reload bike an jî Ctrl-F5 an Ctrl-R bike (ji bo Mac: ⌘-R)
- Google Chrome: Pê li Ctrl-Shift-R (ji bo Mac: ⌘-Shift-R) bike
- Internet Explorer / Edge: Pê li Ctrl û Refresh bike, an jî Ctrl-F5 bike
- Opera: Pê li Ctrl-F5 bike.
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
* @update-token [[File:Pathoschild/templatescript.js]]
*/
// <nowiki>
var katreberaKO = mw.config.get('wgTitle');
katreberaKO = katreberaKO.replace(/Gotarên bi rêbera (.+)$/g, '$1');
var title = mw.config.get('wgTitle');
var sablonfull = mw.config.get('wgPageName');
var sablonbelgeremoved = sablonfull.replace(/(.+)\/belge/g, '$1');
var sablonbelgeremoved = sablonbelgeremoved.replace(/_/g, ' ');
var kat = title.replace(/(.+)ên .+/g, '$1');
var kategori = title.replace(/Şitilên (.+)/g, '$1');
var netewe = title.replace(/(.+)ên (.+)/g, '$2');
var netewe2 = title.replace(/(.+) li gorî pîşeyan/g, '$1');
var pise = title.replace(/(.+) li gorî neteweyan/g, '$1');
var dugel = "";
if (netewe == "brîtanî") {
dugel == "Keyaniya Yekbûyî";
}else if (netewe == "amerîkî"){
dugel == "DYA";
}else{
wd=title;
}
var gotar = title.replace(/(.+)\, (.+)/g, '$1');
var gund = title.replace(/(.*?), .+/g, '$1');
var navce = title.replace(/(.*?) \(navçe\)/g, '$1');
var amt = title.replace(/(.*?) \(Verbandsgemeinde\)/g, '$1');
//var wd = title.replace(/(.*?), Almanya/g, '$1, Germany');
//var wd = title.replace(/(.*?), Rheinland-Pfalz/g, '$1, Rhineland-Palatinate');
var wd;
if (/Almanya$/.test(title) == true){
wd = title.replace(/(.*?), Almanya/g, '$1, Germany');
}else if (/Rheinland-Pfalz$/.test(title) == true){
wd = title.replace(/(.*?), Rheinland-Pfalz/g, '$1, Rhineland-Palatinate');
}
/*
var katjdb;
if (/Jidayikbûn (\d+)î/.test(title) == true){
catjdb = title.replace(/Jidayikbûn (\d+)î/g, '$1');
caten = 's births';
}else if (/Mirin (\d+)î/.test(title) == true){
catjdb = title.replace(/Mirin (\d+)î/g, '$1');
caten = 's deaths';
}else if (/Mirin (\d+)$/.test(title) == true){
catjdb = title.replace(/Mirin (\d+)$/g, '$1');
caten = ' deaths';
}else if (/Bidawîbûnên (\d+)an$/.test(title) == true){
catjdb = title.replace(/Bidawîbûnên (\d+)an$/g, '$1');
caten = ' endings';
}else if (/Bidawîbûnên (\d+)î$/.test(title) == true){
catjdb = title.replace(/Bidawîbûnên (\d+)î$/g, '$1');
caten = 's endings';
}else if (/^(\d+)î$/.test(title) == true){
catjdb = title.replace(/^(\d+)î$/g, '$1');
caten = 's';
}else if (/^(\d+)$/.test(title) == true){
catjdb = title.replace(/^(\d+)$/g, '$1');
caten = '';
}else if (/^Fîlmên (\d+)an$/.test(title) == true){
catjdb = title.replace(/^Fîlmên (\d+)an$/g, '$1');
caten = ' films';
}else if (/^Berhemên (\d+)an$/.test(title) == true){
catjdb = title.replace(/^Berhemên (\d+)an$/g, '$1');
caten = ' works';
}else if (/^Berhemên (\d+)î$/.test(title) == true){
catjdb = title.replace(/^Berhemên (\d+)î$/g, '$1');
caten = 's works';
}else{
catjdb=title;
}
*/
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add({
name:'Sererastbike',
//forNamespaces: '0',
accessKey: 'a',
script: function(editor) {
editor
//.replace(//g, '')
.replace(/“/g, '"')
.replace(/„/g, '"')
.replace(/(V|v)îrûs/g, '$1îrus')
.replace(/(\]\])?(’|\')(ê|an)/g, '$1$3')
.replace(/\([ ]*?z\./g, '\(jdb.')
.replace(/<ref name="(.*?)">([^>]+)<\/ref>(,|\.)/g, '$3<ref name="$1">$2<\/ref>')
.replace(/<ref name="(.*?)"\/>(,|\.)/g, '$2<ref name="$1"/>')
.replace(/ref> <ref/g, 'ref><ref')
.replace(/[ ]*,/g, ',')
.replace(/(,|\.) <ref>/g, '$1<ref>')
.replace(/<ref>([^>]+)<\/ref>(,|\.)/g, '$2<ref>$1<\/ref>')
.replace(/îy/g, 'iy')
.replace(/([\d]+)(\’|\')(ê|yê)?(a|an)?/g, '$1$3$4') //hejmar
.replace(/([\d]+)(\’|\')(emîn|em)/g, '$1$3') //hejmar
.replace(/([\d]+)\’(ê|yê)?(a|an)?/g, '$1$2$3') //hejmar
.replace(/([\d]+)\’(emîn|em)/g, '$1$3') //hejmar
.replace(/([\d]{4})-(a|an)/g, '$1$2') //hejmar
.replace(/([\d]{4})-(ê|yê)/g, '$1$2') //hejmar
// .replace(/\b\[?\[?s?S?tenbol(ê|a)?\]?\]?\b/g, 'Stembol$1')//Stenbol
.replace(/\([ ]*/g, '\(')
.replace(/[ ]*\)/g, '\)')
.replace(/\(\[\[[Zz]imanê çînî\|çînî\]\]:?[ ]*?([^\)]+)\)/g, '({{bi-zh|$1}})')
.replace(/=[ ]?Ol[ ]?=/g, '= Dîn =')
.replace(/ olên /g, ' dînên ')
.replace(/(f|F)îz(i|î)?k/g, '$1izîk')
.replace(/\]\]\'(y)?(ê|a)(n)?/g, ']]$1$2$3')
.replace(/[ ]BZ [ ]/g, ' b.z. ')
//meh
.replace(/\b(R|r)(ê|e)bendanê\b/g, 'kanûna paşîn') //rêbendan
.replace(/\b(R|r)(ê|e)bendan\b/g, 'kanûna paşîn') //rêbendan
.replace(/\b(R|r)(ê|e)bendana\b/g, 'kanûna paşîn a') //rêbendan
.replace(/\b(R|r)eşem(i|î)(y)?(ê)?\b/g, 'sibat$4') //reşemî
.replace(/\b(A|a)vrêl(ê)?\b/g, 'nîsan$2') //avrêl
.replace(/\b(P|p)(û|u)şp(e|ê)r(ê)?\b/g, 'hezîran$4') //pûşper
.replace(/\b(G|g)elawêj(ê)?\b/g, 'tebax$2') //gelawêj
.replace(/(R|r)ezber(ê)?/g, 'îlon$2') //rezber
.replace(/(K|k)ewçêra/g, 'çiriya pêşîn a') //kewçêr
.replace(/(K|k)ewçêr(ê?)/g, 'çiriya pêşîn') //kewçêr
.replace(/(S|s)ermawez(ê)?/g, 'çiriya paşîn') //sermawez
.replace(/(S|s)ermaweza/g, 'çiriya paşîn a') //sermawez
.replace(/(M|m)ijdar(ê)?/g, 'çiriya paşîn') //mijdar
.replace(/\b(B|b)erf(e|a)nbar(ê)?\b/g, 'kanûna pêşîn') //berfanbar
.replace(/\b(B|b)erf(e|a)nbara\b/g, 'kanûna pêşîn a') //berfanbar
.replace(/\b(c|C)otmehê?\b/g, 'çiriya pêşîn') //cotmeh
.replace(/\b(c|C)otmeha\b/g, 'çiriya pêşîn a') //cotmeh
.replace(/(ç|Ç)ileya/g, 'kanûna paşîn a')//çile
.replace(/(ç|Ç)ileyê/g, 'kanûna paşîn')//çile
.replace(/(ç|Ç)ile/g, 'kanûna paşîn')//çile
.replace(/(ç|Ç)irî/g, 'çiriya pêşîn')//çile
.replace(/\bÎlon(ê|a)?\b/g, 'îlon$1') //Îlon
.replace(/\bnîsan(ê|a)?\b/g, 'nîsan$1') //Nîsan
.replace(/\bSibat(ê|a)?\b/g, 'sibat$1') //Sibat
.replace(/\bAdar(ê|a)?\b/g, 'adar$1') //Adar
.replace(/\bGulan(ê|a)?\b/g, 'gulan$1') //Gulan
.replace(/\bHezîran(ê|a)?\b/g, 'hezîran$1') //Hezîran
.replace(/\bT(i|î)rmeh(ê|a)?\b/g, 'tîrmeh$2') //tîrmeh
.replace(/\bTebax(ê|a)?\b/g, 'tebax$1') //tebax
.replace(/\[?\[?([\d]+)[']?(ê|î)?[ ]*?([Ss]ibat|[aA]dar|[Nn]îsan|[Gg]ulan|[Hh]ezîran|[Tt]îrmeh|[Tt]ebax|[Îî]lon)ê?a?\]?\]? (\[\[)?([\d]+)(\]\])?(an|a|ê|î)?/g, '{{d|$1|$3|$5}}') //tebax
.replace(/\[?\[?([\d]+)(ê|î)?[ ]*?[ ]*?(kanûna|çiriya)[ ](pêşîn|paşîn)ê?\]?\]?[ ]\[?\[?([\d]+)\]?\]?y?(ê|î|an)?/g, '{{d|$1|$3 $4|$5}}') //tebax
.appendEditSummary('[[Bikarhêner:Balyozxane/templateScript.js|TS]]: sererastkirin')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'wêne',
//forNamespaces: '0',
script: function(editor) {
editor
.replace(/\}\}\[\[Wêne:([^\|]+)([^\]]+)\]\]/g, '|wêne=$1\n|sernavê_wêne=$2}}')
.appendEditSummary('')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'pisule',
//forNamespaces: '0',
script: function(editor) {
editor
.replace(/\{\{[Gg]eographic [Ll]ocation/g, '{{Pisûle')
.replace(/\|[ ]*?Centre[ ]*?=/g, '| Navend =')
.replace(/\|[ ]*?North[ ]*?=/g, '| Bakur =')
.replace(/\|[ ]*?Northeast[ ]*?=/g, '| Bakur rojhilat =')
.replace(/\|[ ]*?East[ ]*?=/g, '| Rojhilat =')
.replace(/\|[ ]*?Southeast[ ]*?=/g, '| Başûr rojhilat =')
.replace(/\|[ ]*?South[ ]*?=/g, '| Başûr =')
.replace(/\|[ ]*?Southwest[ ]*?=/g, '| Başûr rojava =')
.replace(/\|[ ]*?West[ ]*?=/g, '| Rojava =')
.replace(/\|[ ]*?Northwest[ ]*?=/g, '| Bakur rojava =')
.replace(/\|[ ]*?Centre[ ]*?=/g, '| Navend =')
.appendEditSummary('')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'virgulniqte',
//forNamespaces: '0',
script: function(editor) {
editor
.replace(/(\d+),(\d+)/g, '$1virgul$2')
.replace(/(\d+)\.(\d+)/g, '$1niqte$2')
.replace(/(\d+)virgul(\d+)/g, '$1.$2')
.replace(/(\d+)niqte(\d+)/g, '$1,$2')
.appendEditSummary('')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'Gbingehîn',
forNamespaces: '4',
script: function(editor) {
editor
.replace(/''\{\{lgb\|([^\}]+)\}\}''/g, '{{lgb|$1|îtalîk=erê}}')
.appendEditSummary('')
.clickDiff();
}
});
pathoschild.TemplateScript.add([
// add your own templates or scripts here
{
name: 'Rêza kategoriyê',
template: '\n{{Rêza kategoriyê}}',
position: 'after',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +{{[[Şablon:Rêza kategoriyê|Rêza kategoriyê]]}}',
forNamespaces: '0'
},
{
name: 'Giştîdank',
template: '{{Agahîdanka giştî\n}}',
position: 'before',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +{{[[Şablon:Agahîdanka giştî|Agahîdanka giştî]]}}',
forNamespaces: '0'
},
{
name: 'mirov/wd2',
template: '{{Agahîdank mirov/wîkîdane2\n}}',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank mirov/wîkîdane2',
forNamespaces: '0'
},
{
name: 'Mirov',
template: '{{Agahîdank mirov/wîkîdane\n}}',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank mirov/wîkîdane',
forNamespaces: '0'
},
{
name: 'Fîlm',
template: '{{Agahîdank fîlm/wîkîdane\n}}',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank fîlm/wîkîdane',
forNamespaces: '0'
},
{
name: 'Wargeh',
template: '{{Agahîdank wargeh/wîkîdane\n\| welat=\n}}\n',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank wargeh/wîkîdane',
forNamespaces: '0'
},
{
name: 'Welat',
template: '{{Agahîdank welat2/wîkîdane}}\n',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank welat2/wîkîdane',
forNamespaces: '0'
},
{
name: 'Galaksî',
template: '{{Agahîdank galaksî}}\n',
position: 'cursor',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +Agahîdank galaksî',
forNamespaces: '0'
},
{
name: 'otokat',
// template: '{{Otokat}}\n[[en:Category:'+ catjdb + '' + caten + ']]',
template: '{{Otokat}}',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +[[Şablon:Otokat]]',
forNamespaces: '14'
},
{
name: 'navçe-kat',
template: '{{standard-kat}}\n[[Kategorî:Navçeyên Rheinland-Pfalzê]]',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'standard-kat',
template: '{{standard-kat}}\n',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: {{[[Şablon:standard-kat|standard-kat]]}}+',
forNamespaces: '14'
}, {
name: 'jin',
template: '{{subst:Bikarhêner:Balyozxane/kat/jin|1=' + kat + '}}',
position: 'cursor',
accessKey: 'q',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'pîşe',
template: '{{ewkên ewk\n|pîşe=' + kat + '\n|netewe=' + netewe + '\n|dûgel='+ netewe + '\n|serkategorî=\n}}',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'li gorî pîşeyan',
template: '{{netewe/pîşe\n|netewe=' + netewe2 + '\n|dûgel=' + netewe2+ '\n}}',
position: 'cursor',
accessKey: 'e',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'li gorî neteweyan',
template: '{{pîşe/netewe\n|pîşe=' + pise + '\n|gotar=' + pise + '\n|beş=\n}}',
position: 'cursor',
accessKey: 'd',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'wezîrên tirkiye',
template: '{{standard-kat}}\n{{navseasoncats}}\n\n[[Kategorî:Wezîrên Hikûmeta Tirkiyeyê li gorî werçerxan|0]]',
position: 'cursor',
accessKey: 'a',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'şitil kategorî',
template: '{{kategoriya şitilê\n|gotar=' + kategori + '\n|şablon=' + kategori + '-şitil\n|kategorî='+ kategori + '\n}}',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'kontrola otorîteyê',
template: '{{Maintenance category}}\n{{Possibly empty category}}\n{{kategoriya veşartî}}\n\n[[Kategorî:Gotarên bi agahiyên kontrola otorîteyê|'+ katreberaKO+ ']]\n\n[[en:Category:Articles with '+ katreberaKO + ' identifiers]]',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '14'
},
{
name: 'kategoriyên tên teqîpkirin',
template: '== Kategoriyên tên teqîpkirin ==\n* {{ghk|Rûpelên ku ' + sablonbelgeremoved + ' bi parametreyên xelet bi kar tînin}}\n* {{ghk|Rûpelên ku parametreyên ku êdî nayên bikaranîn an jî yên îngilîzî bi kar tînin}}',
position: 'cursor',
accessKey: '',
editSummary: '[[Bikarhêner:Balyozxane/templateScript.js|TS]]: kategorî+',
forNamespaces: '10'
},
]);
pathoschild.TemplateScript.add({
name:'parametre',
forNamespaces: '2',
accessKey: '',
script: function(editor) {
editor
.replace(/\|([^\|]+)\|([^\|]+)/g, '* <code>{{AWB rename template parameter|Agahîdank xwedî meqam|$2|$1}}</code>\n')
.appendEditSummary('[[Bikarhêner:Balyozxane/templateScript.js|TS]]: sererastkirin')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'parametreyên inglîzî',
forNamespaces: '10',
accessKey: '',
script: function(editor) {
editor
.replace(/\| ([^\s]+)([^=]+)=/g, '| $1$2= {{{param|{{{$1|}}}}}}')
.appendEditSummary('[[Bikarhêner:Balyozxane/templateScript.js|TS]]: parametreyan çêke')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'kategoriyê beralî bike',
forNamespaces: '14',
accessKey: '',
script: function(editor) {
editor
.replace(/#BERALÎKIRIN \[\[\:?Kategorî:([^\]]+)\]\]/g, '{{Beralîkirina kategoriyê|$1}}')
.appendEditSummary('[[Bikarhêner:Balyozxane/templateScript.js|TS]]: +{{[[Şablon:Beralîkirina kategoriyê|Beralîkirina kategoriyê]]}}')
.clickDiff();
}
});
pathoschild.TemplateScript.add({
name:'tablo',
forNamespaces: '2',
accessKey: 'q',
script: function(editor) {
editor
.replace(/Kat(.*?)/g, '\|-\n\|Kat$1')
.appendEditSummary('[[Bikarhêner:Balyozxane/templateScript.js|TS]]: tablo')
.clickDiff();
}
});
});
//mw.config.set('userjs-templatescript', { regexEditor: false });
// </nowiki>