-
Notifications
You must be signed in to change notification settings - Fork 0
/
questions.html
172 lines (147 loc) · 4.54 KB
/
questions.html
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:[email protected]&display=swap" rel="stylesheet">
<link rel="icon" href="favicon.png" sizes="any"><!-- 32×32 -->
<link rel="icon" href="favicon.svg" type="image/svg+xml">
<style>
body {
font-family: "Lexend", "Helvetica Neue", "Helvetica", sans-serif;
margin: 1rem;
padding: 0;
font-size: 16px;
}
header {
background-color: #999;
color: #eee;
height: 0vh;
}
main {
background-color: #fff;
color: #222;
padding: 1rem 2rem;
margin: 1em auto;
display: flex;
flex-wrap: wrap;
}
section {
flex: 1;
}
footer {}
h1 {
font-size: 32px;
}
ol {
margin: 1rem;
list-style: none;
counter-reset: my-counter 0;
}
li {
cursor: pointer;
}
footer section {
max-width: 50rem;
margin-left: auto;
margin-right: auto;
}
ol li {
counter-increment: my-counter;
padding-left: 0.5rem;
margin-bottom: 1rem;
}
ol li::marker {
content: counter(my-counter) ".";
}
ol li::marker.glow {
content: counter(my-counter) ".";
background-color: #06c;
color: #fff;
display: inline-block;
}
.glow {
background-color: #c3ebff;
color: #000;
}
li:hover {
background-color: #e2f5ff;
color: #000;
}
.answer {
display: block;
clear: left;
transition: all 200ms linear;
overflow: hidden;
height: 4em;
}
.hidden {
height: 0px;
}
.glow .answer {
height: 4em;
}
textarea {
height: 3.3rem;
width: 28rem;
}
</style>
</head>
<body>
<h1>Job Interview Questions</h1>
<main>
</main>
<footer>
</footer>
<script>
const $ = str => document.querySelector(str);
const $$ = str => document.querySelectorAll(str);
(function() {
const app = {
init: function() {
fetch("questions.json").then(response => response.json()).then(data => {
app.state.questions = data;
console.dir(data);
app.renderQuestions();
$("main").addEventListener("click", app.doClick);
});
app.state.loaded = true;
},
state: {
loaded: false,
questions: {}
},
renderQuestions: function() {
const sections = Object.keys(app.state.questions["Questions"]);
let out = "";
sections.forEach(section => {
out += app.makeSection(section, app.state.questions["Questions"][section]);
});
$("main").innerHTML = out;
$("footer").innerHTML = app.makeSection("Tips", app.state.questions["Tips"], 'ul');
},
makeSection: function(title, items, type = 'ol') {
const key = title.replace(/\W/, '').toLowerCase();
let out = `<section><h2>${title}</h2><${type}>`;
items.forEach((item, idx) => {
out += `<li>${item}<div class='answer hidden'><textarea cols='40' rows='5' id='answer[${key}][${idx}]'></textarea></li>`;
});
out += `</${type}></section>`;
return out;
},
doClick: function(e) {
console.dir(e);
if (e.target.nodeName === "LI") {
$(".glow")?.classList.remove("glow");
e.target.classList.add("glow");
}
},
}
window.app = app;
app.init();
})();
</script>
</body>
</html>