User:WOSlinker/infobox.js

//

function ibox_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 'ibox edit' tab if(mw.config.get('wgArticleId') != 0 ) { $( function iboxEditButton {       mw.util.addPortletLink('p-cactions', mw.util.getUrl(null,{action:'edit',ibox:true}), 'ibox', 'p-ibox', 'ibox edit');   } )}

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

myContent = myContent.replace(/\{\| class\=\"infobox\" style\=\"font-size\: *90\%\;\" *\n\|\+ \'*([\w\d -]*)\'* */i,'{{Infobox GAA championship\n|name           = $1');

myContent = myContent.replace(/\! style\=\"background\: *\#BFD7FF\; text-align\: *center\" colspan\=\"3\" \|[\w\d -]*\n/i,''); myContent = myContent.replace(/\|\- *\n\! style\=\"background\: *\#BFD7FF\; text-align\: *center\" colspan\=\"3\" \|[\w\d -]*\n/i,''); myContent = myContent.replace(/\|\- *\n\! style\=\"background\: *\#BFD7FF\; text-align\: *center\" colspan\=\"3\" \|[\w\d -]*\n/i,'');

myContent = myContent.replace(/\|- *\n\|\'\'\'Dates\'\'\' *\n\|colspan\=\"2\"\| */i,'|date           = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Competitors\'\'\' *\n\|colspan\=\"2\"\| */i,'|num_teams      = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Counties\'\'\' *\n\|colspan\=\"2\"\| */i,'|num_teams      = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Sponsor\'\'\' *\n\|colspan\=\"2\"\| */i,'|sponsor        = ');

myContent = myContent.replace(/\|- *\n\|\'\'\'Winners\'\'\' *\n\|colspan\=\"2\"\| */i,'|winners        = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Captain\'\'\' *\n\|colspan\=\"2\"\| */i,'|captain        = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Manager\'\'\' *\n\|colspan\=\"2\"\| */i,'|manager        = ');

myContent = myContent.replace(/\|- *\n\|\'\'\'Runners-up\'\'\' *\n\|colspan\=\"2\"\| */i,'|runnersup      = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Captain\'\'\' *\|* *\n\|colspan\=\"2\"\| */i,'|runnerupcaptain = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Manager\'\'\' *\n\|colspan\=\"2\"\| */i,'|runnerupmanager = '); myContent = myContent.replace(/\|- *\n\|\'\'\'Matches played\'\'\' *\n\|colspan\=\"2\"\| */i,'|matches        = ');

myContent = myContent.replace(/\n\|\}\n/,'\n}}\n');

if(document.getElementById('wpTextbox1').value != myContent) { document.getElementById('wpTextbox1').value=myContent; document.getElementById('wpSummary').value='use Infobox GAA championship template'; //document.getElementById('wpMinoredit').checked = true; }

} )}

//