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 22:24, 27 April 2009 view sourceAFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 edits Remove unneeded← Previous edit Revision as of 22:28, 27 April 2009 view source AFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 edits CodeFixer → EasyEdNext edit →
Line 1: Line 1:
// <pre> // <pre>
if( typeof( codefixerMinor ) == 'undefined' ) { //CONFIGURATION if( typeof( easyEdMinor ) == 'undefined' ) { //CONFIGURATION
codefixerMinor = true; easyEdMinor = true;
} }
Line 12: Line 12:
} }
function codefixerstartinedit() { //Initiates CodeFixer if you are already in edit mode function easyedinedit() { //Initiates EasyEd if you are already in edit mode
codefixer(); codefixer();
Line 25: Line 25:
} }
document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpMinoredit.checked = easyEdMinor;
document.editform.wpDiff.click() document.editform.wpDiff.click()
} }
if(queryString('codefixerstartfromview')) addOnloadHook(function() { codefixerstartfromview(); }) //Part of next function if(queryString('easyedfromview')) addOnloadHook(function() { easyedfromview(); }) //Part of next function
function codefixerstartfromview() { //Initiates CodeFixer if you are viewing the article without currently editing it function easyedfromview() { //Initiates EasyEd if you are viewing the article without currently editing it
var txt = document.getElementById('wpTextbox1'); var txt = document.getElementById('wpTextbox1');
if(!txt) return; if(!txt) return;
codefixer(); codefixer();
document.getElementById('wpSummary').value += 'Code cleaned up using ]'; document.getElementById('wpSummary').value += 'Code cleaned up using ]';
document.editform.wpMinoredit.checked = codefixerMinor; document.editform.wpMinoredit.checked = easyEdMinor;
document.editform.wpDiff.click() document.editform.wpDiff.click()
} }
function queryString(p) { //Allows URI to be properly decoded so that codefixerstartfromview() works properly function queryString(p) { //Allows URI to be properly decoded so that easyedfromview() works properly
var re = RegExp('' + p + '=(*)'); var re = RegExp('' + p + '=(*)');
var matches; var matches;
Line 51: Line 51:
} }
addOnloadHook(function () { //Adds "fix code" and "fix code (+)" tabs to page. addOnloadHook(function () { //Adds "easy ed" tabs to page.
if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "Image" || wgCanonicalNamespace == "File" || wgCanonicalNamespace == "User" || wgCanonicalNamespace == "Template" || wgCanonicalNamespace == "Project" || wgCanonicalNamespace == "Portal"){ if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "Image" || wgCanonicalNamespace == "File" || wgCanonicalNamespace == "User" || wgCanonicalNamespace == "Template" || wgCanonicalNamespace == "Project" || wgCanonicalNamespace == "Portal"){
if(document.forms.editform) { if(document.forms.editform) {
addPortletLink('p-cactions', 'javascript:codefixerstartinedit()', 'fix code', 'ca-codefixeredit', 'Cleans up common errors in code and syntax', '', document.getElementById('ca-move')); addPortletLink('p-cactions', 'javascript:easyedinedit()', 'easy ed', 'ca-easyed', 'Run EasyEd', '', document.getElementById('ca-move'));
} //End editform if } //End editform if
if(wgAction == "view"){ if(wgAction == "view"){
var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit'; var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit';
addPortletLink('p-cactions',url + '&codefixerstartfromview=true', 'fix code','ca-codefixerview', 'Cleans up common errors in code and syntax', '', document.getElementById('ca-move')); addPortletLink('p-cactions',url + '&easyedfromview=true', 'easy ed','ca-easyed', 'Run EasyEd', '', document.getElementById('ca-move'));
} //End pageview if } //End pageview if
}//End namespace if }//End namespace if

Revision as of 22:28, 27 April 2009

//

 
if( typeof( easyEdMinor ) == 'undefined' ) { //CONFIGURATION
	easyEdMinor = true;
}
function codefixer() { //MAIN FUNCTION describes list of fixes
    var txt = document.editform.wpTextbox1;
    var page_name = wgPageName.replace('_',' ');
    txt.value = txt.value.replace(new RegExp('ISBN-10:|ISBN-13:|ISBN-10|ISBN-13|ISBN:', 'gi'), 'ISBN');
}
function easyedinedit() { //Initiates EasyEd if you are already in edit mode
    codefixer();
    // Add a tag to the summary box
    var txt = document.editform.wpSummary;
    var summary = "Code cleaned up using ]";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
    document.editform.wpMinoredit.checked = easyEdMinor;
    document.editform.wpDiff.click()
}
if(queryString('easyedfromview')) addOnloadHook(function() { easyedfromview(); }) //Part of next function
function easyedfromview() { //Initiates EasyEd if you are viewing the article without currently editing it
  var txt = document.getElementById('wpTextbox1');
  if(!txt) return;
  codefixer();
  document.getElementById('wpSummary').value += 'Code cleaned up using ]';
    document.editform.wpMinoredit.checked = easyEdMinor;
    document.editform.wpDiff.click()
}
function queryString(p) { //Allows URI to be properly decoded so that easyedfromview() 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 "easy 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:easyedinedit()', 'easy ed', 'ca-easyed', 'Run EasyEd', '', document.getElementById('ca-move'));
        } //End editform if
        if(wgAction == "view"){
             var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit';
             addPortletLink('p-cactions',url + '&easyedfromview=true', 'easy ed','ca-easyed', 'Run EasyEd', '', document.getElementById('ca-move'));
        } //End pageview if
    }//End namespace if
});
//