Skip to content

Commit a34e3a0

Browse files
authored
Merge pull request #494 from joaquinelio/modidocu
Modifying the document
2 parents e060ee7 + b836585 commit a34e3a0

File tree

32 files changed

+285
-285
lines changed

32 files changed

+285
-285
lines changed

2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Answer: **1 and 3**.
1+
Respuesta: **1 y 3**.
22

3-
Both commands result in adding the `text` "as text" into the `elem`.
3+
Ambos comandos agregan `text` "como texto" dentro de `elem`.
44

5-
Here's an example:
5+
Aquí el ejemplo:
66

77
```html run height=80
88
<div id="elem1"></div>

2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ importance: 5
44

55
# createTextNode vs innerHTML vs textContent
66

7-
We have an empty DOM element `elem` and a string `text`.
7+
Tenemos un elemento DOM vacio `elem` y un string `text`.
88

9-
Which of these 3 commands will do exactly the same?
9+
¿Cuáles de estos 3 comandos harán exactamente lo mismo?
1010

1111
1. `elem.append(document.createTextNode(text))`
1212
2. `elem.innerHTML = text`

2-ui/1-document/07-modifying-document/10-clock-setinterval/solution.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
First, let's make HTML/CSS.
1+
Primero escribamos HTML/CSS.
22

3-
Each component of the time would look great in its own `<span>`:
3+
Cada componente de la hora se verá muy bien dentro de su propio `<span>`:
44

55
```html
66
<div id="clock">
77
<span class="hour">hh</span>:<span class="min">mm</span>:<span class="sec">ss</span>
88
</div>
99
```
1010

11-
Also we'll need CSS to color them.
11+
También necesitamos CSS para colorearlos.
1212

13-
The `update` function will refresh the clock, to be called by `setInterval` every second:
13+
La función `update` que refrescará el reloj será llamada por `setInterval` una vez por segundo:
1414

1515
```js
1616
function update() {
@@ -32,15 +32,15 @@ function update() {
3232
}
3333
```
3434

35-
In the line `(*)` we every time check the current date. The calls to `setInterval` are not reliable: they may happen with delays.
35+
En la línea `(*)` verificamos la hora cada vez. Las llamadas a `setInterval` no son confiables: pueden ocurrir con demoras.
3636

37-
The clock-managing functions:
37+
Las funciones que manejan el reloj:
3838

3939
```js
4040
let timerId;
4141

42-
function clockStart() { // run the clock
43-
if (!timerId) { // only set a new interval if the clock is not running
42+
function clockStart() { // ejecuta el reloj
43+
if (!timerId) { // solo establece un nuevo intervalo si el reloj no está corriendo
4444
timerId = setInterval(update, 1000);
4545
}
4646
update(); // (*)
@@ -52,6 +52,6 @@ function clockStop() {
5252
}
5353
```
5454

55-
Please note that the call to `update()` is not only scheduled in `clockStart()`, but immediately run in the line `(*)`. Otherwise the visitor would have to wait till the first execution of `setInterval`. And the clock would be empty till then.
55+
Nota que la llamada a `update()` no solo está agendada en `clockStart()`, también la ejecuta inmediatamente en la línea `(*)`. De otro modo el visitante tendría que esperar hasta la primera ejecución de `setInterval`. Y el reloj estaría vacío hasta entonces.
5656

57-
Also it is important to set a new interval in `clockStart()` only when the clock is not running. Otherways clicking the start button several times would set multiple concurrent intervals. Even worse - we would only keep the `timerID` of the last interval, losing references to all others. Then we wouldn't be able to stop the clock ever again! Note that we need to clear the `timerID` when the clock is stopped in the line `(**)`, so that it can be started again by running `clockStart()`.
57+
También es importante establecer un nuevo intervalo en `clockStart()` solamente cuando el reloj no está corriendo. De otra forma al cliquear el botón de inicio varias veces se establecerían múltiples intervalos concurrentes. Peor aún, solo mantendríamos el `timerID` del último intervalo, perdiendo referencia a todos los demás. ¡No podríamos detener el reloj nunca más! Nota que necesitamos limpiar `timerID` cuando el reloj es detenido en la línea `(**)`, así puede ser reiniciado corriendo `clockStart()`.

2-ui/1-document/07-modifying-document/10-clock-setinterval/solution.view/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,26 @@
4343
}
4444

4545
function clockStart() {
46-
// set a new interval only if the clock is stopped
47-
// otherwise we would rewrite the timerID reference to the running interval and wouldn't be able to stop the clock ever again
46+
// establece un nuevo intervalo solo si el reloj está detenido
47+
// de otro modo sobreescribiríamos la referencia timerID del intervalo en ejecución y no podríamos detener el reloj nunca más
4848
if (!timerId) {
4949
timerId = setInterval(update, 1000);
5050
}
51-
update(); // <-- start right now, don't wait 1 second till the first setInterval works
51+
update(); // <-- inicia ahora mismo, no espera 1 second hasta el primer intervalo
5252
}
5353

5454
function clockStop() {
5555
clearInterval(timerId);
56-
timerId = null; // <-- clear timerID to indicate that the clock has been stopped, so that it is possible to start it again in clockStart()
56+
timerId = null; // <-- borra timerID para indicar que el reloj fue detenido, haciendo posible iniciarlo de nuevo en clockStart()
5757
}
5858

5959
clockStart();
6060
</script>
6161

62-
<!-- click on this button calls clockStart() -->
62+
<!-- cliquear este botón llama a clockStart() -->
6363
<input type="button" onclick="clockStart()" value="Start">
6464

65-
<!-- click on this button calls clockStop() -->
65+
<!-- cliquear este botón llama a clockStop() -->
6666
<input type="button" onclick="clockStop()" value="Stop">
6767

6868
</body>

2-ui/1-document/07-modifying-document/10-clock-setinterval/source.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html>
33
<body>
44

5-
<!-- click on this button calls clockStart() -->
5+
<!-- cliquear en este botón llama a clockStart() -->
66
<input type="button" onclick="clockStart()" value="Start">
77

8-
<!-- click on this button calls clockStop() -->
8+
<!-- cliquear en este botón llama a clockStop() -->
99
<input type="button" onclick="clockStop()" value="Stop">
1010

1111
</body>

2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ importance: 4
22

33
---
44

5-
# Colored clock with setInterval
5+
# Reloj coloreado con setInterval
66

7-
Create a colored clock like here:
7+
Crea un reloj coloreado como aquí:
88

99
[iframe src="solution" height=60]
1010

11-
Use HTML/CSS for the styling, JavaScript only updates time in elements.
11+
Usa HTML/CSS para el estilo, JavaScript solamente actualiza la hora en elements.

2-ui/1-document/07-modifying-document/11-append-to-list/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
When we need to insert a piece of HTML somewhere, `insertAdjacentHTML` is the best fit.
2+
Cuando necesitamos insertar una pieza de HTML en algún lugar, `insertAdjacentHTML` es lo más adecuado.
33

4-
The solution:
4+
La solución:
55

66
```js
77
one.insertAdjacentHTML('afterend', '<li>2</li><li>3</li>');

2-ui/1-document/07-modifying-document/11-append-to-list/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Insert the HTML in the list
5+
# Inserta el HTML en la lista
66

7-
Write the code to insert `<li>2</li><li>3</li>` between two `<li>` here:
7+
Escribe el código para insertar `<li>2</li><li>3</li>` entre dos `<li>` aquí:
88

99
```html
1010
<ul id="ul">
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution is short, yet may look a bit tricky, so here I provide it with extensive comments:
1+
La solución es corta, pero puede verse algo dificultosa así que brindamos comentarios extendidos:
22

33
```js
44
let sortedRows = Array.from(table.tBodies[0].rows) // 1
@@ -7,12 +7,12 @@ let sortedRows = Array.from(table.tBodies[0].rows) // 1
77
table.tBodies[0].append(...sortedRows); // (3)
88
```
99

10-
The step-by-step algorthm:
10+
El algoritmo paso a paso:
1111

12-
1. Get all `<tr>`, from `<tbody>`.
13-
2. Then sort them comparing by the content of the first `<td>` (the name field).
14-
3. Now insert nodes in the right order by `.append(...sortedRows)`.
12+
1. Obtener todos los `<tr>` de `<tbody>`.
13+
2. Entonces ordenarlos comparando por el contenido de su primer `<td>` (el campo nombre).
14+
3. Ahora insertar nodos en el orden correcto con `.append(...sortedRows)`.
1515

16-
We don't have to remove row elements, just "re-insert", they leave the old place automatically.
16+
No necesitamos quitar los elementos row, simplemente "reinsertarlos", ellos dejan el viejo lugar automáticamente.
1717

18-
P.S. In our case, there's an explicit `<tbody>` in the table, but even if HTML table doesn't have `<tbody>`, the DOM structure always has it.
18+
P.S. En nuestro caso, hay un `<tbody>` explícito en la tabla, pero incluso si la tabla HTML no tiene `<tbody>`, la estructura DOM siempre lo tiene.

2-ui/1-document/07-modifying-document/12-sort-table/source.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
</table>
2424

2525
<script>
26-
// ... your code ...
26+
// ... tu código ...
2727
</script>

0 commit comments

Comments
 (0)