Skip to content

Commit 2d00a7f

Browse files
authored
Merge pull request #186 from msisaifu/modifying-document
Modifying the document
2 parents 8dd2bcc + ce5a9f1 commit 2d00a7f

File tree

22 files changed

+221
-222
lines changed

22 files changed

+221
-222
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Answer: **1 and 3**.
1+
উত্তরটি হল: **1 and 3**
22

3-
Both commands result in adding the `text` "as text" into the `elem`.
3+
উভয়ই কমান্ড ফলাফল হিসেবে `elem` `text` সংযোগ করে।
44

5-
Here's an example:
5+
এখানে একটি উদাহরণ দেখুন:
66

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

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

+2-2
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+
আমাদের একটি খালি DOM এলিমেন্ট `elem` এবং একটি `text` স্ট্রিং আছে।
88

9-
Which of these 3 commands do exactly the same?
9+
৩টি কমান্ডের মধ্যে কোন দুইটি একই কাজ করে?
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
First, let's make HTML/CSS.
1+
শুরুতে HTML/CSS তৈরি করি।
22

3-
Each component of the time would look great in its own `<span>`:
3+
প্রতিটি কম্পোনেন্টকে `<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+
আমাদের CSS ও পরিবর্তন করতে হবে।
1212

13-
The `update` function will refresh the clock, to be called by `setInterval` every second:
13+
`update` ফাংশনটি `setInterval` দ্বারা প্রতিসেকেন্ডে কল হয়:
1414

1515
```js
1616
function update() {
@@ -32,9 +32,9 @@ 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+
`(*)` এই লাইনে আমরা প্রতিবারের তারিখটি পরীক্ষা করি। এ ক্ষেত্রে `setInterval` নির্ভরযোগ্য নাও হতে পারে: এটি কিছু সময় নিতে পারে।
3636

37-
The clock-managing functions:
37+
আমাদের ফাংশনগুলো হবে:
3838

3939
```js
4040
let timerId;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ importance: 4
22

33
---
44

5-
# Colored clock with setInterval
5+
# একটি ঘড়ি
66

7-
Create a colored clock like here:
7+
এইরকম একটি ঘড়ি বানান:
88

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

11-
Use HTML/CSS for the styling, JavaScript only updates time in elements.
11+
HTML/CSS এর সাহায্যে স্ট্যাইল করুন, জাভস্ক্রিপ্টের সাহায্যে শুধু সময়টি পরিবর্তন করুন।

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

+3-3
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.
3-
4-
The solution:
2+
আমাদের HTML এর কোন একটি অংশে লিখার জন্য, `insertAdjacentHTML` সবচেয়ে বেশি উপযোগী।
3+
4+
সমাধানটি হল:
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

+2-2
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+
# লিস্টকে HTML এ লিখা
66

7-
Write the code to insert `<li>2</li><li>3</li>` between two `<li>` here:
7+
এই লিস্টকে `<li>2</li><li>3</li>` নিচের দুইটি `<li>` এর মাঝে লিখুন:
88

99
```html
1010
<ul id="ul">
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+
এটি খুব সহজেই করা যায়, তবে এটি কিছুটা ট্রিকি, এখানে বিস্তারিত আলোচনা করা হল:
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+
এখানে ধাপে ধাপে অ্যালগরিদমটি আলোচনা করা হল:
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. `<tbody>` হতে সকল `<tr>` কে নিই।
13+
2. তারপর আমরা `<td>` কে কম্পেয়ার করব (name ফিল্ডটি অনুযায়ী)।
14+
3. এখন আমরা সঠিক নোড অনুযায়ী তাদের সংযুক্ত করব `.append(...sortedRows)`
1515

16-
We don't have to remove row elements, just "re-insert", they leave the old place automatically.
16+
আমাদের রো এলিমেন্টকে রিমুভ করতে হবে না, শুধুমাত্র "re-insert", স্বয়ংক্রিয়ভাবে পুরনো জায়গা গুলো ঠিক হয়ে যায়।
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+
বি.দ্র. এক্ষেত্রে, *table*`<tbody>` বিদ্যমান, কিন্তু অনেক সময় `<tbody>` নাও থাকতে পারে, কিন্তু DOM এ সর্বদা এটি থাকে।

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Sort the table
5+
# table টিকে সর্ট করুন
66

7-
There's a table:
7+
একটি table আছে:
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+
এখানে আরো বেশি রো থাকতে পারে।
3434

35-
Write the code to sort it by the `"name"` column.
35+
`"name"` অনুযায়ী কলামটিকে সর্ট করুন।

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
First, let's see how *not* to do it:
2+
প্রথমত, লক্ষ্য করুন, আমাদের এটি এভাবে করা উচিত হবে না:
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+
এটি কাজ করবে নাহ, কেননা `remove()` কলে আমাদের `elem.childNodes` কালেকশনে কিছু পরিবর্তন হয়, সুতরাং এলিমেন্টটি সবসময় `0` থেকে শুরু হয়। কিন্তু `i` বৃদ্ধি পায়, এবং কিছু এলিমেন্ট বাদ পড়ে যায়।
1313

14-
The `for..of` loop also does the same.
14+
`for..of` দ্বারাও কাজ করবে না।
1515

16-
The right variant could be:
16+
সঠিক উপায়টি হল:
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+
এবং আরো সহজে আমরা এভাবে করতে পারি:
2727

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 5
44

55
# Clear the element
66

7-
Create a function `clear(elem)` that removes everything from the element.
7+
একটি ফাংশন লিখুন `clear(elem)` যা এলিমেন্ট হতে সকল কিছু রিমুভ করে।
88

99
```html run height=60
1010
<ol id="elem">
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
The HTML in the task is incorrect. That's the reason of the odd thing.
1+
আমাদের টাস্কটিই ভুল। যে কারণে আমরা এমন অনাকাঙ্ক্ষিত ঘটনার সম্মুখীন হচ্ছি।
22

3-
The browser has to fix it automatically. But there may be no text inside the `<table>`: according to the spec only table-specific tags are allowed. So the browser adds `"aaa"` *before* the `<table>`.
3+
ব্রাউজার আমাদের ভুল HTML কে স্বয়ংক্রিয়ভাবে ঠিক করে। `<table>` এর মধ্যে কোন টেক্সট থাকতে পারবে না: স্পেসিফিকেশন অনুযায়ী *table* এ শুধুমাত্র table স্পেসিফিক ট্যাগ থাকতে পারবে। সুতরাং ব্রাউজার `"aaa"` কে `<table>` এর *পূর্বে* যুক্ত করে।
44

5-
Now it's obvious that when we remove the table, it remains.
5+
এবং এর ফলে আমরা *table* কে রিমুভ করলেও টেক্সট রয়ে যায়।
66

7-
The question can be easily answered by exploring the DOM using the browser tools. It shows `"aaa"` before the `<table>`.
7+
আমরা ব্রাউজার টুলের সাহায্যে দেখলে আরো পরিষ্কারভাবে বুঝতে পারব। `"aaa"` কে `<table>` এর পূর্বে দেখাবে।
88

9-
The HTML standard specifies in detail how to process bad HTML, and such behavior of the browser is correct.
9+
HTML স্ট্যান্ডার্ডে আমাদের ভুল HTML সমূহকে কিভাবে প্রসেস করবে তা আলোচনা করা হয়েছে, এবং এক্ষেত্রে ব্রাউজার এটিকে স্বয়ংক্রিয়ভাবে ঠিক করে।

2-ui/1-document/07-modifying-document/5-why-aaa/task.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 1
22

33
---
44

5-
# Why does "aaa" remain?
5+
# কেন "aaa" অবশিষ্ট থাকে?
66

7-
In the example below, the call `table.remove()` removes the table from the document.
7+
নিচের উদাহরণে, `table.remove()` এর মাধ্যমে ডকুমেন্ট হতে টেবিল টি রিমুভ করা হয়।
88

9-
But if you run it, you can see that the text `"aaa"` is still visible.
9+
কিন্তু যদি আমরা এটি রান করি, তাহলে আমরা `"aaa"` কে ডকুমেন্টে দেখব।
1010

11-
Why does that happen?
11+
কেন এটি রয়ে যায়?
1212

1313
```html height=100 run
1414
<table id="table">
@@ -22,6 +22,6 @@ Why does that happen?
2222
alert(table); // the table, as it should be
2323
2424
table.remove();
25-
// why there's still aaa in the document?
25+
// কেন ডকুমেন্টে "aaa" অবশিষ্ট রয়ে গেল?
2626
</script>
2727
```
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Please note the usage of `textContent` to assign the `<li>` content.
1+
দয়া করে নোট করুন `<li>` এর কন্টেন্ট হিসেবে অ্যাসাইন করতে আমরা `textContent` ব্যবহার করব।

2-ui/1-document/07-modifying-document/6-create-list/task.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 4
22

33
---
44

5-
# Create a list
5+
# একটি লিস্ট তৈরি
66

7-
Write an interface to create a list from user input.
7+
একটি ইন্টারফেস লিখুন যা ইউজার ইনপুট হতে একটি লিস্ট তৈরি করে।
88

9-
For every list item:
9+
প্রতিটি লিস্ট আইটেম:
1010

11-
1. Ask a user about its content using `prompt`.
12-
2. Create the `<li>` with it and add it to `<ul>`.
13-
3. Continue until the user cancels the input (by pressing `key:Esc` or CANCEL in prompt).
11+
1. ইউজার হতে কন্টেন্ট নিবে `prompt` এর মাধ্যমে।
12+
2. `<li>` তৈরি করবে এবং একে `<ul>` এর মধ্যে সংযুক্ত করবে।
13+
3. ইউজার ক্যান্সেল করার পূর্ব পর্যন্ত এটি চলতে থাকবে (`key:Esc` চাপার মাধ্যমে এটি ক্যান্সেল হয়)।
1414

15-
All elements should be created dynamically.
15+
সকল এলিমেন্ট স্বয়ংক্রিয়ভাবে তৈরি হয়।
1616

17-
If a user types HTML-tags, they should be treated like a text.
17+
যদি ইউজার HTML-tags টাইপ করে, এটি টেক্সট হিসেবে কাজ করবে।
1818

1919
[demo src="solution"]
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The easiest way to walk the object is to use recursion.
1+
সবচেয়ে সহজ উপায়টি হল রিকার্সিভলি অবজেক্টকে ইটারেট করা।
22

33
1. [The solution with innerHTML](sandbox:innerhtml).
44
2. [The solution with DOM](sandbox:build-tree-dom).

2-ui/1-document/07-modifying-document/7-create-object-tree/task.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Create a tree from the object
5+
# অবজেক্ট হতে একটি ট্রি তৈরি করুন
66

7-
Write a function `createTree` that creates a nested `ul/li` list from the nested object.
7+
`createTree` নামের একটি ফাংশন লিখুন যেটি একটি নেস্টেড `ul/li` লিস্ট ক্রিয়েট করবে একটি নেস্টেড অবজেক্ট হতে।
88

9-
For instance:
9+
উদাহরণস্বরূপ:
1010

1111
```js
1212
let data = {
@@ -28,7 +28,7 @@ let data = {
2828
};
2929
```
3030

31-
The syntax:
31+
সিন্ট্যাক্সটি:
3232

3333
```js
3434
let container = document.getElementById('container');
@@ -37,15 +37,15 @@ createTree(container, data); // creates the tree in the container
3737
*/!*
3838
```
3939

40-
The result (tree) should look like this:
40+
ফলাফলটি দেখতে এমন হবে:
4141

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

44-
Choose one of two ways of solving this task:
44+
নিচের যে কোন একটি উপায়ে এট সমাধান করুন:
4545

46-
1. Create the HTML for the tree and then assign to `container.innerHTML`.
47-
2. Create tree nodes and append with DOM methods.
46+
1. HTML ট্রি নোডটি তৈরি করে `container.innerHTML` এ অ্যাসাইন করুন।
47+
2. ট্রি নোড তৈরি করে DOM মেথডের সাহায্যে সংযুক্ত করা।
4848

49-
Would be great if you could do both.
49+
যদি আপনি দুই উপায়েই করতে পারেন এটি আরো ভালো হবে।
5050

51-
P.S. The tree should not have "extra" elements like empty `<ul></ul>` for the leaves.
51+
বি.দ্র. ট্রি টিতে কোন "অতিরিক্ত" এম্পটি `<ul></ul>` থাকবে না।
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
To append text to each `<li>` we can alter the text node `data`.
1+
আমরা `<li>` এ টেক্সট নোডের `data` প্রপার্টির সাথে মানটি যুক্ত করে দিব।

2-ui/1-document/07-modifying-document/8-tree-count/solution.view/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
let lis = document.getElementsByTagName('li');
4444

4545
for (let li of lis) {
46-
// get the count of all <li> below this <li>
46+
// সকল লিস্টকে গণনা <li> below this <li>
4747
let descendantsCount = li.getElementsByTagName('li').length;
4848
if (!descendantsCount) continue;
4949

50-
// add directly to the text node (append to the text)
50+
// মানটি লিখা
5151
li.firstChild.data += ' [' + descendantsCount + ']';
5252
}
5353
</script>

2-ui/1-document/07-modifying-document/8-tree-count/task.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ importance: 5
22

33
---
44

5-
# Show descendants in a tree
5+
# UL এর নেস্টেড লিস্ট এর সংখ্যা
66

7-
There's a tree organized as nested `ul/li`.
7+
একটি `ul/li` এর ট্রি আছে।
88

9-
Write the code that adds to each `<li>` the number of its descendants. Skip leaves (nodes without children).
9+
প্রতিটি `ul` এর অধীনে কতটি `<li>` আছে দেখান। (চিল্ড্রেন ব্যাতীত) নোড সমূহ বাদ যাবে।
1010

11-
The result:
11+
ফলাফলটি হবে:
1212

1313
[iframe border=1 src="solution"]
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
We'll create the table as a string: `"<table>...</table>"`, and then assign it to `innerHTML`.
1+
আমরা টেবল টি জেনারেট করে: `"<table>...</table>"`, এই প্রপার্টিতে `innerHTML` সেট করে দিব।
22

3-
The algorithm:
3+
ধাপসমূহ হবে:
44

5-
1. Create the table header with `<th>` and weekday names.
6-
2. Create the date object `d = new Date(year, month-1)`. That's the first day of `month` (taking into account that months in JavaScript start from `0`, not `1`).
7-
3. First few cells till the first day of the month `d.getDay()` may be empty. Let's fill them in with `<td></td>`.
8-
4. Increase the day in `d`: `d.setDate(d.getDate()+1)`. If `d.getMonth()` is not yet the next month, then add the new cell `<td>` to the calendar. If that's a Sunday, then add a newline <code>"&lt;/tr&gt;&lt;tr&gt;"</code>.
9-
5. If the month has finished, but the table row is not yet full, add empty `<td>` into it, to make it square.
5+
1. প্রথমে হেডার রো তৈরি `<th>` করি এবং সপ্তাহের নাম লিখি।
6+
2. *date* অবজেক্ট করি `d = new Date(year, month-1)`। এবং `month` এর প্রথম দিনটি নেব (জাভাস্ক্রিপ্টে মাস শুরু হয় `0` হতে, `1` হতে না)।
7+
3. শুরুর কয়েকটি সেল `d.getDay()` খালি হতে পারে। তাদের এম্পটি `<td></td>` দ্বারা পূর্ণ করুন।
8+
4. দিনের মান বৃদ্ধি করুন `d`: `d.setDate(d.getDate()+1)`। যদি `d.getMonth()` পরবর্তী মাস না হয়, তাহলে ক্যালেন্ডারে তারিখটি লিখুন `<td>`। যদি দিনটি রবিবার হয়, তাহলে নতুন লাইনে যান <code>"&lt;/tr&gt;&lt;tr&gt;"</code>
9+
5. যদি সম্পূর্ণ মাসটি শেষ হয়, এবং টেবলটি সম্পূর্ণ না হয়, খালি `<td>` দ্বারা পূর্ণ করুন।

2-ui/1-document/07-modifying-document/9-calendar-table/task.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ importance: 4
22

33
---
44

5-
# Create a calendar
5+
# ক্যালেন্ডার লিখা
66

7-
Write a function `createCalendar(elem, year, month)`.
7+
একটি ফাংশন লিখুন `createCalendar(elem, year, month)`
88

9-
The call should create a calendar for the given year/month and put it inside `elem`.
9+
ফাংশন কলে `elem` এর মধ্যে একটি ক্যালেন্ডার তৈরি হবে মাস এবং বছর অনুযায়ী।
1010

11-
The calendar should be a table, where a week is `<tr>`, and a day is `<td>`. The table top should be `<th>` with weekday names: the first day should be Monday, and so on till Sunday.
11+
ক্যালেন্ডারটি একটি *table* এ হবে, যেখানে সপ্তাহসমূহ হবে `<tr>` এ, এবং দিনগুলো থাকবে `<td>` এ। এবং একদম উপরের রোতে `<th>` সপ্তাহের দিন গুলোর নাম থাকবে: সপ্তাহ শুরু হবে সোমবার দিয়ে, এবং শেষ হবে রবিবারে।
1212

13-
For instance, `createCalendar(cal, 2012, 9)` should generate in element `cal` the following calendar:
13+
যেমন, `createCalendar(cal, 2012, 9)` এই এলিমেন্টের `cal` জন্য নিচের ক্যালেন্ডারটি বানাবে:
1414

1515
[iframe height=210 src="solution"]
1616

17-
P.S. For this task it's enough to generate the calendar, should not yet be clickable.
17+
বি.দ্র. এই টাস্কটিতে শুধু ক্যালেন্ডারটি জেনারেট করলেই হবে, অন্য কোন ফাংশনালিটির প্রয়োজন নেই।

0 commit comments

Comments
 (0)