From 372d95b1a5d5f621b1388c36342d181c7a7022aa Mon Sep 17 00:00:00 2001 From: wahyukmr Date: Mon, 12 Feb 2024 10:09:43 +0700 Subject: [PATCH] translate modifying the document --- .../1-createtextnode-vs-innerhtml/solution.md | 8 +- .../1-createtextnode-vs-innerhtml/task.md | 6 +- .../10-clock-setinterval/solution.md | 26 +- .../solution.view/index.html | 106 ++-- .../source.view/index.html | 16 +- .../10-clock-setinterval/task.md | 8 +- .../11-append-to-list/solution.md | 7 +- .../11-append-to-list/task.md | 7 +- .../12-sort-table/solution.md | 18 +- .../12-sort-table/solution.view/index.html | 53 +- .../12-sort-table/source.view/index.html | 50 +- .../12-sort-table/task.md | 58 +- .../4-clear-elem/solution.md | 17 +- .../4-clear-elem/task.md | 12 +- .../5-why-aaa/solution.md | 10 +- .../07-modifying-document/5-why-aaa/task.md | 14 +- .../6-create-list/solution.md | 2 +- .../6-create-list/solution.view/index.html | 35 +- .../6-create-list/task.md | 18 +- .../build-tree-dom.view/index.html | 82 ++- .../innerhtml.view/index.html | 70 +-- .../7-create-object-tree/solution.md | 6 +- .../source.view/index.html | 59 +- .../7-create-object-tree/task.md | 46 +- .../8-tree-count/solution.md | 2 +- .../8-tree-count/solution.view/index.html | 106 ++-- .../8-tree-count/source.view/index.html | 92 ++-- .../8-tree-count/task.md | 10 +- .../9-calendar-table/solution.md | 14 +- .../9-calendar-table/solution.view/index.html | 120 ++--- .../9-calendar-table/source.view/index.html | 68 ++- .../9-calendar-table/task.md | 14 +- .../07-modifying-document/article.md | 502 +++++++++--------- 33 files changed, 849 insertions(+), 813 deletions(-) diff --git a/2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md b/2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md index a38f01645..cf3ff5476 100644 --- a/2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md +++ b/2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md @@ -1,15 +1,15 @@ -Answer: **1 and 3**. +Jawabannya: **1 dan 3**. -Both commands result in adding the `text` "as text" into the `elem`. +Kedua perintah tersebut mengakibatkan penambahan `text` 'sebagai teks' ke dalam `elem` -Here's an example: +Berikut adalah contohnya: ```html run height=80
+ function clockStop() { + clearInterval(timerId); + timerId = null; // <-- hapus timerID untuk menunjukkan bahwa jam telah dihentikan, sehingga memungkinkan untuk memulainya kembali di clockStart() + } - - + clockStart(); + - - + + - + + + diff --git a/2-ui/1-document/07-modifying-document/10-clock-setinterval/source.view/index.html b/2-ui/1-document/07-modifying-document/10-clock-setinterval/source.view/index.html index ecf5df99a..7e69bbc84 100644 --- a/2-ui/1-document/07-modifying-document/10-clock-setinterval/source.view/index.html +++ b/2-ui/1-document/07-modifying-document/10-clock-setinterval/source.view/index.html @@ -1,12 +1,10 @@ - + - + + + - - - - - - - + + + diff --git a/2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md b/2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md index a1b53e337..163f36cc7 100644 --- a/2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md +++ b/2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md @@ -1,11 +1,11 @@ -importance: 4 +Tingkat kepentingan: 4 --- -# Colored clock with setInterval +# Jam Berwarna dengan setInterval -Create a colored clock like here: +Buatlah jam berwarna seperti di sini: [iframe src="solution" height=60] -Use HTML/CSS for the styling, JavaScript only updates time in elements. +Gunakan HTML/CSS untuk styling, JavaScript hanya untuk memperbarui waktu pada elemen-elemen. diff --git a/2-ui/1-document/07-modifying-document/11-append-to-list/solution.md b/2-ui/1-document/07-modifying-document/11-append-to-list/solution.md index 4e77fb5cb..799f77314 100644 --- a/2-ui/1-document/07-modifying-document/11-append-to-list/solution.md +++ b/2-ui/1-document/07-modifying-document/11-append-to-list/solution.md @@ -1,8 +1,7 @@ +Ketika kita perlu menyisipkan sebagian HTML di suatu tempat, `insertAdjacentHTML` adalah pilihan terbaik. -When we need to insert a piece of HTML somewhere, `insertAdjacentHTML` is the best fit. - -The solution: +Solusi: ```js -one.insertAdjacentHTML('afterend', '
  • 2
  • 3
  • '); +one.insertAdjacentHTML("afterend", "
  • 2
  • 3
  • "); ``` diff --git a/2-ui/1-document/07-modifying-document/11-append-to-list/task.md b/2-ui/1-document/07-modifying-document/11-append-to-list/task.md index 543cd3e46..0684f3831 100644 --- a/2-ui/1-document/07-modifying-document/11-append-to-list/task.md +++ b/2-ui/1-document/07-modifying-document/11-append-to-list/task.md @@ -1,14 +1,15 @@ -importance: 5 +Tingkat kepentingan: 5 --- -# Insert the HTML in the list +# Menyisipkan HTML ke dalam daftar -Write the code to insert `
  • 2
  • 3
  • ` between two `
  • ` here: +Tulis kode untuk menyisipkan `
  • 2
  • 3
  • ` antara dua `
  • ` di sini: ```html ``` diff --git a/2-ui/1-document/07-modifying-document/12-sort-table/solution.md b/2-ui/1-document/07-modifying-document/12-sort-table/solution.md index 49243e8e3..e05669d8a 100644 --- a/2-ui/1-document/07-modifying-document/12-sort-table/solution.md +++ b/2-ui/1-document/07-modifying-document/12-sort-table/solution.md @@ -1,18 +1,20 @@ -The solution is short, yet may look a bit tricky, so here I provide it with extensive comments: +Solusinya singkat, namun mungkin terlihat sedikit rumit, jadi di sini saya berikan dengan komentar yang ekstensif: ```js let sortedRows = Array.from(table.tBodies[0].rows) // 1 - .sort((rowA, rowB) => rowA.cells[0].innerHTML.localeCompare(rowB.cells[0].innerHTML)); + .sort((rowA, rowB) => + rowA.cells[0].innerHTML.localeCompare(rowB.cells[0].innerHTML) + ); table.tBodies[0].append(...sortedRows); // (3) ``` -The step-by-step algorthm: +Algoritma langkah-demi-langkah: -1. Get all ``, from ``. -2. Then sort them comparing by the content of the first `` (the name field). -3. Now insert nodes in the right order by `.append(...sortedRows)`. +1. Dapatkan semua ``, dari ``. +2. Kemudian urutkan mereka dengan membandingkan berdasarkan konten `` pertama (bidang nama). +3. Sekarang masukkan node dengan urutan yang benar dengan `.append(...sortedRows)`. -We don't have to remove row elements, just "re-insert", they leave the old place automatically. +Kita tidak perlu menghapus elemen baris, cukup "memasukkan kembali", karena mereka akan meninggalkan tempat lama secara otomatis. -P.S. In our case, there's an explicit `` in the table, but even if HTML table doesn't have ``, the DOM structure always has it. +P.S. Dalam kasus kita, ada yang eksplisit dalam tabel, tetapi bahkan jika tabel HTML tidak memiliki , struktur DOM selalu memiliki elemen tersebut. diff --git a/2-ui/1-document/07-modifying-document/12-sort-table/solution.view/index.html b/2-ui/1-document/07-modifying-document/12-sort-table/solution.view/index.html index 40692031a..9e436e8cf 100644 --- a/2-ui/1-document/07-modifying-document/12-sort-table/solution.view/index.html +++ b/2-ui/1-document/07-modifying-document/12-sort-table/solution.view/index.html @@ -1,30 +1,41 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameSurnameAge
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    NamaNama BelakangUmur
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    diff --git a/2-ui/1-document/07-modifying-document/12-sort-table/source.view/index.html b/2-ui/1-document/07-modifying-document/12-sort-table/source.view/index.html index 9071c88ee..57875ce34 100644 --- a/2-ui/1-document/07-modifying-document/12-sort-table/source.view/index.html +++ b/2-ui/1-document/07-modifying-document/12-sort-table/source.view/index.html @@ -1,27 +1,37 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameSurnameAge
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    NamaNama BelakangUmur
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    diff --git a/2-ui/1-document/07-modifying-document/12-sort-table/task.md b/2-ui/1-document/07-modifying-document/12-sort-table/task.md index 7cdba35bc..291d31a8a 100644 --- a/2-ui/1-document/07-modifying-document/12-sort-table/task.md +++ b/2-ui/1-document/07-modifying-document/12-sort-table/task.md @@ -1,35 +1,45 @@ -importance: 5 +Tingkat kepentingan: 5 --- -# Sort the table +# Mengurutkan Tabel -There's a table: +Berikut adalah sebuah tabel: ```html run - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameSurnameAge
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    NamaNama BelakangUsia
    JohnSmith10
    PeteBrown15
    AnnLee5
    .........
    ``` -There may be more rows in it. +Mungkin ada lebih banyak baris di dalamnya. -Write the code to sort it by the `"name"` column. +Tulislah kode untuk mengurutkannya berdasarkan kolom `"Nama"`. diff --git a/2-ui/1-document/07-modifying-document/4-clear-elem/solution.md b/2-ui/1-document/07-modifying-document/4-clear-elem/solution.md index 62c3386d8..72cc80aef 100644 --- a/2-ui/1-document/07-modifying-document/4-clear-elem/solution.md +++ b/2-ui/1-document/07-modifying-document/4-clear-elem/solution.md @@ -1,19 +1,18 @@ - -First, let's see how *not* to do it: +Pertama, mari kita lihat cara yang _tidak benar_ untuk melakukannya: ```js function clear(elem) { - for (let i=0; i < elem.childNodes.length; i++) { - elem.childNodes[i].remove(); + for (let i = 0; i < elem.childNodes.length; i++) { + elem.childNodes[i].remove(); } } ``` -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. +Itu tidak akan berfungsi, karena panggilan ke `remove()` menggeser koleksi `elem.childNodes`, sehingga elemen dimulai dari indexs `0` setiap kali. Tetapi `i` terus bertambah, dan beberapa elemen akan terlewat. -The `for..of` loop also does the same. +Loop `for..of` juga melakukan hal yang sama. -The right variant could be: +Variasi yang benar bisa menjadi: ```js function clear(elem) { @@ -23,10 +22,10 @@ function clear(elem) { } ``` -And also there's a simpler way to do the same: +Dan juga ada cara yang lebih sederhana untuk melakukan hal yang sama: ```js function clear(elem) { - elem.innerHTML = ''; + elem.innerHTML = ""; } ``` diff --git a/2-ui/1-document/07-modifying-document/4-clear-elem/task.md b/2-ui/1-document/07-modifying-document/4-clear-elem/task.md index 938d53470..66ebd98a2 100644 --- a/2-ui/1-document/07-modifying-document/4-clear-elem/task.md +++ b/2-ui/1-document/07-modifying-document/4-clear-elem/task.md @@ -1,10 +1,10 @@ -importance: 5 +Tingkat kepentingan: 5 --- -# Clear the element +# Membersihkan elemen -Create a function `clear(elem)` that removes everything from the element. +Buatlah fungsi `clear(elem)` yang menghapus semua konten dari elemen tersebut. ```html run height=60
      @@ -13,8 +13,10 @@ Create a function `clear(elem)` that removes everything from the element.
    ``` diff --git a/2-ui/1-document/07-modifying-document/5-why-aaa/solution.md b/2-ui/1-document/07-modifying-document/5-why-aaa/solution.md index 3d1f6698f..b0006a83f 100644 --- a/2-ui/1-document/07-modifying-document/5-why-aaa/solution.md +++ b/2-ui/1-document/07-modifying-document/5-why-aaa/solution.md @@ -1,9 +1,9 @@ -The HTML in the task is incorrect. That's the reason of the odd thing. +HTML pada tugas tersebut tidak benar. Itulah sebabnya hal yang aneh terjadi. -The browser has to fix it automatically. But there may be no text inside the ``: according to the spec only table-specific tags are allowed. So the browser shows `"aaa"` *before* the `
    `. +_Browser_ harus memperbaikinya secara otomatis. Tetapi mungkin tidak ada teks di dalam `
    `: sesuai dengan spesifikasi, hanya tag khusus tabel yang diizinkan. Jadi, _Browser_ menampilkan `"aaa"` sebelum `
    `. -Now it's obvious that when we remove the table, it remains. +Sekarang jelas bahwa ketika kita menghapus tabel, teks tersebut tetap ada. -The question can be easily answered by exploring the DOM using the browser tools. You'll see `"aaa"` before the `
    `. +Pertanyaan tersebut dapat dengan mudah dijawab dengan menjelajahi DOM menggunakan alat _Browser_. Anda akan melihat `"aaa"` sebelum `
    `. -The HTML standard specifies in detail how to process bad HTML, and such behavior of the browser is correct. +Standar HTML menentukan secara rinci bagaimana cara memproses HTML yang tidak benar, dan perilaku browser seperti itu adalah benar. diff --git a/2-ui/1-document/07-modifying-document/5-why-aaa/task.md b/2-ui/1-document/07-modifying-document/5-why-aaa/task.md index f87074dba..046cc57b2 100644 --- a/2-ui/1-document/07-modifying-document/5-why-aaa/task.md +++ b/2-ui/1-document/07-modifying-document/5-why-aaa/task.md @@ -1,14 +1,14 @@ -importance: 1 +Tingkat kepentingan: 1 --- -# Why does "aaa" remain? +# Mengapa "aaa" masih ada? -In the example below, the call `table.remove()` removes the table from the document. +Pada contoh di bawah, panggilan `table.remove()` menghapus tabel dari dokumen. -But if you run it, you can see that the text `"aaa"` is still visible. +Tetapi jika anda menjalankannya, anda dapat melihat bahwa teks `"aaa"` masih terlihat. -Why does that happen? +Mengapa hal itu terjadi? ```html height=100 run
    @@ -19,9 +19,9 @@ Why does that happen?
    ``` diff --git a/2-ui/1-document/07-modifying-document/6-create-list/solution.md b/2-ui/1-document/07-modifying-document/6-create-list/solution.md index 1669be18f..17fd06fcb 100644 --- a/2-ui/1-document/07-modifying-document/6-create-list/solution.md +++ b/2-ui/1-document/07-modifying-document/6-create-list/solution.md @@ -1 +1 @@ -Please note the usage of `textContent` to assign the `
  • ` content. +Harap perhatikan penggunaan `textContent` untuk menetapkan konten `
  • `. diff --git a/2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html b/2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html index 071645e8d..39b195c5c 100755 --- a/2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html +++ b/2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html @@ -1,24 +1,23 @@ - + - -

    Create a list

    + +

    Membuat daftar

    - + if (!data) { + break; + } - + let li = document.createElement("li"); + li.textContent = data; + ul.append(li); + } + + diff --git a/2-ui/1-document/07-modifying-document/6-create-list/task.md b/2-ui/1-document/07-modifying-document/6-create-list/task.md index a57e7e2d9..914734928 100644 --- a/2-ui/1-document/07-modifying-document/6-create-list/task.md +++ b/2-ui/1-document/07-modifying-document/6-create-list/task.md @@ -1,19 +1,19 @@ -importance: 4 +Tingkat kepentingan: 4 --- -# Create a list +# Membuat daftar -Write an interface to create a list from user input. +Tuliskan antarmuka untuk membuat daftar dari _input_ pengguna. -For every list item: +Untuk setiap item daftar: -1. Ask a user about its content using `prompt`. -2. Create the `
  • ` with it and add it to `