-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
167 lines (136 loc) · 3.88 KB
/
Copy pathscript.js
File metadata and controls
167 lines (136 loc) · 3.88 KB
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
(function() {
document.getElementById("miName").focus();
})();
let index = 0
let aciertos = [];
let questions = [];
let incisos = [];
let answers = [];
function usuarioNombre() {
let elemento = document.getElementById("miName");
let nombre = document.getElementById("miName").value;
if (nombre.length === 0) {
alert("Aún no nos has dicho tu nombre");
document.getElementById("miName").focus();
} else {
greetings(nombre);
}
}
function greetings(nombre) {
aparecer('saludo');
let saludito = `¡Bienvenida ${nombre}!`;
document.getElementById('mensajeSaludo').innerHTML = saludito;
}
function aparecer(div) {
let invi = document.getElementsByClassName("cajas");
for (let i = 0, caj = invi.length; i < caj; i++) {
invi[i].style.display = "none";
}
document.getElementById(div).style.display = "block";
}
function abrirPreguntas(opcion) {
let categoria = '';
reiniciar();
if (opcion === 'categoria1') {
questions = [
"1) ¿Cuál es el río mas largo de México?",
"2) ¿En que país nació el internet?",
"3) ¿Qué país tiene la línea de ferrocarril más larga del mundo?"
];
incisos = [
["Bravo", "Lerma", "Balsas"],
["Alemania", "Estados Unidos", "Japón"],
["China", "Estados Unidos", "Rusia"]
];
answers = [
0,
1,
2
];
categoria = "Conocimiento general";
} else if (opcion === 'categoria2') {
questions = [
"1) En Stranger Things ¿Cuál es la comida favorita de Eleven?",
"2) ¿Cómo se llama la protagonista principal de The Big Ban Theory?",
"3) En Game of Thrones ¿Cómo muere el rey de la noche?"
];
incisos = [
["Hot Cakes", "Waffles", "Hot dogs"],
["Penny", "Jenny", "Amy"],
["Jon Snow lo mata", "Un dragón lo aplasta", "Una adolescente lo mata"]
];
answers = [
1,
0,
2
];
categoria = "Series de TV";
}
document.getElementById("nombreCategoria").innerHTML = categoria;
preguntar(index);
aparecer("tarjetas");
}
function preguntar(indice) {
document.getElementById("aparezcanP").innerHTML = questions[indice];
let opciones = "";
for (let i = 0; i < incisos[indice].length; i++) {
opciones += "<p>";
opciones += "<label><input class='radios' type='radio' onclick = 'respUser(" + i + ")' name='opcion'>" + incisos[indice][i] + "</label>";
opciones += "</p>";
}
document.getElementById("incisos").innerHTML = opciones;
}
function respUser(resp) {
document.getElementById("almostAnswer").style.display = "block";
let aviso = "Respuesta incorrecta (ಥ﹏ಥ)";
let color = "DarkGray";
if (answers[index] === resp) {
aviso = "Respuesta correcta (=⌒‿‿⌒=)";
aciertos.push(index);
color = "MediumSpringGreen";
}
document.getElementById("almostAnswer").style.background = color;
document.getElementById("almostAnswer").innerHTML = aviso;
}
function next() {
document.getElementById("almostAnswer").style.display = "none";
index++;
if (index <= questions.length - 1) {
preguntar(index);
}
if (index === questions.length) {
muestraTotal();
}
}
function muestraTotal() {
aparecer("totales");
let plantilla = "";
let plantillaFinal = "";
for (let j = 0; j < questions.length; j++) {
plantilla += "<p>";
let daleInfo = "Incorrecto";
let dameInfo = "wrong";
for (let x of aciertos) {
if (x === j) {
daleInfo = "Correcto";
dameInfo = "right";
break;
}
}
plantillaFinal += '<label class="' + dameInfo + '">' + daleInfo + "</label>";
plantilla += "<p>" + questions[j] + " " + plantillaFinal + "</p>";
plantilla += "</p>";
plantillaFinal = "";
}
document.getElementById("muestrameTodo").innerHTML = plantilla;
}
function reload() {
window.location.reload();
}
function reiniciar() {
index = 0;
aciertos = [];
questions = [];
incisos = [];
answers = [];
}