// <nowiki>
function replace_queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches = re.exec(document.location);
if (matches) {
try {
return decodeURI(matches[1]);
} catch (e) { }
}
return null;
}
//Add a 'replace' tab
if(mw.config.get('wgArticleId') != 0 ) {
$( function replaceEditButton() {
mw.util.addPortletLink('p-cactions',
mw.util.getUrl(null,{action:'edit',replaceedit:true}),
'replace',
'p-replace',
'replace');
}
)}
if(mw.config.get('wgAction') == 'edit' && replace_queryString('replaceedit') == 'true') {
$(function replace() {
var myContent = document.getElementById('wpTextbox1').value;
myContent = myContent.replace(/(row|col)span *\= *(\d+)([^\d]+?)/gi, '$1span="$2"$3');
myContent = myContent.replace(/width *\= *["']? *(\d+\%) *["']? *\|/gi, 'style="width:$1;"|');
/* Cleanup quarry results
myContent = myContent.replace(/_/gi,' ');
myContent = myContent.replace(/\{\| *class\=\"wikitable\"\n\![^\n]+\n/gi,'');
myContent = myContent.replace(/\n\|-\n/gi,'\n');
myContent = myContent.replace(/\n\|\}/gi,'');
myContent = myContent.replace(/\|([#*])/gi,'$1');
myContent = myContent.replace(/|/gi,'|');
*/
if(document.getElementById('wpTextbox1').value != myContent) {
document.getElementById('wpTextbox1').value=myContent;
document.getElementById('wpSummary').value='Update table markup to [[WP:HTML5|HTML5]]';
document.getElementById('wpMinoredit').checked = false;
document.forms.editform.wpDiff.click();
}
}
)}
// </nowiki>