Skip to content

Commit dd06aff

Browse files
authored
Merge pull request #186 from HachemiH/master
Modifying the document
2 parents b1f87b3 + 4bcb88b commit dd06aff

File tree

21 files changed

+220
-220
lines changed

21 files changed

+220
-220
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+
Réponse : **1 et 3**.
22

3-
Both commands result in adding the `text` "as text" into the `elem`.
3+
Les deux commandes ont pour résultat d'ajouter le `texte` "en tant que texte" dans `elem`.
44

5-
Here's an example:
5+
Voici un exemple :
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+
Nous avons un élément DOM vide `elem` et une chaîne de caractères `text`.
88

9-
Which of these 3 commands do exactly the same?
9+
Lesquelles de ces 3 commandes font exactement la même chose ?
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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
First, let's make HTML/CSS.
1+
Tout d'abord, créons notre HTML/CSS.
22

3-
Each component of the time would look great in its own `<span>`:
3+
Chaque composante du temps aurait fière allure dans son propre `<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+
Nous aurons également besoin de CSS pour les colorer.
1212

13-
The `update` function will refresh the clock, to be called by `setInterval` every second:
13+
La fonction `update` rafraîchira l'horloge, qui sera appelée par `setInterval` toutes les secondes :
1414

1515
```js
1616
function update() {
@@ -32,14 +32,14 @@ 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+
Dans la ligne `(*)` nous vérifions à chaque fois la date actuelle. Les appels à `setInterval` ne sont pas fiables : ils peuvent survenir avec des retards.
3636

37-
The clock-managing functions:
37+
Les fonctions de gestion d'horloge :
3838

3939
```js
4040
let timerId;
4141

42-
function clockStart() { // run the clock
42+
function clockStart() { // exécute l'horloge
4343
timerId = setInterval(update, 1000);
4444
update(); // (*)
4545
}
@@ -50,4 +50,4 @@ function clockStop() {
5050
}
5151
```
5252

53-
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.
53+
Veuillez noter que l'appel à `update()` est non seulement planifié dans `clockStart()`, mais s'exécute immédiatement dans la ligne `(*)`. Sinon, le visiteur devra attendre la première exécution de `setInterval`. Et l'horloge serait vide jusque-là.

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+
# Horloge colorée avec setInterval
66

7-
Create a colored clock like here:
7+
Créez une horloge colorée comme ici :
88

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

11-
Use HTML/CSS for the styling, JavaScript only updates time in elements.
11+
Utilisez HTML/CSS pour le style, JavaScript ne met à jour que le temps dans les éléments.

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+
Lorsque nous devons insérer un morceau de HTML quelque part, `insertAdjacentHTML` est le meilleur choix.
33

4-
The solution:
4+
La solution :
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+
# Insérez le HTML dans la liste
66

7-
Write the code to insert `<li>2</li><li>3</li>` between two `<li>` here:
7+
Écrivez le code pour insérer `<li>2</li><li>3</li>` entre deux `<li>` ici :
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 solution est courte, mais peut sembler un peu délicate, alors ici je la présente avec de nombreux commentaires :
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'algorithme pas à pas :
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. Obtenez tous les `<tr>` de `<tbody>`.
13+
2. Triez-les ensuite en les comparant au contenu du premier `<td>` (le champ du nom).
14+
3. Insérez maintenant les nœuds dans le bon ordre par `.append(...sortedRows)`.
1515

16-
We don't have to remove row elements, just "re-insert", they leave the old place automatically.
16+
Nous n'avons pas à supprimer les éléments de ligne, il suffit de les "réinsérer", ils quittent automatiquement l'ancien emplacement.
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. Dans notre cas, il y a un `<tbody>` explicite dans le tableau, mais même si le tableau HTML n'a pas de `<tbody>`, la structure DOM l'a toujours.

2-ui/1-document/07-modifying-document/12-sort-table/task.md

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

33
---
44

5-
# Sort the table
5+
# Trier le tableau
66

7-
There's a table:
7+
Il y a un tableau :
88

99
```html run
1010
<table>
@@ -30,6 +30,6 @@ There's a table:
3030
</table>
3131
```
3232

33-
There may be more rows in it.
33+
Il peut y avoir plus de lignes.
3434

35-
Write the code to sort it by the `"name"` column.
35+
Écrivez le code pour le trier par la colonne `"name"`.

2-ui/1-document/07-modifying-document/4-clear-elem/solution.md

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

2-
First, let's see how *not* to do it:
2+
Voyons d'abord comment ne *pas* le faire :
33

44
```js
55
function clear(elem) {
@@ -9,11 +9,11 @@ function clear(elem) {
99
}
1010
```
1111

12-
That won't work, because the call to `remove()` shifts the collection `elem.childNodes`, so elements start from the index `0` every time. But `i` increases, and some elements will be skipped.
12+
Cela ne fonctionnera pas, car l'appel à `remove()` décale la collection `elem.childNodes`, donc les éléments commencent à partir de l'index `0` à chaque fois. Mais `i` augmente et certains éléments seront ignorés.
1313

14-
The `for..of` loop also does the same.
14+
La boucle `for..of` fait de même.
1515

16-
The right variant could be:
16+
La bonne variante pourrait être :
1717

1818
```js
1919
function clear(elem) {
@@ -23,7 +23,7 @@ function clear(elem) {
2323
}
2424
```
2525

26-
And also there's a simpler way to do the same:
26+
Et il existe également un moyen plus simple de faire de même :
2727

2828
```js
2929
function clear(elem) {

2-ui/1-document/07-modifying-document/4-clear-elem/task.md

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

33
---
44

5-
# Clear the element
5+
# Effacer l'élément
66

7-
Create a function `clear(elem)` that removes everything from the element.
7+
Créez une fonction `clear(elem)` qui supprime tout de l'élément.
88

99
```html run height=60
1010
<ol id="elem">
@@ -13,8 +13,8 @@ Create a function `clear(elem)` that removes everything from the element.
1313
</ol>
1414

1515
<script>
16-
function clear(elem) { /* your code */ }
16+
function clear(elem) { /* votre code */ }
1717
18-
clear(elem); // clears the list
18+
clear(elem); // efface la liste
1919
</script>
2020
```

0 commit comments

Comments
 (0)