User:WOSlinker/age.js

function age_queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }   return null; }

//Add a 'age edit' tab if(mw.config.get('wgArticleId') != 0 ) { $( function ageEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',age:true}), 'age', 'p-age', 'age edit');   } )}

if(mw.config.get('wgAction') == 'edit' && age_queryString('age') == 'true') { $(function age {       var myContent = document.getElementById('wpTextbox1').value;

myContent = myContent.replace(/(\| *birth_date *\=) *January *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 January undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *February *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 February undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *March *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 March undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *April *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 April undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *May *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 May undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *June *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 June undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *July *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 July undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *August *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 August undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *September *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 September undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *October *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 October undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *November *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 November undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *December *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 December undefined\n');

myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *January *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 January undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *February *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 February undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *March *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 March undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *April *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 April undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *May *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 May undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *June *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 June undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *July *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 July undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *August *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 August undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *September *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 September undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *October *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 October undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *November *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 November undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *December *(\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 December undefined\n');

myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *January *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 January undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *February *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 February undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *March *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 March undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *April *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 April undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *May *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 May undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *June *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 June undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *July *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 July undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *August *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 August undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *September *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 September undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *October *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 October undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *November *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 November undefined\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *December *(\d\d\d\d) *\ *\([Aa]ged? \d*\) *\n/,'$1 December undefined\n');

myContent = myContent.replace(/(\| *birth_date *\=) *January *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 January undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *February *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 February undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *March *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 March undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *April *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 April undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *May *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 May undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *June *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 June undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *July *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 July undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *August *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 August undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *September *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 September undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *October *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 October undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *November *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 November undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *December *(\d\d?)\,? *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 December undefined<');

myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *January *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 January undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *February *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 February undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *March *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 March undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *April *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 April undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *May *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 May undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *June *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 June undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *July *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 July undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *August *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 August undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *September *(\d\d\d\d) *\([Aa]ged? \d*\) *\</,'$1 September undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *October *(\d\d\d\d) *\([Aa]ged? \d*\) *\ *\([Aa]ged? \d*\) *\ *\([Aa]ged? \d*\) *\ *\([Aa]ged? \d*\) *\ *\([Aa]ged? \d*\) *\</,'$1 April undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *May *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 May undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *June *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 June undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *July *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 July undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *August *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 August undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *September *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 September undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *October *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 October undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *November *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 November undefined<'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d?) *December *(\d\d\d\d) *\<br\/?\> *\([Aa]ged? \d*\) *\</,'$1 December undefined<');

myContent = myContent.replace(/(\| *birth_date *\=) *(January *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(February *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(March *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(April *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(May *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(June *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(July *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(August *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(September *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(October *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(November *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(December *\d\d\d\d) *\([Aa]ged? \d*\) *\n/,'$1 $2\n');

myContent = myContent.replace(/(\| *birth_date *\=) *(January *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(February *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(March *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(April *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(May *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(June *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(July *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(August *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(September *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(October *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(November *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n'); myContent = myContent.replace(/(\| *birth_date *\=) *(December *\d\d\d\d) *\([Aa]ged? \{\{[Aa]ge\|\d*\|\d*\|1\}\}\) *\n/,'$1 $2\n');

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='use birth date and age template'; document.getElementById('wpMinoredit').checked = true; }

if(document.getElementById('wpTextbox1').value == myContent) { myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d\d\d) *\([Aa]ged? [\d-–—\/ or]*\) *\n/,'$1 \n'); myContent = myContent.replace(/(\| *birth_date *\=) *(\d\d\d\d) *\([Aa]ged? [\d-–—\/ or]*\) *\</,'$1 <');

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='use birth year and age template'; document.getElementById('wpMinoredit').checked = true; }

}

} )}