Skip to content

Commit f0c9488

Browse files
authored
Merge pull request #281 from Dorin-David/modifying-document
Modifying document
2 parents 7db55fd + bf58681 commit f0c9488

File tree

31 files changed

+253
-253
lines changed

31 files changed

+253
-253
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
Answer: **1 and 3**.
1+
Risposta: **1 e 3**.
22

3-
Both commands result in adding the `text` "as text" into the `elem`.
4-
5-
Here's an example:
3+
Entrambi i commandi risultano nell'aggiunta di `text` "come testo" dentro a `elem`.
4+
Ecco un esempio:
65

76
```html run height=80
87
<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+
Abbiamo `elem`, un elemento DOM vuoto, e una stringa`text`.
88

9-
Which of these 3 commands will do exactly the same?
9+
Quali di questi 3 comandi fanno esattamente la stessa cosa?
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 che la chiamata a `update()` non è programmata solo in `clockStart()`, ma immediatamente dopo l'esecuzione della linea `(*)`. Altrimenti il visitatore dovrebbe aspettare fino alla prima esecuzione di `setInterval`. E l'orologio sarebbe vuoto fino ad allora.
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+
E' altresì importante impostare il nuovo intervallo in `clockStart()` solo quando l'orologio non sta andando. Altrimenti cliccare il bottone start svariate volte imposterebbe multipli intervali concorrenti. Ancora peggio: terremmo solo il `timerID` dell'ultimo intervallo, perdendo la referenza a tutti gli altri. Così non potremmo più fermare l'orologio! Nota che dobbiamo rimuovere il `timerID` quando l'orologio viene fermato alla linea `(**)`, in modo da permettergi di ricominciare eseguendo `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+
// imposta un nuovo intervallo solo se l'orologio è fermo
47+
// altrimenti dovremmo riscrivere la referenza di timerID all'intervallo in esecuzione e non potremmo più fermare l'orologio
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(); // <-- comincia subito, non aspettare un secondo affinché il primo setInterval funzioni
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; // <-- rimuovi timerID per indicare che l'orologio è stato fermato, in modo da poterlo far ripartire in clockStart()
5757
}
5858

5959
clockStart();
6060
</script>
6161

62-
<!-- click on this button calls clockStart() -->
62+
<!-- cliccare questo bottone chiama clockStart() -->
6363
<input type="button" onclick="clockStart()" value="Start">
6464

65-
<!-- click on this button calls clockStop() -->
65+
<!-- cliccare questo bottone chiama 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+
<!-- cliccare questo bottone chiama clockStart() -->
66
<input type="button" onclick="clockStart()" value="Start">
77

8-
<!-- click on this button calls clockStop() -->
8+
<!-- cliccare questo bottone chiama 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+
# Orologio colorato con setInterval
66

7-
Create a colored clock like here:
7+
Crea un orologio colorato come quello dell'esempio:
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 per lo styling, JavaScript aggiorna solo il tempo negli elementi.

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+
Quando abbiamo bisogno di inserire dell'HTML da qualche parte, `insertAdjacentHTML` è la scelta migliore
33

4-
The solution:
4+
La soluzione:
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+
# Inserisci l'HTML nella lista
66

7-
Write the code to insert `<li>2</li><li>3</li>` between two `<li>` here:
7+
Scrivi il codice per inserire `<li>2</li><li>3</li>` tra i due `<li>` sotto:
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 soluzione è breve, ma potrebbe sembrare difficile, quindi la commenteremo in dettaglio:
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+
L'algoritmo passo per passo:
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. Trova tutti i `<tr>` dentro `<tbody>`.
13+
2. Ordinali comparando il contenuto del primo `<td>` (il campo con il nome).
14+
3. Ora inserisci i nodi nel giusto ordine con `.append(...sortedRows)`.
1515

16-
We don't have to remove row elements, just "re-insert", they leave the old place automatically.
16+
Non dobbiamo rimuovere gli elementi della fila, solo "re-inserirli", lasciano automaticamente il vecchio posto.
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. Nel nostro caso c'è un esplicito `<tbody>` nella tabella; ma se anche non vi fosse, la struttura DOM lo include sempre e comunque.

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+
// ... il tuo codice ...
2727
</script>

0 commit comments

Comments
 (0)