Skip to content

Commit 04beb0b

Browse files
authored
Merge pull request #72 from otmon76/1.2.6
Interaction: alert, prompt, confirm
2 parents 3c8ba94 + 3c3dd2a commit 04beb0b

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
JavaScript-code:
1+
Kód v JavaScriptu:
22

33
```js demo run
4-
let name = prompt("What is your name?", "");
5-
alert(name);
4+
let jméno = prompt("Jak se jmenuješ?", "");
5+
alert(jméno);
66
```
77

8-
The full page:
8+
Celá stránka:
99

1010
```html
1111
<!DOCTYPE html>
@@ -15,8 +15,8 @@ The full page:
1515
<script>
1616
'use strict';
1717
18-
let name = prompt("What is your name?", "");
19-
alert(name);
18+
let jméno = prompt("Jak se jmenuješ?", "");
19+
alert(jméno);
2020
</script>
2121

2222
</body>

1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md

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

33
---
44

5-
# A simple page
5+
# Jednoduchá stránka
66

7-
Create a web-page that asks for a name and outputs it.
7+
Vytvořte webovou stránku, která se zeptá na jméno a pak ho zobrazí.
88

99
[demo]
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
1-
# Interaction: alert, prompt, confirm
1+
# Interakce: alert, prompt, confirm
22

3-
As we'll be using the browser as our demo environment, let's see a couple of functions to interact with the user: `alert`, `prompt` and `confirm`.
3+
Protože jako demonstrační prostředí budeme používat prohlížeč, podíváme se na několik funkcí sloužících k interakci s uživatelem: `alert`, `prompt` a `confirm`.
44

55
## alert
66

7-
This one we've seen already. It shows a message and waits for the user to press "OK".
7+
Tuto funkci jsme už viděli. Zobrazí zprávu a počká, až uživatel stiskne tlačítko „OK“.
88

9-
For example:
9+
Příklad:
1010

1111
```js run
12-
alert("Hello");
12+
alert("Ahoj");
1313
```
1414

15-
The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc, until they have dealt with the window. In this case -- until they press "OK".
15+
Miniokno se zprávou se nazývá *modální okno*. Slovo „modální“ znamená, že uživatel nemůže komunikovat se zbytkem stránky, mačkat jiná tlačítka apod., dokud nevyhodnotí toto okno -- v tomto případě dokud nestiskne „OK“.
1616

1717
## prompt
1818

19-
The function `prompt` accepts two arguments:
19+
Funkce `prompt` přijímá dva argumenty:
2020

2121
```js no-beautify
22-
result = prompt(title, [default]);
22+
výsledek = prompt(titulek, [default]);
2323
```
2424

25-
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel.
25+
Zobrazí modální okno s textovou zprávou, vstupní pole pro návštěvníka a tlačítka OK a Storno.
2626

27-
`title`
28-
: The text to show the visitor.
27+
`titulek`
28+
: Text, který se má zobrazit návštěvníkovi.
2929

3030
`default`
31-
: An optional second parameter, the initial value for the input field.
31+
: Volitelný druhý parametr, úvodní hodnota ve vstupním poli.
3232

33-
```smart header="The square brackets in syntax `[...]`"
34-
The square brackets around `default` in the syntax above denote that the parameter is optional, not required.
33+
```smart header="Hranaté závorky v syntaxi `[...]`"
34+
Hranaté závorky okolo `default` ve výše uvedené syntaxi označují, že parametr je dobrovolný a není vyžadován.
3535
```
3636
37-
The visitor can type something in the prompt input field and press OK. Then we get that text in the `result`. Or they can cancel the input by pressing Cancel or hitting the `key:Esc` key, then we get `null` as the `result`.
37+
Návštěvník může do vstupního pole něco napsat a stisknout OK. Pak získáme napsaný text jako `výsledek`. Nebo může zrušit vstup stisknutím tlačítka Storno nebo klávesy `key:Esc`. Pak jako `výsledek` obdržíme `null`.
3838
39-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
39+
Volání `prompt` vrátí text ze vstupního pole nebo `null`, pokud byl vstup zrušen.
4040
41-
For instance:
41+
Příklad:
4242
4343
```js run
44-
let age = prompt('How old are you?', 100);
44+
let věk = prompt('Kolik je ti let?', 100);
4545
46-
alert(`You are ${age} years old!`); // You are 100 years old!
46+
alert(`Je ti ${věk} let!`); // Je ti 100 let!
4747
```
4848

