-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
220 lines (169 loc) · 6.07 KB
/
index.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
const open = document.getElementById('open');
const close = document.getElementById('close');
const modal = document.getElementById('modal_container');
const video = document.querySelector('.video')
close.addEventListener('click', () => {
console.log('close')
video.innerHTML = `
<video class="video" width="320" height="240">
<source
src="Jack-Black.mp4"
type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>`
modal.classList.remove('show');
});
//close modal when clicked outside the the modal
document.onclick = (e) => {
if (e.target.classList.contains('modal-container')) {
video.innerHTML = `
<video class="video" width="320" height="240">
<source
src="Jack-Black.mp4"
type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>`
modal.classList.remove('show');
}
}
//close modal when clicked escape button
document.onkeydown = (e) => {
if (e.key == 'Escape') {
console.log('close')
video.innerHTML = `<video class="video" width="320" height="240">
<source
src="Jack-Black.mp4"
type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>`
modal.classList.remove('show');
}
}
const projects = [
{
name: 'Covid-19',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Covid-19'
},
{
name: 'Background-Picker',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Background-Picker'
},
{
name: 'Counter',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Counter'
},
{
name: 'Sidebar',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Sidebar'
},
{
name: 'Clash-Of-Clans',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Clash-Of-Clans'
},
{
name: 'Modal',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Modal'
},
{
name: 'Exchange-Rate',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Exchange-Rate'
},
{
name: 'Nepali-Calendar',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Nepali-Calendar'
},
{
name: 'Slider',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Slider'
},
{
name: 'Todo-List',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Todo-List'
},
{
name: 'Recipe',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Recipe'
},
{
name: 'General-Questions',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/General-Questions'
},
{
name: 'weather-api',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/weather-api'
},
{
name: 'quiz-app',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/quiz-app'
},
{
name: 'Emoji-Finder',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Emoji-Finder'
},
]
const containerEl = document.querySelector('.container')
const display = (p) => {
p.forEach((project, index) => {
const boxEl = document.createElement('li')
boxEl.classList.add('box')
const CardHtml = `
<div class="c-subscribe-box u-align-center">
<div class="rainbow"><span></span><span></span></div>
<div class="c-subscribe-box__wrapper">
<a href="/${project.name}/index.html">
<img src='/${project.name}/design/desktop-preview.jpg' alt='${project.name}'></img>
</a>
<h3 class="c-subscribe-box__title">${index + 1}. ${formatNames(project.name)}</h3>
</div>
<div class="links">
<ul>
<li><a href="">
<i class="fab fa-facebook-f"></i>
</a></li>
<li><a href=${project.github}>
<i class="fab fa-github"></i>
</a></li>
<li><a href="https://www.instagram.com/mirozuzamaki/">
<i class="fab fa-instagram"></i>
</a></li>
</ul>
</div>
</div>
`
boxEl.innerHTML = CardHtml
containerEl.appendChild(boxEl)
})
}
const formatNames = (n) => {
return n.split('-').map(word => word[0].toUpperCase() + word.slice(1))
.join(' ')
}
display(projects)
var pattern = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'x', 'x', 'x'];
var current = 0;
var keyHandler = function (event) {
// If the key isn't in the pattern, or isn't the current key in the pattern, reset
if (pattern.indexOf(event.key) < 0 || event.key !== pattern[current]) {
current = 0;
return;
}
// Update how much of the pattern is complete
current++;
// If complete, alert and reset
if (pattern.length === current) {
current = 0;
containerEl.innerHTML = ''
const arr = []
arr.push(...projects, {
name: 'Slider1',
github: 'https://github.com/revengemiroz/VanillaJS/tree/master/Slider1'
})
console.warn(arr)
display(arr)
}
};
// Listen for keydown events
document.addEventListener('keydown', keyHandler, false);