Skip to content

Commit 4ebc8cf

Browse files
committed
2-ui/4-forms-controls/3-events-change-input
1 parent 1c7a55e commit 4ebc8cf

File tree

4 files changed

+67
-67
lines changed

4 files changed

+67
-67
lines changed

2-ui/4-forms-controls/3-events-change-input/1-deposit-calculator/solution.view/index.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@
2323

2424
<body>
2525

26-
Deposit calculator.
26+
Депозитный калькулятор.
2727

2828
<form name="calculator">
2929
<table>
3030
<tr>
31-
<td>Initial deposit</td>
31+
<td>Первоначальный депозит</td>
3232
<td>
3333
<input name="money" type="number" value="10000" required>
3434
</td>
3535
</tr>
3636
<tr>
37-
<td>How many months?</td>
37+
<td>Сколько месяцев?</td>
3838
<td>
3939
<select name="months">
40-
<option value="3">3 (minimum)</option>
41-
<option value="6">6 (half-year)</option>
42-
<option value="12" selected>12 (one year)</option>
43-
<option value="18">18 (1.5 years)</option>
44-
<option value="24">24 (2 years)</option>
45-
<option value="30">30 (2.5 years)</option>
46-
<option value="36">36 (3 years)</option>
47-
<option value="60">60 (5 years)</option>
40+
<option value="3">3 (минимум)</option>
41+
<option value="6">6 (пол года)</option>
42+
<option value="12" selected>12 (год)</option>
43+
<option value="18">18 (1.5 года)</option>
44+
<option value="24">24 (2 года)</option>
45+
<option value="30">30 (2.5 года)</option>
46+
<option value="36">36 (3 года)</option>
47+
<option value="60">60 (5 лет)</option>
4848
</select>
4949
</td>
5050
</tr>
5151
<tr>
52-
<td>Interest per year?</td>
52+
<td>Проценты в год?</td>
5353
<td>
5454
<input name="interest" type="number" value="5" required>
5555
</td>
@@ -62,8 +62,8 @@
6262

6363
<table id="diagram">
6464
<tr>
65-
<th>Was:</th>
66-
<th>Becomes:</th>
65+
<th>Было:</th>
66+
<th>Стало:</th>
6767
</tr>
6868
<tr>
6969
<th id="money-before"></th>

2-ui/4-forms-controls/3-events-change-input/1-deposit-calculator/source.view/index.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@
2323

2424
<body>
2525

26-
Deposit calculator.
26+
Депозитный калькулятор.
2727

2828
<form name="calculator">
2929
<table>
3030
<tr>
31-
<td>Initial deposit</td>
31+
<td>Первоначальный депозит</td>
3232
<td>
3333
<input name="money" type="number" value="10000" required>
3434
</td>
3535
</tr>
3636
<tr>
37-
<td>How many months?</td>
37+
<td>Сколько месяцев?</td>
3838
<td>
3939
<select name="months">
40-
<option value="3">3 (minimum)</option>
41-
<option value="6">6 (half-year)</option>
42-
<option value="12" selected>12 (one year)</option>
43-
<option value="18">18 (1.5 years)</option>
44-
<option value="24">24 (2 years)</option>
45-
<option value="30">30 (2.5 years)</option>
46-
<option value="36">36 (3 years)</option>
47-
<option value="60">60 (5 years)</option>
40+
<option value="3">3 (минимум)</option>
41+
<option value="6">6 (пол года)</option>
42+
<option value="12" selected>12 (год)</option>
43+
<option value="18">18 (1.5 года)</option>
44+
<option value="24">24 (2 года)</option>
45+
<option value="30">30 (2.5 года)</option>
46+
<option value="36">36 (3 года)</option>
47+
<option value="60">60 (5 лет)</option>
4848
</select>
4949
</td>
5050
</tr>
5151
<tr>
52-
<td>Interest per year?</td>
52+
<td>Проценты в год?</td>
5353
<td>
5454
<input name="interest" type="number" value="5" required>
5555
</td>
@@ -62,8 +62,8 @@
6262

6363
<table id="diagram">
6464
<tr>
65-
<th>Was:</th>
66-
<th>Becomes:</th>
65+
<th>Было:</th>
66+
<th>Стало:</th>
6767
</tr>
6868
<tr>
6969
<th id="money-before"></th>
@@ -81,7 +81,7 @@
8181

8282
let form = document.forms.calculator;
8383

84-
// your code
84+
// ваш код
8585
</script>
8686

8787

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
importance: 5
1+
важность: 5
22

33
---
44

5-
# Deposit calculator
5+
# Депозитный калькулятор
66

7-
Create an interface that allows to enter a sum of bank deposit and percentage, then calculates how much it will be after given periods of time.
7+
Создайте интерфейс, позволяющий ввести сумму банковского вклада и процент, а затем рассчитать, сколько он будет через заданные промежутки времени.
88

9-
Here's the demo:
9+
Демо-версия:
1010

1111
[iframe src="solution" height="350" border="1"]
1212

13-
Any input change should be processed immediately.
13+
Любое изменение входа должно быть обработано немедленно.
1414

15-
The formula is:
15+
Формула:
1616
```js
17-
// initial: the initial money sum
18-
// interest: e.g. 0.05 means 5% per year
19-
// years: how many years to wait
17+
// initial: начальная сумма денег
18+
// interest: проценты, например, 0,05 означает 5% в год
19+
// years: сколько лет ждать
2020
let result = Math.round(initial * (1 + interest * years));
2121
```
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Events: change, input, cut, copy, paste
1+
# События: change, input, cut, copy, paste
22

