Difference between revisions of "MediaWiki:Timeless.js"

From Drawn to Life Wiki
Line 65: Line 65:
  
  
−
var didScroll = false;
+
window.onscroll = function() {scrollFunction()};
  
−
$(window).scroll(function() {
+
function scrollFunction() {
−
    didScroll = true;
+
  if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
−
});
+
     document.getElementById("mw-header-container").style.background = "white";
−
 
+
  } else {
−
setInterval(function() {
+
    document.getElementById("mw-header-container").style.background = "black";
−
     if ( didScroll ) {
+
  }
−
        didScroll = false;
+
}
−
        var $el;
 
−
 
 
−
        //Same that all the if else statements
 
−
        switch (true) {
 
−
            case (scroll >= 100):
 
−
                $el = $('#mw-header-container');
 
−
                break;
 
−
 
 
−
        }
 
−
        $el.addClass('headerblur');
 
−
    }
 
−
}, 50);
 

Revision as of 06:23, 29 May 2021

/* All JavaScript here will be loaded for users of the Timeless skin */
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')
    })
}
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')
    })
}
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')
    })
}
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')
    })
}
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')
    })
}


window.onscroll = function() {scrollFunction()};

function scrollFunction() {
  if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
    document.getElementById("mw-header-container").style.background = "white";
  } else {
    document.getElementById("mw-header-container").style.background = "black";
  }
}