noname/game/background.js

66 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-05-11 11:57:44 +00:00
'use strict';
2015-04-29 03:25:17 +00:00
(function(){
var temp;
try{
temp=JSON.parse(localStorage.getItem('noname_0.9_config'));
2015-04-29 07:54:01 +00:00
if(!temp){
throw('err');
}
2015-04-29 03:25:17 +00:00
}
2015-04-29 07:54:01 +00:00
catch(err){
return;
2015-04-29 03:25:17 +00:00
}
2015-04-29 07:54:01 +00:00
var bg=document.querySelector('.background');
2015-12-02 10:40:25 +00:00
if(bg){
2015-04-29 07:54:01 +00:00
bg.style.backgroundSize="cover";
2015-12-02 10:40:25 +00:00
}
if(temp.image_background&&temp.image_background!='default'&&temp.image_background!='custom'){
bg.style.backgroundImage="url('image/background/"+temp.image_background+".jpg')";
2015-04-29 07:54:01 +00:00
switch (temp.image_background_filter){
2015-11-05 02:34:35 +00:00
case 'blur':
bg.style.filter='blur(8px)';
bg.style.webkitFilter='blur(8px)';
bg.style.transform='scale(1.05)';
break;
case 'gray':
bg.style.filter='grayscale(1)';
bg.style.webkitFilter='grayscale(1)';
break;
case 'sepia':
bg.style.filter='sepia(0.5)';
bg.style.webkitFilter='sepia(0.5)';
break;
case 'invert':
bg.style.filter='invert(1)';
bg.style.webkitFilter='invert(1)';
break;
case 'saturate':
bg.style.filter='saturate(5)';
bg.style.webkitFilter='saturate(5)';
break;
case 'contrast':
bg.style.filter='contrast(1.4)';
bg.style.webkitFilter='contrast(1.4)';
break;
case 'hue':
bg.style.filter='hue-rotate(180deg)';
bg.style.webkitFilter='hue-rotate(180deg)';
break;
case 'brightness':
bg.style.filter='brightness(5)';
bg.style.webkitFilter='brightness(5)';
break;
default:
bg.style.webkitFilter='';
2015-04-29 03:25:17 +00:00
}
}
2015-10-30 09:13:19 +00:00
window.resetGameTimeout=setTimeout(function(){
2015-12-06 15:23:47 +00:00
if(window.inSplash) return;
2015-10-30 09:13:19 +00:00
if(confirm('游戏似乎未正常载入,是否重置游戏?')){
localStorage.clear();
window.location.reload();
}
},5000);
2015-04-29 03:25:17 +00:00
}())