-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
131 lines (121 loc) · 4.73 KB
/
script.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
let projectsSectionDisplay = false;
let skillsSectionDisplay = false;
let projects = false;
let errorMessage = false;
let activeSection = "";
document.addEventListener('keydown', quitPopUp);
function removeAllCSS(){
document.querySelectorAll('style,link[rel="stylesheet"]').forEach(item => item.remove())
}
function generateUUID(){
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
window.onload = function(){
Array.from(document.getElementsByClassName('generated-uuid')).forEach(element => {element.innerHTML=generateUUID()});
}
function quitPopUp(e){
console.log(e.key);
if (e.key === 'E' || e.key === 'e' || e.key === 'Escape' || e.key === 'Enter') {
desactivatePopUp();
}
}
function desactivatePopUp(){
document.getElementById('filter').style.display = 'none';
document.getElementById('popup').style.display = 'none';
document.removeEventListener('keydown', quitPopUp);
}
function switchSection(section){
if(activeSection !== ""){
disableSection(activeSection);
}
toggleDisplaySection(section);
activeSection = section;
}
function toggleDisplaySection(sectionName) {
window[sectionName+"SectionDisplay"] = !window[sectionName+"SectionDisplay"];
let closeBracket = document.getElementById('close-bracket-'+sectionName);
let openBracket = document.getElementById('open-bracket-'+sectionName);
let section = document.getElementById(sectionName+'-section');
if(window[sectionName+"SectionDisplay"]){
section.style.display = 'block';
closeBracket.style.display = 'block';
closeBracket.style.color = 'var(--red)';
openBracket.innerHTML = '{';
openBracket.style.color = 'var(--red)';
}else{
disableSection(sectionName);
}
}
function disableSection(sectionName){
let closeBracket = document.getElementById('close-bracket-'+sectionName);
let openBracket = document.getElementById('open-bracket-'+sectionName);
let section = document.getElementById(sectionName+'-section');
section.style.display = 'none';
openBracket.innerHTML = '{ ... }';
openBracket.style.color = 'var(--grey)';
closeBracket.style.display= 'none';
}
async function displayProjects() {
if (!errorMessage && !projects) {
document.getElementById('loading').style.display = 'block';
await changeLoading()
document.getElementById('errorLoading').style.display = 'block';
document.getElementById('loading').style.display = 'none';
errorMessage = true;
} else if (errorMessage && !projects) {
document.getElementById('projects').style.display = 'block';
document.getElementById('errorLoading').style.display = 'none';
Array.from(document.getElementsByClassName('display-projects')).forEach(e=>e.style.display = 'none');
projects = true;
}
}
async function changeLoading() {
let i = 0;
let element = document.getElementById('loading');
while (i < 6) {
if (i == 0) {
element.innerHTML = "Loading";
}
else if (i == 1) {
element.innerHTML = "Loading .";
}
else if (i == 2) {
element.innerHTML = "Loading ..";
}
else if (i == 3) {
element.innerHTML = "Loading ...";
}
else if (i == 4) {
element.innerHTML = "Loading";
}
else if (i == 5) {
element.innerHTML = "L ad gg.";
await new Promise(resolve => setTimeout(resolve, 150));
element.innerHTML = "Loaig.";
await new Promise(resolve => setTimeout(resolve, 120));
element.innerHTML = "Loddaig....";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "LL";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "Loddaig....";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "LL";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "Lodd@ig....";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "4242";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "4242";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "4242";
await new Promise(resolve => setTimeout(resolve, 50));
element.innerHTML = "Lo@@dD11g....";
await new Promise(resolve => setTimeout(resolve, 600));
break
}
await new Promise(resolve => setTimeout(resolve, 800));
i++;
}
}