1
|
|
|
(function(d) { |
2
|
|
|
/** |
3
|
|
|
* CODE FOR SELECTION OF FRAMES |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
/* IE8 Incompatibility crap */ |
7
|
|
|
let elements = ['section', 'header', 'nav', 'footer']; |
8
|
|
|
|
9
|
|
|
for (let i = 0; i < elements.length; i++) { |
10
|
|
|
d.createElement(elements[i]); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* CODE FOR CONTROL OF ELEMENTS HTML IN THE HEADER |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
let header = d.querySelector('header'); |
18
|
|
|
let message = d.querySelector('.time'); |
19
|
|
|
|
20
|
|
|
message.style = "display: none"; |
21
|
|
|
|
22
|
|
|
window.addEventListener('scroll', (e) => { |
|
|
|
|
23
|
|
|
if (d.documentElement.scrollTop > 10) { |
24
|
|
|
if (localStorage.getItem('dark-mode') === 'true') { |
|
|
|
|
25
|
|
|
header.style.background = '#1F2937'; |
26
|
|
|
header.style.borderBottom = '1px solid rgba(36, 68, 86, 0.5)'; |
27
|
|
|
header.style.boxShadow = '0 0 15px 4px rgba(0, 0, 0, 0.2)'; |
28
|
|
|
} else { |
29
|
|
|
header.style.background = '#F3F4F6'; |
30
|
|
|
header.style.borderBottom = 'none'; |
31
|
|
|
header.style.boxShadow = '0 0 15px 4px rgba(0, 0, 0, 0.2)'; |
32
|
|
|
} |
33
|
|
|
} else { |
34
|
|
|
if (localStorage.getItem('dark-mode') === 'true') { |
35
|
|
|
header.style.background = 'none'; |
36
|
|
|
header.style.borderBottom = '1px solid rgba(31, 41, 51, 1)'; |
37
|
|
|
header.style.boxShadow = 'none'; |
38
|
|
|
} else { |
39
|
|
|
header.style.background = 'none'; |
40
|
|
|
header.style.borderBottom = 'none'; |
41
|
|
|
header.style.boxShadow = 'none'; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (d.documentElement.scrollTop > 150) { |
46
|
|
|
message.style = "display: block"; |
47
|
|
|
} else { |
48
|
|
|
message.style = "display: none"; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
var dropdown = d.querySelector('.dropdown'); |
54
|
|
|
var config = d.querySelector('nav:nth-child(2) a'); |
55
|
|
|
let evento = ((document.ontouchstart !== null) ? 'mouseup' : 'touchstart'); |
56
|
|
|
|
57
|
|
|
config.addEventListener(evento, function (e) { |
58
|
|
|
if (e.target) { |
59
|
|
|
dropdown.classList.toggle("active"); |
60
|
|
|
} |
61
|
|
|
}); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* CODE FOR SELECTED THE FRAMES |
65
|
|
|
*/ |
66
|
|
|
|
67
|
|
|
var previousFrame = null; |
68
|
|
|
var previousInfo = null; |
69
|
|
|
var allFrames = d.querySelectorAll('.frame'); |
70
|
|
|
var allFramesCode = d.querySelectorAll('.code-source'); |
71
|
|
|
|
72
|
|
|
function changeTo(el) |
73
|
|
|
{ |
74
|
|
|
if (previousInfo) previousInfo.classList.remove("active"); |
|
|
|
|
75
|
|
|
|
76
|
|
|
previousInfo = el; |
77
|
|
|
|
78
|
|
|
el.classList.add("active"); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
function selectFrameInfo(index) |
82
|
|
|
{ |
83
|
|
|
var el = allFramesCode[index]; |
84
|
|
|
|
85
|
|
|
if (el) { |
|
|
|
|
86
|
|
|
if (el.closest('[data-frame]')) { |
|
|
|
|
87
|
|
|
return changeTo(el); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
for (let i = 0; i < allFrames.length; i++) { |
93
|
|
|
(function(i, el) { |
94
|
|
|
var el = allFrames[i]; |
95
|
|
|
|
96
|
|
|
el.addEventListener(evento, (e) => { |
97
|
|
|
e.preventDefault(); |
98
|
|
|
|
99
|
|
|
allFrames[0].classList.remove("active"); |
100
|
|
|
allFramesCode[0].classList.remove("active"); |
101
|
|
|
|
102
|
|
|
if (previousFrame) { |
103
|
|
|
previousFrame.classList.remove("active"); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
el.classList.add("active"); |
107
|
|
|
|
108
|
|
|
previousFrame = el; |
109
|
|
|
|
110
|
|
|
selectFrameInfo(el.attributes["data-index"].value); |
111
|
|
|
}); |
112
|
|
|
|
113
|
|
|
})(i); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
})(document); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.