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 21:15, 29 April 2009 view sourceAFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 edits Copy from User:Plastikspork/AutoEd/core.js per request at WT:AutoEd← Previous edit Revision as of 21:32, 1 May 2009 view source AFigureOfBlue (talk | contribs)Edit filter managers, Administrators53,878 editsm Should fix an errorNext edit →
Line 16: Line 16:
} }


if( typeof( autoEdHover ) == 'undefined' ) { if( typeof( autoEdLinkHover ) == 'undefined' ) {
autoEdLinkHover = "Run AutoEd"; autoEdLinkHover = "Run AutoEd";
} }


if( typeof( autoEdLink ) == 'undefined' ) { if( typeof( autoEdLinkName ) == 'undefined' ) {
autoEdLinkName = "auto ed"; autoEdLinkName = "auto ed";
} }

Revision as of 21:32, 1 May 2009

//

//This script does not function without additional "helper" modules!
//Please see ] for details on use.
// Set default values for any unset variables
if( typeof( autoEdMinor ) == 'undefined' ) {
  autoEdMinor = true;
}
if( typeof( autoEdClick ) == 'undefined' ) {
  autoEdClick = true;
}
if( typeof( autoEdTag ) == 'undefined' ) {
  autoEdTag = "Cleaned up using ]";
}
if( typeof( autoEdLinkHover ) == 'undefined' ) {
  autoEdLinkHover = "Run AutoEd";
}
if( typeof( autoEdLinkName ) == 'undefined' ) {
  autoEdLinkName = "auto ed";
}
if( typeof( autoEdLinkLocation ) == 'undefined' ) {
  autoEdLinkLocation = "p-cactions";
}
if( typeof( autoEdFunctions ) == 'undefined' ) {
  function autoEdFunctions() { alert('AutoEd/core.js: autoEdFunctions is undefined'); }
  autoEdTag = "";
  autoEdClick = false;
  autoEdMinor = false;
}
//Initiates AutoEd
function autoEdExecute() {
  if(!document.getElementById('wpTextbox1')) return;
  autoEdFunctions();
  autoEdEditSummary();
}
//Adds Tag to edit summary textbox
function autoEdEditSummary() {
  var txt = document.editform.wpSummary;
  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( autoEdMinor ) {
    document.editform.wpMinoredit.checked = autoEdMinor;
  }
  // Click 'Show changes'
  if( autoEdClick ) {
    document.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(document.location)) {
    try {
      return decodeURI(matches);
    } catch (e) {
    }
  }
  return null;
}
//Execute AutoEd after call from View Mode
if( autoEdQueryString('AutoEd') ) {
  addOnloadHook(function() { 
    autoEdExecute();
  });
}
// Add "auto ed" tabs and associate with actions
addOnloadHook(function () {
  if(wgCanonicalNamespace == "" || wgCanonicalNamespace == "Image" ||  wgCanonicalNamespace == "File" || wgCanonicalNamespace == "User"
       || wgCanonicalNamespace == "Template" || wgCanonicalNamespace == "Project" || wgCanonicalNamespace == "Portal") {
    if(document.forms.editform) {
      addPortletLink( autoEdLinkLocation, 'javascript:autoEdExecute()', autoEdLinkName, 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move'));
    } //End editform if
    if(wgAction == "view"){
      var url = wgServer + wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=edit';
      addPortletLink( autoEdLinkLocation, url + '&AutoEd=true', autoEdLinkName, 'ca-AutoEd', autoEdLinkHover, '', document.getElementById('ca-move'));
    } //End pageview if
  } //End namespace if
});
//