$(function(){ function isMobile(){ var userAgentInfo = navigator.userAgent; var mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for(var i = 0; i < mobileAgents.length; i ++){ if (userAgentInfo.indexOf(mobileAgents[i]) != -1) { return true; } } return false; } function initBackgroundImage(params){ let bgImg = new isekai.BgImage(); let bgImgElement = $('body').append('
').find('div.isekai-bgimg:last'); bgImg.addViewport(bgImgElement); bgImg.addBlurBackground($('#mw-panel .portal')); bgImg.addBlurBackground($('#p-personal')); bgImg.addBlurBackground($('#footer')); bgImg.addBlurBackground($('#left-navigation')); bgImg.addBlurBackground($('#right-navigation')); bgImg.addBlurBackground($('#content')); if(!('xcenter' in params)){ params.xcenter = 50; } if(!('ycenter' in params)){ params.ycenter = 50; } bgImg.loadImage(params.src, params.xcenter, params.ycenter); } var showBackgroundWidget = true; if(isMobile() && !mw.user.options.get('isekai-bgimg-visible-mobile', true)){ showBackgroundWidget = false; } else if(!mw.user.options.get('isekai-bgimg-visible-desktop', true)) { showBackgroundWidget = false; } if(showBackgroundWidget){ var params = mw.config.get('isekaiBackgroundWidgetData'); if(params && params.src){ $('body').addClass('has-bgimg'); if(window.requestAnimationFrame){ window.requestAnimationFrame(function(){ initBackgroundImage(params); }); } else { setTimeout(function(){ initBackgroundImage(params); }, 0); } } else { console.log(mw.message('isekai-background-widget-param-error').parse(), params); } } });