Misplaced Pages

:AutoEd/core.js: Difference between revisions - Misplaced Pages

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< Misplaced Pages:AutoEd Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 20:28, 28 April 2009 view sourceAFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 editsm Changed protection level for "Misplaced Pages:AutoEd/core.js": Fully deploying script; full protection. If you have any requests, please use WT:AutoEd and I'll see them ( (indefinite) (indefinite))← Previous edit Revision as of 22:55, 28 April 2009 view source AFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 edits AutoEdSummaryAddNext edit →
Line 12: Line 12:
// Add a tag to the summary box // Add a tag to the summary box
var txt = document.editform.wpSummary; var txt = document.editform.wpSummary;
var summary = "Cleaned up using ]"; var summary = "Cleaned up using ] (" + AutoEdSummaryAdd + ")";
if (txt.value.indexOf(summary) == -1) { if (txt.value.indexOf(summary) == -1) {
if (txt.value.match(/?\s*$/)) { if (txt.value.match(/?\s*$/)) {
Line 28: Line 28:
if(!txt) return; if(!txt) return;
autoEdFunctions(); autoEdFunctions();
document.getElementById('wpSummary').value += 'Cleaned up using ]'; document.getElementById('wpSummary').value += 'Cleaned up using ] (" + AutoEdSummaryAdd + ")";
document.editform.wpMinoredit.checked = autoEdMinor; document.editform.wpMinoredit.checked = autoEdMinor;
document.editform.wpDiff.click() document.editform.wpDiff.click()

Revision as of 22:55, 28 April 2009

//

//This script does not function without additional "helper" modules!
//Please see ] for details on use.
if( typeof( autoEdMinor ) == 'undefined' ) { //CONFIGURATION
    autoEdMinor = true;
}
function AutoEdFromEdit() { //Initiates AutoEd if you are already in edit mode
    autoEdFunctions();
    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "Cleaned up using ] (" + AutoEdSummaryAdd + ")";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
    document.editform.wpMinoredit.checked = autoEdMinor;
    document.editform.wpDiff.click()
}
if(queryString('AutoEdFromView')) addOnloadHook(function() { AutoEdFromView(); }) //Part of next function
function AutoEdFromView() { //Initiates AutoEd if you are viewing the article without currently editing it
    var txt = document.getElementById('wpTextbox1');
    if(!txt) return;
    autoEdFunctions();
    document.getElementById('wpSummary').value += 'Cleaned up using ] (" + AutoEdSummaryAdd + ")";
    document.editform.wpMinoredit.checked = autoEdMinor;
    document.editform.wpDiff.click()
}
function queryString(p) { //Allows URI to be properly decoded so that AutoEdFromView() works properly
    var re = RegExp('' + p + '=(*)');
    var matches;
    if (matches = re.exec(document.location)) {
        try {
            return decodeURI(matches);
        } catch (e) {
        }
    }
    return null;
}
addOnloadHook(function () { //Adds "auto ed" tabs to page.
    if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "Image" || wgCanonicalNamespace == "File" || wgCanonicalNamespace == "User" || wgCanonicalNamespace == "Template" || wgCanonicalNamespace == "Project" || wgCanonicalNamespace == "Portal"){
        if(document.forms.editform) {
            addPortletLink('p-cactions', 'javascript:AutoEdFromEdit()', 'auto ed', 'ca-AutoEd', 'Run AutoEd', '', document.getElementById('ca-move'));
        } //End editform if
        if(wgAction == "view"){
             var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit';
             addPortletLink('p-cactions',url + '&AutoEdFromView=true', 'auto ed','ca-AutoEd', 'Run AutoEd', '', document.getElementById('ca-move'));
        } //End pageview if
    }//End namespace if
});
//