1
|
|
|
(function(d, w) { |
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
|
|
|
w.addEventListener('scroll', (e) => { |
|
|
|
|
23
|
|
|
if (d.documentElement.scrollTop > 10) { |
24
|
|
|
/* Access to the attribute data-theme */ |
25
|
|
|
if (d.documentElement.dataset.theme == 'dark') { |
26
|
|
|
header.style.background = '#1F2937'; |
27
|
|
|
header.style.borderBottom = '1px solid rgba(36, 68, 86, 0.5)'; |
28
|
|
|
header.style.boxShadow = '0 0 15px 4px rgba(0, 0, 0, 0.2)'; |
29
|
|
|
} else { |
30
|
|
|
header.style.background = '#F3F4F6'; |
31
|
|
|
header.style.borderBottom = 'none'; |
32
|
|
|
header.style.boxShadow = '0 0 15px 4px rgba(0, 0, 0, 0.2)'; |
33
|
|
|
} |
34
|
|
|
} else { |
35
|
|
|
if (d.documentElement.dataset.theme == 'dark') { |
36
|
|
|
header.style.background = '#111827'; |
37
|
|
|
header.style.borderBottom = '1px solid rgba(31, 41, 51, 1)'; |
38
|
|
|
header.style.boxShadow = 'none'; |
39
|
|
|
} else { |
40
|
|
|
header.style.background = '#EAE9F1'; |
41
|
|
|
header.style.borderBottom = 'none'; |
42
|
|
|
header.style.boxShadow = 'none'; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (d.documentElement.scrollTop > 150) { |
47
|
|
|
message.style = "display: block"; |
48
|
|
|
} else { |
49
|
|
|
message.style = "display: none"; |
50
|
|
|
} |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* DROPDOWN COMPONENT |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
let dropdown = d.getElementById('menuDropdown'); |
58
|
|
|
let menu = d.querySelector('nav:nth-child(2) a'); |
59
|
|
|
let evento = ((d.ontouchstart !== null) ? 'mouseup' : 'touchstart'); |
60
|
|
|
|
61
|
|
|
/* Show|hide dropdown */ |
62
|
|
|
menu.addEventListener(evento, function (e) { |
63
|
|
|
/* Prevents the click from propagating to the modal */ |
64
|
|
|
e.stopPropagation(0); |
65
|
|
|
|
66
|
|
|
dropdown.classList.toggle("active"); |
67
|
|
|
}); |
68
|
|
|
|
69
|
|
|
/* Hide dropdown on click outside */ |
70
|
|
|
w.addEventListener(evento, function (e) { |
71
|
|
|
if ( ! dropdown.contains(e.target)) { |
72
|
|
|
dropdown.classList.remove("active"); |
73
|
|
|
} |
74
|
|
|
}); |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* CODE FOR SELECTED THE FRAMES |
78
|
|
|
*/ |
79
|
|
|
|
80
|
|
|
var previousFrame = null; |
81
|
|
|
var previousInfo = null; |
82
|
|
|
var allFrames = d.querySelectorAll('.frame'); |
83
|
|
|
var allFramesCode = d.querySelectorAll('.code-source'); |
84
|
|
|
|
85
|
|
|
function changeTo(el) |
86
|
|
|
{ |
87
|
|
|
if (previousInfo) previousInfo.classList.remove("active"); |
|
|
|
|
88
|
|
|
|
89
|
|
|
previousInfo = el; |
90
|
|
|
|
91
|
|
|
el.classList.add("active"); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
function selectFrameInfo(index) |
95
|
|
|
{ |
96
|
|
|
var el = allFramesCode[index]; |
97
|
|
|
|
98
|
|
|
if (el) { |
|
|
|
|
99
|
|
|
if (el.closest('[data-frame]')) { |
|
|
|
|
100
|
|
|
return changeTo(el); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
for (let i = 0; i < allFrames.length; i++) { |
106
|
|
|
(function(i, el) { |
107
|
|
|
var el = allFrames[i]; |
108
|
|
|
|
109
|
|
|
el.addEventListener(evento, (e) => { |
110
|
|
|
e.preventDefault(); |
111
|
|
|
|
112
|
|
|
allFrames[0].classList.remove("active"); |
113
|
|
|
allFramesCode[0].classList.remove("active"); |
114
|
|
|
|
115
|
|
|
if (previousFrame) { |
116
|
|
|
previousFrame.classList.remove("active"); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
el.classList.add("active"); |
120
|
|
|
|
121
|
|
|
previousFrame = el; |
122
|
|
|
|
123
|
|
|
selectFrameInfo(el.attributes["data-index"].value); |
124
|
|
|
}); |
125
|
|
|
|
126
|
|
|
})(i); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
})(document, window); |
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.