MediaWiki:Vector.js: Difference between revisions

instead of using settimeout for 100 miliseconds to enable darkreader and setinterval to wait until the DarkReader variable exists, use jquery promises to wait for each script to load and do things based off of that asynchronously
imported>Smallketchup82
No edit summary
imported>Smallketchup82
(instead of using settimeout for 100 miliseconds to enable darkreader and setinterval to wait until the DarkReader variable exists, use jquery promises to wait for each script to load and do things based off of that asynchronously)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Vector skin */
/* All JavaScript here will be loaded for users of the Vector skin */


// Load embedded dark reader
// Load Scripts
mw.loader.load( '/index.php?title=MediaWiki:Dark.css&action=raw&ctype=text/css', 'text/css' );
mw.loader.getScript( '/index.php?title=MediaWiki:Dark.css&action=raw&ctype=text/css', 'text/css' ).then( // -> Load custom dark css styling first
mw.loader.getScript( '/index.php?title=MediaWiki:DarkReader.js&action=raw&ctype=text/javascript' ).then(
function () {
function () {
DarkReader.setFetchMethod(window.fetch);
mw.loader.getScript( '/index.php?title=MediaWiki:DarkReader.js&action=raw&ctype=text/javascript' ).then( // -> Now load DarkReader to refine our custom dark css styling
DarkReader.enable();
function () {
console.log("Darkreader Enabled!")
DarkReader.setFetchMethod(window.fetch);
DarkReader.enable();
console.log("Darkreader Enabled!");
},
function ( e ) {
mw.log.error( e.message ); // => "Failed to load script"
}
);
     },
     },
     function ( e ) {
     function ( e ) {