Revision as of 15:24, 8 July 2014 view sourceNihiltres (talk | contribs)Edit filter managers, Administrators83,813 edits Wrapped wg* variables with mw.config.get("")← Previous edit | Revision as of 20:56, 8 July 2014 view source Krinkle (talk | contribs)Extended confirmed users, Pending changes reviewers, Rollbackers5,472 edits Clean up: typeof is an operator, not a function; use location and .href instead of doc.location; Use decodeURIComponent instead of decodeURI (match encodeURIComponent)Next edit → | ||
Line 2: | Line 2: | ||
//This script does not function without additional "helper" modules! | //This script does not function without additional "helper" modules! | ||
//Please see ] for details on use. | //Please see ] for details on use. | ||
//Initiates AutoEd | //Initiates AutoEd | ||
function autoEdExecute() { | function autoEdExecute() { | ||
if(!document.getElementById('wpTextbox1')) return; | if(!document.getElementById('wpTextbox1')) return; | ||
// copy wikEd (]) frame to wpTextbox1 textarea | // copy wikEd (]) frame to wpTextbox1 textarea | ||
// for compatibility with WikiEd | // for compatibility with WikiEd | ||
if (typeof |
if (typeof wikEdUseWikEd != 'undefined') { | ||
if (wikEdUseWikEd == true) { | if (wikEdUseWikEd == true) { | ||
WikEdUpdateTextarea(); | WikEdUpdateTextarea(); | ||
} | } | ||
} | } | ||
//alert/return if autoEdFunctions is not defined | //alert/return if autoEdFunctions is not defined | ||
if( typeof |
if( typeof autoEdFunctions == 'undefined' ) { | ||
alert('AutoEd/core.js: autoEdFunctions is undefined'); | alert('AutoEd/core.js: autoEdFunctions is undefined'); | ||
return; | return; | ||
} | } | ||
autoEdFunctions(); | autoEdFunctions(); | ||
autoEdEditSummary(); | autoEdEditSummary(); | ||
// copy wpTextbox1 textarea back to wikEd frame | // copy wpTextbox1 textarea back to wikEd frame | ||
// for compatibility with WikiEd | // for compatibility with WikiEd | ||
if (typeof |
if (typeof wikEdUseWikEd != 'undefined') { | ||
if (wikEdUseWikEd == true) { | if (wikEdUseWikEd == true) { | ||
WikEdUpdateFrame(); | WikEdUpdateFrame(); | ||
Line 32: | Line 32: | ||
} | } | ||
} | } | ||
//Adds Tag to edit summary textbox | //Adds Tag to edit summary textbox | ||
function autoEdEditSummary() { | function autoEdEditSummary() { | ||
var txt = document.forms.editform.wpSummary; | var txt = document.forms.editform.wpSummary; | ||
if( typeof |
if( typeof autoEdTag == 'undefined' ) { | ||
var tag = "Cleaned up using ]"; | var tag = "Cleaned up using ]"; | ||
} else { | } else { | ||
var tag = autoEdTag; | var tag = autoEdTag; | ||
} | } | ||
// Is the tag blank? | // Is the tag blank? | ||
if( tag.match(//) ) { | if( tag.match(//) ) { | ||
Line 55: | Line 55: | ||
} | } | ||
} | } | ||
// Check 'This is a minor edit' | // Check 'This is a minor edit' | ||
if( typeof |
if( typeof autoEdMinor == 'undefined' || autoEdMinor ) { | ||
document.forms.editform.wpMinoredit.checked = true; | document.forms.editform.wpMinoredit.checked = true; | ||
} | } | ||
// Click 'Show changes' | // Click 'Show changes' | ||
if( typeof |
if( typeof autoEdClick == 'undefined' || autoEdClick ) { | ||
document.forms.editform.wpDiff.click(); | document.forms.editform.wpDiff.click(); | ||
} | } | ||
} | } | ||
//Allows URI to be properly decoded for AutoEd in View Mode |
//Allows URI to be properly decoded for AutoEd in View Mode | ||
function autoEdQueryString(p) { | function autoEdQueryString(p) { | ||
var re = RegExp('' + p + '=(*)'); | var re = RegExp('' + p + '=(*)'); | ||
var matches; | var matches; | ||
if (matches = re.exec( |
if (matches = re.exec(location.href)) { | ||
try { | try { | ||
return |
return decodeURIComponent(matches); | ||
} catch (e) { | } catch (e) { | ||
} | } | ||
Line 79: | Line 79: | ||
return null; | return null; | ||
} | } | ||
// Add "auto ed" tab and associate with actions | // Add "auto ed" tab and associate with actions | ||
addOnloadHook(function () { | addOnloadHook(function () { | ||
//Execute AutoEd after call from "view mode" | //Execute AutoEd after call from "view mode" | ||
if( autoEdQueryString('AutoEd') ) { | if( autoEdQueryString('AutoEd') ) { | ||
autoEdExecute(); | autoEdExecute(); | ||
} | } | ||
// Set default values for any unset variables | // Set default values for any unset variables | ||
if( typeof |
if( typeof autoEdLinkHover == 'undefined' ) { | ||
autoEdLinkHover = "Run AutoEd"; | autoEdLinkHover = "Run AutoEd"; | ||
} | } | ||
if( typeof |
if( typeof autoEdLinkName == 'undefined' ) { | ||
autoEdLinkName = "auto ed"; | autoEdLinkName = "auto ed"; | ||
} | } | ||
if( typeof |
if( typeof autoEdLinkLocation == 'undefined' ) { | ||
autoEdLinkLocation = "p-cactions"; | autoEdLinkLocation = "p-cactions"; | ||
} | } | ||
//Add the "auto ed" tab | //Add the "auto ed" tab | ||
if( typeof |
if( typeof document.forms.editform != 'undefined' ) { | ||
addPortletLink( autoEdLinkLocation, 'javascript:autoEdExecute()', autoEdLinkName, |
addPortletLink( autoEdLinkLocation, 'javascript:autoEdExecute()', autoEdLinkName, | ||
'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); | 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); | ||
} else if (mw.config.get("wgIsArticle") && document.getElementById('ca-edit') && mw.config.get("wgAction") == "view") { | } else if (mw.config.get("wgIsArticle") && document.getElementById('ca-edit') && mw.config.get("wgAction") == "view") { | ||
var url = mw.config.get("wgServer") + mw.config.get("wgScript") + '?title=' + encodeURIComponent(mw.config.get("wgPageName")) + '&action=edit'; | var url = mw.config.get("wgServer") + mw.config.get("wgScript") + '?title=' + encodeURIComponent(mw.config.get("wgPageName")) + '&action=edit'; | ||
addPortletLink( autoEdLinkLocation, url + '&AutoEd=true', autoEdLinkName, |
addPortletLink( autoEdLinkLocation, url + '&AutoEd=true', autoEdLinkName, | ||
'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); | 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); | ||
} //End view-mode/edit-mode if | } //End view-mode/edit-mode if | ||
}); | }); | ||
//</source> | //</source> |
Revision as of 20:56, 8 July 2014
//
//This script does not function without additional "helper" modules! //Please see ] for details on use. //Initiates AutoEd function autoEdExecute() { if(!document.getElementById('wpTextbox1')) return; // copy wikEd (]) frame to wpTextbox1 textarea // for compatibility with WikiEd if (typeof wikEdUseWikEd != 'undefined') { if (wikEdUseWikEd == true) { WikEdUpdateTextarea(); } } //alert/return if autoEdFunctions is not defined if( typeof autoEdFunctions == 'undefined' ) { alert('AutoEd/core.js: autoEdFunctions is undefined'); return; } autoEdFunctions(); autoEdEditSummary(); // copy wpTextbox1 textarea back to wikEd frame // for compatibility with WikiEd if (typeof wikEdUseWikEd != 'undefined') { if (wikEdUseWikEd == true) { WikEdUpdateFrame(); } } } //Adds Tag to edit summary textbox function autoEdEditSummary() { var txt = document.forms.editform.wpSummary; if( typeof autoEdTag == 'undefined' ) { var tag = "Cleaned up using ]"; } else { var tag = autoEdTag; } // Is the tag blank? if( tag.match(//) ) { // Has it already been tagged? if( txt.value.indexOf(tag) == -1 ) { // Append a pipe if necessary if( txt.value.match(/?\s*$/) ) { txt.value += " | "; } // Append our tag txt.value += tag; } } // Check 'This is a minor edit' if( typeof autoEdMinor == 'undefined' || autoEdMinor ) { document.forms.editform.wpMinoredit.checked = true; } // Click 'Show changes' if( typeof autoEdClick == 'undefined' || autoEdClick ) { document.forms.editform.wpDiff.click(); } } //Allows URI to be properly decoded for AutoEd in View Mode function autoEdQueryString(p) { var re = RegExp('' + p + '=(*)'); var matches; if (matches = re.exec(location.href)) { try { return decodeURIComponent(matches); } catch (e) { } } return null; } // Add "auto ed" tab and associate with actions addOnloadHook(function () { //Execute AutoEd after call from "view mode" if( autoEdQueryString('AutoEd') ) { autoEdExecute(); } // Set default values for any unset variables if( typeof autoEdLinkHover == 'undefined' ) { autoEdLinkHover = "Run AutoEd"; } if( typeof autoEdLinkName == 'undefined' ) { autoEdLinkName = "auto ed"; } if( typeof autoEdLinkLocation == 'undefined' ) { autoEdLinkLocation = "p-cactions"; } //Add the "auto ed" tab if( typeof document.forms.editform != 'undefined' ) { addPortletLink( autoEdLinkLocation, 'javascript:autoEdExecute()', autoEdLinkName, 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); } else if (mw.config.get("wgIsArticle") && document.getElementById('ca-edit') && mw.config.get("wgAction") == "view") { var url = mw.config.get("wgServer") + mw.config.get("wgScript") + '?title=' + encodeURIComponent(mw.config.get("wgPageName")) + '&action=edit'; addPortletLink( autoEdLinkLocation, url + '&AutoEd=true', autoEdLinkName, 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move')); } //End view-mode/edit-mode if }); //