-
Notifications
You must be signed in to change notification settings - Fork 0
/
bg.js
63 lines (56 loc) · 2.32 KB
/
bg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
uniform circular motion demo! ()cleoold
*/
const pBody = document.querySelector('body');
const pHtml = document.querySelector('html');
// background change
let bgChangeFlag = -1;
(() => {
const colors = ['#30542c', '#232170', '#530a80', '#870c6d', '#873a0b'];
//const colorsLight = ['#4c9144', '#514db0', '#a06bc2', '#ab609b'];
let i = 0;
bgChangeFlag = setTimeout(function loopBgColor() {
if (++i === 5) i = 0;
pBody.style.backgroundColor = colors[i];
pHtml.style.backgroundColor = colors[i];
if (bgChangeFlag)
bgChangeFlag = setTimeout(loopBgColor, 5000);
}, 5000);
})();
document.querySelector('.cancel-bg-change').addEventListener('click', function fn(e) {
document.querySelector('.cancel-bg-change').removeEventListener('click', fn);
clearTimeout(bgChangeFlag);
bgChangeFlag = null;
});
document.querySelector('.cancel-bg-change-and-enable-star').addEventListener('click', function fn(e) {
document.querySelector('.cancel-bg-change-and-enable-star').removeEventListener('click', fn);
clearTimeout(bgChangeFlag);
bgChangeFlag = null;
pBody.style.backgroundColor = 'unset';
pHtml.style.backgroundColor = 'unset';
pHtml.style.background = 'url("./assets/bg.jpg")';
pHtml.style.backgroundPosition = 'center center';
pHtml.style.backgroundAttachment = 'fixed';
document.querySelector('#container').style.backgroundColor = 'unset';
document.querySelector('#container').style.overflow = 'unset';
// change origin display styles, add lights
const colors = [
'1px 1px 15px 6px rgba(255,144,61,.89)',
'1px 1px 15px 6px rgba(255,100,61,.93)',
'1px 1px 15px 6px rgba(255,88,61,.89)',
'1px 1px 15px 6px rgba(255,88,61,.5)',
'1px 1px 15px 6px rgba(255,100,61,.89)',
'1px 1px 15px 6px rgba(255,144,61,.77)',
];
let i = 0;
const origin = document.querySelector('#origin');
origin.style.background = 'radial-gradient( rgb(255,208,0) 1%, rgb(255,151,0) 39%, rgb(249,183,0) 39%, rgb(223,77,23) 100%)';
origin.style.width = '8px';
origin.style.height = '8px';
setTimeout(function loopSunColor() {
if (++i === 6) i =0;
origin.style.boxShadow = colors[i];
origin.style.WebkitBoxShadow = colors[i];
setTimeout(loopSunColor, 4000);
}, 0);
});