MediaWiki:Common.js: Difference between revisions

undone; it *did in fact work* after bypassing both local and server-side cache; I am still going to leave the Sysop.js code out of the whole process for now, but this is good to know
(final test, based on a proposed solution to this -- inserting Sysop.js code directly into Common.js; worth a try for informational purposes)
(undone; it *did in fact work* after bypassing both local and server-side cache; I am still going to leave the Sysop.js code out of the whole process for now, but this is good to know)
Line 23: Line 23:
   *  Description: Allows for sysop-specific Javascript at [[MediaWiki:Sysop.js]].
   *  Description: Allows for sysop-specific Javascript at [[MediaWiki:Sysop.js]].
   */
   */
function sysopFunctions() {
/*function sysopFunctions() {
     if ( wgUserGroups && !window.disableSysopJS ) {
     if ( wgUserGroups && !window.disableSysopJS ) {
         for ( var g = 0; g < wgUserGroups.length; ++g ) {
         for ( var g = 0; g < wgUserGroups.length; ++g ) {
             if ( wgUserGroups[g] == "sysop" ) {
             if ( wgUserGroups[g] == "sysop" ) {
                if (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Undelete") {
                importScript("MediaWiki:Sysop.js");
    (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 );
    })();
}
                 break;
                 break;
             }
             }
         }
         }
     }
     }
} // this code is currently not working for an unknown reason, and it adds little value for us sysops anyway, so it's inactive for now -- [[User_talk:Iritscen]]
}*/ // this attempt to import the Sysop.js code is currently not working for an unknown reason, although the code from the Sysop.js file can successfully be directly inserted here in place of the importScript command; it is currently my hypothesis that placing Sysop.js in the wrong namespace at first somehow threw off the server, and that, now that it's in the right place, it is still (for some reason) invisible to the software. In any case, WP's version of Sysop.js adds little value for us OG sysops anyway, so I have not inserted its code here. -- [[User_talk:Iritscen]]


addOnloadHook( sysopFunctions ); // be sure to uncomment this if restoring above code
// addOnloadHook( sysopFunctions ); // be sure to uncomment this if restoring above code