49-
````warn header="In IE: always supply a `default`"
50-
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
49+
````warn header="Pro IE vždy uvádějte `default`"
50+
Druhý parametr je nepovinný, ale jestliže ho neuvedeme, Internet Explorer vloží do dotazu text `"undefined"`.
5151

52-
Run this code in Internet Explorer to see:
52+
Spusťte si v Internet Exploreru tento kód a uvidíte:
5353

5454
```js run
5555
let test = prompt("Test");
5656
```
5757

58-
So, for prompts to look good in IE, we recommend always providing the second argument:
58+
Aby dotazy vypadaly dobře i v IE, doporučujeme vždy uvádět i druhý argument:
5959

6060
```js run
61-
let test = prompt("Test", ''); // <-- for IE
61+
let test = prompt("Test", ''); // <-- pro IE
6262
```
6363
````
6464
6565
## confirm
6666
67-
The syntax:
67+
Syntaxe:
6868
6969
```js
70-
result = confirm(question);
70+
výsledek = confirm(otázka);
7171
```
7272
73-
The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel.
73+
Funkce `confirm` zobrazí modální okno s otázkou -- v našem případě obsaženou v promenné `otázka` -- a dvěma tlačítky: OK a Storno.
7474
75-
The result is `true` if OK is pressed and `false` otherwise.
75+
Výsledek bude `true`, jestliže uživatel stiskne OK, jinak bude `false`.
7676
77-
For example:
77+
Příklad:
7878
7979
```js run
80-
let isBoss = confirm("Are you the boss?");
80+
let jeŠéf = confirm("Jsi šéf?");
8181
82-
alert( isBoss ); // true if OK is pressed
82+
alert( jeŠéf ); // pokud bylo stisknuto OK, tak true
8383
```
8484
85-
## Summary
85+
## Shrnutí
8686
87-
We covered 3 browser-specific functions to interact with visitors:
87+
Uvedli jsme tři funkce specifické pro prohlížeče, které umožňují interakci s návštěvníky:
8888
8989
`alert`
90-
: shows a message.
90+
: Zobrazí zprávu.
9191
9292
`prompt`
93-
: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`.
93+
: Zobrazí zprávu, která požádá uživatele o zadání textu. Vrátí zadaný text nebo `null`, pokud uživatel stiskl tlačítko Storno nebo klávesu `key:Esc`.
9494
9595
`confirm`
96-
: shows a message and waits for the user to press "OK" or "Cancel". It returns `true` for OK and `false` for Cancel/`key:Esc`.
96+
: Zobrazí zprávu a počká, než uživatel stiskne „OK“ nebo „Storno“. Vrátí `true`, pokud stiskl OK, nebo `false`, pokud stiskl Storno nebo klávesu `key:Esc`.
9797
98-
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
98+
Všechny tyto metody jsou modální: pozastaví vykonávání skriptu a neumožní návštěvníkovi komunikovat se zbytkem stránky, dokud okno nezmizí.
9999
100-
There are two limitations shared by all the methods above:
100+
Všechny uvedené metody mají dvě omezení:
101101
102-
1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
103-
2. The exact look of the window also depends on the browser. We can't modify it.
102+
1. Poloha modálního okna je stanovena prohlížečem. Obvykle je uprostřed.
103+
2. Vzhled okna závisí na prohlížeči. Nelze jej upravit.
104104
105-
That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
105+
To je cena za jednoduchost. Existují jiné způsoby, kde můžete upravit vzhled oken a umožnit bohatší interakci s návštěvníkem, ale pokud nám na těchto věcech příliš nezáleží, tyto metody fungují dobře.

0 commit comments

Comments
 (0)