MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 428: Line 428:
     $('#dark-mode-switch').click(function () {
     $('#dark-mode-switch').click(function () {
         var timestamp = new Date().getTime();
         var timestamp = new Date().getTime();
        $(this).after('<div class="dark-mode-notif" data-state="'+ $('body').hasClass('dark-mode') ? 'off' : 'on' +'"></div>');
         $('body').toggleClass('dark-mode');
         $('body').toggleClass('dark-mode');
         var otherNotif = $('.dark-mode-notif:not([data-time="'+timestamp+'"])');
         var otherNotif = $('.dark-mode-notif:not(eq(0))');
         otherNotif.remove();
         otherNotif.remove();
        matchHeaderText(true);
         var notif = $('.dark-mode-notif:eq(0)');
        if ($('body').hasClass('dark-mode')) {
            setCookie('elwiki-dark-mode', 'true');
            $(this).after('<div class="dark-mode-notif" data-state="on" data-time="'+timestamp+'"></div>');
        } else {
            setCookie('elwiki-dark-mode', 'true');
            $(this).after('<div class="dark-mode-notif" data-state="off" data-time="'+timestamp+'"></div>');
        }
         var notif = $('.dark-mode-notif[data-time="'+timestamp+'"]');
         notif.show();
         notif.show();
         setTimeout(function(){
         setTimeout(function(){
Line 447: Line 440:
             }, 300);
             }, 300);
         }, 3000);
         }, 3000);
        matchHeaderText(true);
        if ($('body').hasClass('dark-mode')) {
            setCookie('elwiki-dark-mode', 'true');
        } else {
            setCookie('elwiki-dark-mode', 'false');
        }
       
     });
     });