3-
Let's discuss various events that accompany data updates.
3+
Давайте обсудим различные события, сопутствующие обновлению данных.
44

5-
## Event: change
5+
## Событие: change
66

7-
The [change](http://www.w3.org/TR/html5/forms.html#event-input-change) event triggers when the element has finished changing.
7+
Событие [change] (http://www.w3.org/TR/html5/forms.html#event-input-change) срабатывает по окончании изменения элемента.
88

9-
For text inputs that means that the event occurs when it loses focus.
9+
Для текстовых инпутов это означает, что событие происходит при потере фокуса.
1010

11-
For instance, while we are typing in the text field below -- there's no event. But when we move the focus somewhere else, for instance, click on a button -- there will be a `change` event:
11+
Например, пока мы печатаем в текстовом поле в примере ниже, события нет. Но когда мы перемещаем фокус, например, в другое место, нажмите на кнопку - произойдёт событие `change`:
1212

1313
```html autorun height=40 run
1414
<input type="text" onchange="alert(this.value)">
1515
<input type="button" value="Button">
1616
```
1717

18-
For other elements: `select`, `input type=checkbox/radio` it triggers right after the selection changes.
18+
Для других элементов: `select`, `input type=checkbox/radio` событие запускается сразу после изменения выбора.
1919

20-
## Event: input
20+
## Событие: input
2121

22-
The `input` event triggers every time a value is modified.
22+
Событие `input` срабатывает каждый раз при изменении значения.
2323

24-
For instance:
24+
Например:
2525

2626
```html autorun height=40 run
2727
<input type="text" id="input"> oninput: <span id="result"></span>
@@ -32,25 +32,25 @@ For instance:
3232
</script>
3333
```
3434

35-
If we want to handle every modification of an `<input>` then this event is the best choice.
35+
Если мы хотим обрабатывать каждое изменение в `<input>`, то это событие является лучшим выбором.
3636

37-
Unlike keyboard events it works on any value change, even those that does not involve keyboard actions: pasting with a mouse or using speech recognition to dictate the text.
37+
В отличие от клавиатурных событий, он работает при любых изменениях значений, даже если они не связаны с клавиатурными действиями: вставка с помощью мыши или распознавание речи для диктата текста.
3838

39-
```smart header="Can't prevent anything in `oninput`"
40-
The `input` event occurs after the value is modified.
39+
```smart header="Нельзя ничего предотвратить в `oninput`"
40+
Событие `input` происходит после изменения значения.
4141

42-
So we can't use `event.preventDefault()` there -- it's just too late, there would be no effect.
42+
Поэтому мы не можем использовать `event.preventDefault()` там - будет уже слишком поздно, никакого эффекта не будет.
4343
```
4444
45-
## Events: cut, copy, paste
45+
## События: cut, copy, paste
4646
47-
These events occur on cutting/copying/pasting a value.
47+
Эти события происходят при вырезании/копировании/вставке значения.
4848
49-
They belong to [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) class and provide access to the data that is copied/pasted.
49+
Они относятся к классу [ClipboardEvent] (https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) и обеспечивают доступ к копируемым/вставляемым данным.
5050
51-
We also can use `event.preventDefault()` to abort the action.
51+
Мы также можем использовать `event.preventDefault()` для прерывания действия.
5252
53-
For instance, the code below prevents all such events and shows what we are trying to cut/copy/paste:
53+
Например, код, приведённый ниже, предотвращает все подобные события и показывает, что мы пытаемся вырезать/копировать/вставить:
5454
5555
```html autorun height=40 run
5656
<input type="text" id="input">
@@ -62,18 +62,18 @@ For instance, the code below prevents all such events and shows what we are tryi
6262
</script>
6363
```
6464

65-
Technically, we can copy/paste everything. For instance, we can copy a file in the OS file manager, and paste it.
65+
Технически, мы можем скопировать/вставить всё. Например, мы можем скопировать файл в файловый менеджер ОС и вставить его.
6666

67-
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) to work with different data types, read/write to the clipboard.
67+
Существует список методов [в спецификации] (https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) для работы с различными типами данных, чтения/записи в буфер обмена.
6868

69-
But please note that clipboard is a "global" OS-level thing. Most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety. Also it is forbidden to create "custom" clipboard events in all browsers except Firefox.
69+
Но обратите внимание, что буфер обмена - это "глобальный" уровень ОС. Большинство браузеров разрешают доступ на чтение/запись в буфер обмена только в рамках определённых действий пользователя для безопасности. Также запрещается создавать "пользовательские" события буфера обмена во всех браузерах, кроме Firefox.
7070

71-
## Summary
71+
## Итого
7272

73-
Data change events:
73+
События изменения данных:
7474

75-
| Event | Description | Specials |
75+
| Событие | Описание | Особенности |
7676
|---------|----------|-------------|
77-
| `change`| A value was changed. | For text inputs triggers on focus loss. |
78-
| `input` | For text inputs on every change. | Triggers immediately unlike `change`. |
79-
| `cut/copy/paste` | Cut/copy/paste actions. | The action can be prevented. The `event.clipboardData` property gives read/write access to the clipboard. |
77+
| `change`| Значение было изменено. | Для текстовых входов срабатывает при потере фокуса. |
78+
| `input` | Для ввода текста при каждом изменении. | Запускается немедленно, в отличие от `change`. |
79+
| `cut/copy/paste` | Действия по вырезанию/копированию/вставке. | Действие можно предотвратить. Свойство `event.clipboardData` предоставляет доступ на чтение/запись в буфер обмена.. |

0 commit comments

Comments
 (0)