Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Remove mascot class from element "main" if its width is <= mascotMinWidth */
- function controlMascot(mascot, mascotMinWidth) {
- $(window).resize(function(event) {
- if ( $(window).width() <= mascotMinWidth && $("main").hasClass("mascot") ) {
- removeMascot();
- } else if( $(window).width() > mascotMinWidth && ! $("main").hasClass("mascot") ) {
- setMascot(mascot);
- }
- });
- }
- function setMascot(mascot) {
- $('main').addClass("mascot");
- $('main').css("background-image", "url(" + mascot + ")");
- $('main').removeClass("plain");
- }
- function removeMascot() {
- $('main').removeClass("mascot");
- $('main').css("background-image", "");
- $('main').addClass("plain");
- }
- $(document).ready(function(event) {
- var mascotEnable = true;
- var mascotPath = "images/mascots/"
- var mascotList = ['kurisu.png', 'kido.png', 'ruri3.png', 'ruri1.png', 'ruri2.png', 'ruri.png', 'nadeko.png', 'amakusa.png', 'hitagi.png', 'hitagi1.png', 'hitagi2.png', 'hitagi3.png', 'hitagi4.png', 'mio.png', 'nichijou.png', 'saber.png', 'Hanako.png', 'Kirino.png', 'Kuroneko.png', 'kurumu.png', 'misaka.png', 'yuno.png' ];
- var mascot = mascotPath + mascotList[Math.floor(Math.random() * mascotList.length)];
- var mascotMinWidth = '750';
- if ( mascotEnable ) {
- setMascot(mascot);
- controlMascot(mascot, mascotMinWidth);
- } else { removeMascot(); }
- });
Advertisement
Add Comment
Please, Sign In to add comment