Difference between revisions of "MediaWiki:Timeless.js"

From Drawn to Life Wiki
(blanking to test chrome errors)
Tag: Blanking
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the Timeless skin */
 
$(document).ready(function(){
 
  setTimeout(removeLoader, 120); //wait for page load PLUS 0.12 seconds.
 
});
 
function removeLoader(){
 
    $( "#smooth-loader" ).fadeOut(500, function() {
 
      // fadeOut complete. Remove the loading div
 
      $( "#smooth-loader" ).remove(); //makes page more lightweight
 
  }); 
 
}
 
  
 
 
//Wii
 
if ($.inArray("Drawn to Life: The Next Chapter (Wii)", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/WiiBackground1.webp) bottom center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
 
//Level Gates
 
if ($.inArray("Drawn to Life: Two Realms", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/page_bg_raw.jpg) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
if ($.inArray("City Gate", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/City_Wall_Background.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
if ($.inArray("Beach Gate", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/BeachgateBG.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
if ($.inArray("Snow Gate", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/SnowGate_Mountains_Background.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
if ($.inArray("Forest Gate", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/GearWorks_Background.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
//Wife wasteland
 
if ($.inArray("Wilfre's Wasteland", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/WW_Crumbling_Keep_Wallpaper.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
//Galactic Juggle
 
if ($.inArray("Galactic Jungle", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url(https://drawntolife.wiki/w/backgrounds/Galactic_Jungle_Header_Wallpaper.png) top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
//Lavastem
 
if ($.inArray("Lavasteam", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url("https://drawntolife.wiki/w/backgrounds/Lavasteam_Background_(Lighter).jpg") top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
//Watersnog
 
if ($.inArray("Watersong", mw.config.get('wgCategories')) > -1) {
 
    $(function() {
 
        "use strict";
 
        $('#mw-content-container').css('background', 'url("https://drawntolife.wiki/w/backgrounds/Watersong_Background_(Lighter).jpg") top center no-repeat fixed');
 
        $('#mw-content-container').css('background-size', 'cover')
 
    })
 
}
 
 
//Blurry header
 
$(function() {
 
    //caches a jQuery object containing the header element
 
    var header = $("#mw-header-container");
 
    $(window).scroll(function() {
 
        var scroll = $(window).scrollTop();
 
 
        if (scroll >= 200) {
 
            header.addClass("headerblur");
 
        } else {
 
            header.removeClass("headerblur");
 
        }
 
    });
 
});
 
 
(function(){
 
 
  var doc = document.documentElement;
 
  var w = window;
 
 
  var prevScroll = w.scrollY || doc.scrollTop;
 
  var curScroll;
 
  var direction = 0;
 
  var prevDirection = 0;
 
 
  var header = document.getElementById('mw-header-container');
 
 
  var checkScroll = function() {
 
 
    /*
 
    ** Find the direction of scroll
 
    ** 0 - initial, 1 - up, 2 - down
 
    */
 
 
    curScroll = w.scrollY || doc.scrollTop;
 
    if (curScroll > prevScroll) {
 
      //scrolled up
 
      direction = 2;
 
    }
 
    else if (curScroll < prevScroll) {
 
      //scrolled down
 
      direction = 1;
 
    }
 
 
    if (direction !== prevDirection) {
 
      toggleHeader(direction, curScroll);
 
    }
 
   
 
    prevScroll = curScroll;
 
  };
 
 
  var toggleHeader = function(direction, curScroll) {
 
    if (direction === 2 && curScroll > 52) {
 
     
 
      //replace 52 with the height of your header in px
 
 
      header.classList.add('hide');
 
      prevDirection = direction;
 
    }
 
    else if (direction === 1) {
 
      header.classList.remove('hide');
 
      prevDirection = direction;
 
    }
 
  };
 
 
 
  window.addEventListener('scroll', checkScroll);
 
 
})();
 

Revision as of 04:17, 23 June 2022