-
Notifications
You must be signed in to change notification settings - Fork 0
/
landing.js
100 lines (78 loc) · 2.78 KB
/
landing.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
document.addEventListener("DOMContentLoaded", onload);
function onload(){
setupBackgroundSpecial();
};
function setupBackgroundSpecial(){
console.log('setupBackgroundSpecial');
let delay_ms = randomInRange( 2000, 4000 );
//let delay_ms = randomInRange( 1000, 2000 );
//let delay_ms = 1;
setTimeout( drawBackgroundSpecial, delay_ms );
};
function drawBackgroundSpecial(){
let wrapper = createDiv( document.body, 'specialWrapper' );
wrapper.style.top = randomInRange(5, 75)+'%';
var horizontal = randomInRange(15, 85);
if(horizontal > 50){
wrapper.style.right = (85-horizontal)+'%';
}else{
wrapper.style.left = (horizontal-15)+'%';
}
let titlebar = createDiv( wrapper, ['specialTitlebar'] );
setTimeout( drawBackgroundSpecial_body, 650, {wrapper, titlebar} );
};
function drawBackgroundSpecial_body(divs){
divs.body = createDiv( divs.wrapper, ['specialBody'] );
setTimeout(drawBackgroundSpecial_action, 700, divs);
};
function drawBackgroundSpecial_action(divs){
const animationDelay = 350;
let text = getRandomText();
text = '<div>' + text.split('\n').join('</div><div>') + '</div>';
text = text.split(' ').join(' ');
let fragment = document.createElement('div');
fragment.innerHTML = text;
let children = fragment.children;
for(let i=0, len=children.length; i<len; ++i){
children[i].style['animation-delay'] = i*animationDelay + 'ms';
}
divs.body.appendChild(fragment);
addClasses(divs.body, 'animFadeInText');
let delay_ms = randomInRange( 3000, 4000 );
delay_ms += children.length * animationDelay;
setTimeout(drawBackgroundSpecial_hide, delay_ms, divs);
};
function drawBackgroundSpecial_hide(divs){
divs.wrapper.innerHTML = '';
setupBackgroundSpecial();
};
var text_index = 0;
function getRandomText(){
let arr= ['.specialTitlebar{\n background-color:\n rgb(94, 120, 213);\n width: 150px;\n height: 20px;\n animation:\n animExpandTitle 0.7s\n ease-in-out;\n}',
'SELECT *\nFROM [jRolePerm] j\nJOIN [Permission] P \n ON P.id=j.perm_id\nWHERE not exists(\n SELECT * \n FROM [jRolePerm] j2\n WHERE j2.perm_id \n = j1.perm_id\n and j2.role_id > 13 )'
];
if(text_index>= arr.length) text_index= 0;
return arr[text_index++];
};
function randomInRange(min, max){
return Math.random() * (+max - +min) + +min;
};
function createDiv(parent, _class){
let div = document.createElement('div');
addClasses(div, _class);
parent.appendChild(div);
return div;
};
function addClasses(elem, classes){
if(classes){
if(isArray(classes)){
for(let _c of classes)
elem.classList.add(_c);
}else{
elem.classList.add(classes);
}
}
}
function isArray(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};