Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 2-ui/1-document/07-modifying-document/6-create-list/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ importance: 4

---

# Bir Liste Olustur
# Create a List

Kullanıcı girdisinden bir liste oluşturmak için bir arayüz yazın.

Her liste maddesi için:

1. 'Komut istem'(`prompt`)i kullanarak bir kullanıcıya içeriği hakkında sorun.
2.Onunla `<li>`yi yarat ve onu `<ul>`ye ekle. Create the `<li>` with it and add it to `<ul>`.
2.Onunla `<li>`yi yarat ve onu `<ul>`ye ekle.
3. Kullanıcı girişi iptal edene kadar devam edin (komut isteminde `tuş:Esc` veya CANCEL'a basarak).

Tüm elenetler dinamik olarak oluşturulmalıdır.
Tüm elementler dinamik olarak oluşturulmalıdır.

Eğer bir kullanıcı HTML etiketleri(tags) yazıyorsa, metin gibi davranılmalıdır.
Eğer bir kullanıcı HTML etiketleri(tags) yazıyorsa, onlara metin gibi davranılmalıdır.

[demo src="solution"]
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
}

function createTreeDom(obj) {
// if there's no children, then the call returns undefined
// and the <ul> won't be created
// Hiç çocuk yoksa, o zaman çağrı dönüşleri tanımlanamaz
// ve <ul> oluşturulamayacaktır
if (!Object.keys(obj).length) return;

let ul = document.createElement('ul');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
container.innerHTML = createTreeText(obj);
}

function createTreeText(obj) { // standalone recursive function
function createTreeText(obj) { // bağımsız özyinelemeli fonksiyon
let li = '';
let ul;
for (let key in obj) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The easiest way to walk the object is to use recursion.
Nesneyi gezmenin en kolay yolu özyineleme kullanmaktır.

1. [The solution with innerHTML](sandbox:innerhtml).
2. [The solution with DOM](sandbox:build-tree-dom).
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<div id="tree"></div>

<!-- The result should be:
<!-- Sonuç şöyle olmalıdır:
<div id="tree">
<ul>
<li>Fish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ importance: 5

# Create a tree from the object

Write a function `createTree` that creates a nested `ul/li` list from the nested object.
İçiçe geçmiş nesneden, içiçe geçmiş bir `ul/li` listesi oluşturan bir "createTree" fonksiyonu yazın.

For instance:
Örneğin:

```js
let data = {
Expand All @@ -28,7 +28,7 @@ let data = {
};
```

The syntax:
Sözdizimi (syntax):

```js
let container = document.getElementById('container');
Expand All @@ -37,15 +37,15 @@ createTree(container, data); // creates the tree in the container
*/!*
```

The result (tree) should look like this:
Sonuç (ağaç) şöyle görünmeli:

[iframe border=1 src="build-tree-dom"]

Choose one of two ways of solving this task:
Bu görevi çözmenin iki yolundan birini seçin:

1. Create the HTML for the tree and then assign to `container.innerHTML`.
2. Create tree nodes and append with DOM methods.
1. Ağaç için HTML oluşturun ve ardından `container.innerHTML`ye atayın.
2. Ağaç düğümleri (tree nodes) oluşturun ve DOM yöntemleriyle sonuna ekleyin.

Would be great if you could do both.
Eğer her ikisini de yapabilirseniz harika olur.

P.S. The tree should not have "extra" elements like empty `<ul></ul>` for the leaves.
Not: Ağacın yapraklar için boş `<ul></ul>` gibi "fazladan" öğeleri olmamalıdır.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
To append text to each `<li>` we can alter the text node `data`.
Metni her bir `<li>`nin sonuna eklemek için, metin düğümü (text node) `data`sını değiştiririz.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ul>

<script>
// ... your code ...
// ... sizin kodunuz ...
</script>

</body>
Expand Down
6 changes: 3 additions & 3 deletions 2-ui/1-document/07-modifying-document/8-tree-count/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ importance: 5

# Show descendants in a tree

There's a tree organized as nested `ul/li`.
`ul/li` olarak iç içe geçmiş bir ağaç var.

Write the code that adds to each `<li>` the number of its descendants. Skip leaves (nodes without children).
Her bir `<li>` nin neslinden gelenlerin sayısını ekleyen kodu yazın. Yaprakları geçin (çocuksuz düğümler).

The result:
Sonuç:

[iframe border=1 src="solution"]
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@
<script>
function createCalendar(elem, year, month) {

let mon = month - 1; // months in JS are 0..11, not 1..12
let mon = month - 1; // JS'da aylar 0..11'dir, 1..12 değildir
let d = new Date(year, mon);

let table = '<table><tr><th>MO</th><th>TU</th><th>WE</th><th>TH</th><th>FR</th><th>SA</th><th>SU</th></tr><tr>';

// spaces for the first row
// from Monday till the first day of the month
// ilk satır için yer
// Pazartesi'den ayın ilk gününe kadar
// * * * 1 2 3 4
for (let i = 0; i < getDay(d); i++) {
table += '<td></td>';
}

// <td> with actual dates
// asıl tarihlerle <td>
while (d.getMonth() == mon) {
table += '<td>' + d.getDate() + '</td>';

if (getDay(d) % 7 == 6) { // sunday, last day of week - newline
if (getDay(d) % 7 == 6) { // Pazar günü, haftanın son günü - yeni satır
table += '</tr><tr>';
}

d.setDate(d.getDate() + 1);
}

// add spaces after last days of month for the last row
// ayın son günlerinden sonra, son satır için boş yer ekleyin
// 29 30 31 * * * *
if (getDay(d) != 0) {
for (let i = getDay(d); i < 7; i++) {
table += '<td></td>';
}
}

// close the table
// tabloyu kapat
table += '</tr></table>';

elem.innerHTML = table;
}

function getDay(date) { // get day number from 0 (monday) to 6 (sunday)
function getDay(date) { // 0 (pazartesi günü)n'den 6 (pazar günü)'ne kadar gün numarası alın
let day = date.getDay();
if (day == 0) day = 7; // make Sunday (0) the last day
if (day == 0) day = 7; // Pazar günü (0) son gün
return day - 1;
}

Expand Down