< User:Frietjes
Browse history interactively ← Previous edit Next edit → Content deleted Content addedInline
Revision as of 14:49, 12 September 2012 view source Frietjes (talk | contribs )Autopatrolled , Extended confirmed users , Template editors 1,000,827 editsm fix issue with not seeing {{collapsible option|state=foo}}← Previous edit
Revision as of 15:47, 10 November 2012 view source Frietjes (talk | contribs )Autopatrolled , Extended confirmed users , Template editors 1,000,827 edits add redirect, CO, to collapsible optionNext edit →
Line 25:
Line 25:
// add collapsible option if it's not there and the state parameter is there
// add collapsible option if it's not there and the state parameter is there
if( myContent.search(/\{\{\{*state/g) >= 0 ) {
if( myContent.search(/\{\{\{*state/g) >= 0 ) {
if( myContent.search(/\{\{*ollapsible+option*(?:\||\}\})/g) < 0 ) {
if( myContent.search(/\{\{*(?: ollapsible+option|O]) *(?:\||\}\})/g) < 0 ) {
myContent = myContent.replace(/(<*noinclude*>)*\n/i, '$1\n{{collapsible option}}\n');
myContent = myContent.replace(/(<*noinclude*>)*\n/i, '$1\n{{collapsible option}}\n');
}
}
if( myContent.search(/\{\{*ollapsible+option*(?:\||\}\})/g) < 0 ) {
if( myContent.search(/\{\{*(?: ollapsible+option|O]) *(?:\||\}\})/g) < 0 ) {
myContent = myContent.replace(/(<*noinclude*>)*/i, '$1\n{{collapsible option}}\n');
myContent = myContent.replace(/(<*noinclude*>)*/i, '$1\n{{collapsible option}}\n');
}
}
Revision as of 15:47, 10 November 2012
if(wgNamespaceNumber != -1) addOnloadHook(TTscriptButton)
function TTscriptButton() {
addPortletLink('p-tb','javascript:collapsibleoptionfunction()','Collapsible option','t-clps');
}
function collapsibleoptionfunction()
{
var myContent = document.getElementById('wpTextbox1').value;
// add state parameter if it's not there
if( myContent.search(/\{\{\{*state/g) < 0 ) {
myContent = myContent.replace(/(\|*state*=)*(*)()/, '$1 \{\{\{state|$2\}\}\}$3');
}
if( myContent.search(/\{\{\{*state/g) < 0 ) {
myContent = myContent.replace(/(\|*?*)(title*=*)/, '$1$2$1state = \{\{\{state|autocollapse\}\}\}|\n');
myContent = myContent.replace(/(\|*state*=*\{\{\{state\|*\}\}\})*\|*(*\|)/, '$1$2');
myContent = myContent.replace(/(\|)*()*\|*?*(state*=*\{\{\{state\|*\}\}\})/, '$1$2$3');
}
if( myContent.search(/\{\{\{*state/g) < 0 ) {
myContent = myContent.replace(/(\|*?*)(name*=*)/, '$1$2$1state = \{\{\{state|autocollapse\}\}\}|\n');
myContent = myContent.replace(/(\|*state*=*\{\{\{state\|*\}\}\})*\|*(*\|)/, '$1$2');
myContent = myContent.replace(/(\|)*()*\|*?*(state*=*\{\{\{state\|*\}\}\})/, '$1$2$3');
}
// add collapsible option if it's not there and the state parameter is there
if( myContent.search(/\{\{\{*state/g) >= 0 ) {
if( myContent.search(/\{\{*(?:ollapsible+option|O])*(?:\||\}\})/g) < 0 ) {
myContent = myContent.replace(/(<*noinclude*>)*\n/i, '$1\n{{collapsible option}}\n');
}
if( myContent.search(/\{\{*(?:ollapsible+option|O])*(?:\||\}\})/g) < 0 ) {
myContent = myContent.replace(/(<*noinclude*>)*/i, '$1\n{{collapsible option}}\n');
}
}
// too much whitespace
myContent = myContent.replace(/(\{\{\{*state\|)+(*)*(\}\}\})/g, '$1$2$3');
myContent = myContent.replace(/(\{\{\{*state\|)*(*)+(\}\}\})/g, '$1$2$3');
// includeonly with collapsed
myContent = myContent.replace(/(\|*state*=*\{\{\{state)\|collapsed(\}\}\})/, '$1<includeonly>|collapsed</includeonly>$2');
myContent = myContent.replace(/(\|*state*=*\{\{\{state)\|<*includeonly*>*collapsed*<*\/*includeonly*>(\}\}\})/i, '$1<includeonly>|collapsed</includeonly>$2');
// includeonly only half inside state
myContent = myContent.replace(/(\{\{\{state*\|*)(<\/includeonly>)(*\}\}\})/, '$1$3$2');
myContent = myContent.replace(/(\{\{\{state*\|*)(<includeonly>)(*\}\}\})/, '$2$1$3');
if(document.getElementById('wpTextbox1').value != myContent) {
document.getElementById('wpTextbox1').value = myContent;
document.getElementById('wpSummary').value = 'adding \{\{collapsible option\}\} and/or \{\{\{state\}\}\}';
}
}
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.
**DISCLAIMER** We are not affiliated with Wikipedia, and Cloudflare.
The information presented on this site is for general informational purposes only and does not constitute medical advice.
You should always have a personal consultation with a healthcare professional before making changes to your diet, medication, or exercise routine.
AI helps with the correspondence in our chat.
We participate in an affiliate program. If you buy something through a link, we may earn a commission 💕
↑