MediaWiki:Sysop.js

From XentaxWiki
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button. Firefox: hold down the Shift key while clicking Reload (or press Ctrl-Shift-R). Konqueror and Safari users can just click the Reload button. For details and instructions about other browsers, see wikipedia:Wikipedia:Bypass your cache.

//<syntaxhighlight lang="JavaScript">
 
 
 /** Creates a button to invert checkboxes on Special:Undelete */
 if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Undelete") {
     (function () {
         var form             = document.forms["undelete"];
         if( !form ) {
             return;
         }
         var elements         = form.elements;
         var submitButton     = elements["mw-undelete-submit"];
         if( !submitButton ) {
             return;
         }
         var toggleButton     = document.createElement("input");
         toggleButton.type    = "button";
         toggleButton.value   = "Invert selection";
 
         toggleButton.onclick = function () {
                 for( var i = 0; i < elements.length; ++i ) {
                     var input = elements[i];
                     if( input.type != "checkbox" ) {
                         continue;
                     }
                     input.checked = !input.checked;
                 }
             };
         submitButton.parentNode.insertBefore( toggleButton, submitButton );
     })();
 }

/*******************************************************
 *
 * blanks the "Other/additional reason" field when
 * deleting pages so we don't get stupid vandalism and
 * spam and whatnot preserved for posterity in the
 * delete log
 */
addOnloadHook(function() {
if ( wgAction == 'delete' && ( document.getElementById('wpReason').value.indexOf('content was: "') == 0
     || document.getElementById('wpReason').value.indexOf('content before blanking was: "') == 0 ) ) { 
    document.getElementById('wpReason').value = '';
}
})

//</syntaxhighlight>