User:WOSlinker/comment listings.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
function check_queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) { }
}
return null;
}
if(mw.config.get('wgNamespaceNumber') == 2) {
$( function flagEditButton() {
mw.util.addPortletLink('p-cactions',
mw.util.getUrl(null,{action:'edit',commentlistings:true}),
'comment listings',
'p-commentlistings',
'commentlistings edit');
})
}
if(mw.config.get('wgAction') == 'edit' && check_queryString('commentlistings') == 'true') {
var myContent = document.getElementById('wpTextbox1').value;
myContent = myContent.replace(/(hours|directions|price|checkin|checkout|content)\=([^\|\{\}]*) \|/g,'$1\=<!-- $2 --> \|');
myContent = myContent.replace(/(hours|directions|price|checkin|checkout|content)\=([^\|\{\}]*)\n\|/g,'$1\=<!-- $2 -->\n\|');
myContent = myContent.replace(/(hours|directions|price|checkin|checkout|content)\=([^\|\{\}]*)\}\}/g,'$1\=<!-- $2 -->\n\}\}');
myContent = myContent.replace(/\<\!\-\- *\-\-\>/g,'');
if (myContent != document.getElementById('wpTextbox1').value) {
document.getElementById('wpTextbox1').value=myContent;
document.getElementById('wpSummary').value='comment out listings for translation';
}
}