Difference between revisions of "User:RJackson/vector.js"

From Team Fortress Wiki
Jump to: navigation, search
(testing dark mode shite)
(dark mood)
Line 4: Line 4:
 
// Im a profeional developer so i must make sure there is no flash of unrotated content
 
// Im a profeional developer so i must make sure there is no flash of unrotated content
 
logo.setAttribute('angleshaha', true);
 
logo.setAttribute('angleshaha', true);
 
  
 
$( function () {
 
$( function () {
 
var darkMode = false;
 
var darkMode = false;
 +
  var $dark_mode_link = $('<li id="pt-darkmode-link"><a href="#">Toggle dark mode</a></li>');
 +
 
 +
  $( '#pt-logout' ).after($dark_mode_link);
  
$( '#pt-darkmode-link a' ).on( 'click', function ( e ) {
+
$dark_mode_link.find( 'a' ).on( 'click', function ( e ) {
 
e.preventDefault();
 
e.preventDefault();
 
darkMode = !darkMode;
 
darkMode = !darkMode;
  
 
$( document.documentElement ).toggleClass( 'client-dark-mode', darkMode );
 
$( document.documentElement ).toggleClass( 'client-dark-mode', darkMode );
$( e.target ).text( mw.msg( darkMode ? 'darkmode-default-link' : 'darkmode-link' ) );
+
$( e.target ).text( darkMode ? 'Turn on the lights' : 'Turn off the lights' );
 
} );
 
} );
 
} );
 
} );

Revision as of 15:38, 3 October 2020

const logo = document.querySelector('.mw-wiki-logo');
logo.style.transform = 'rotate(' + Math.random() * 360 + 'deg)';

// Im a profeional developer so i must make sure there is no flash of unrotated content
logo.setAttribute('angleshaha', true);

$( function () {
	var darkMode = false;
  var $dark_mode_link = $('<li id="pt-darkmode-link"><a href="#">Toggle dark mode</a></li>');
  
  $( '#pt-logout' ).after($dark_mode_link);

	$dark_mode_link.find( 'a' ).on( 'click', function ( e ) {
		e.preventDefault();
		darkMode = !darkMode;

		$( document.documentElement ).toggleClass( 'client-dark-mode', darkMode );
		$( e.target ).text( darkMode ? 'Turn on the lights' : 'Turn off the lights' );
	} );
} );