From 2bfd18a923164631fc9c3de9a7c0218d749a322c Mon Sep 17 00:00:00 2001 From: Otmar Onderek Date: Mon, 18 Apr 2022 22:28:59 +0200 Subject: [PATCH 1/7] 1.2.6 --- .../1-simple-page/solution.md | 12 +-- .../1-simple-page/task.md | 4 +- .../06-alert-prompt-confirm/article.md | 82 +++++++++---------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md index 903ee7ff3..3fb06b6d6 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md @@ -1,11 +1,11 @@ -JavaScript-code: +Kód v JavaScriptu: ```js demo run -let name = prompt("What is your name?", ""); -alert(name); +let jméno = prompt("Jak se jmenuješ?", ""); +alert(jméno); ``` -The full page: +Celá stránka: ```html @@ -15,8 +15,8 @@ The full page: diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md index a65a654e0..52d3ac346 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md @@ -2,8 +2,8 @@ importance: 4 --- -# A simple page +# Jednoduchá stránka -Create a web-page that asks for a name and outputs it. +Vytvořte webovou stránku, která se zeptá na jméno a pak je zobrazí. [demo] diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index ef0f333cb..443af2762 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -1,105 +1,105 @@ -# Interaction: alert, prompt, confirm +# Interakce: alert, prompt, confirm -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`. +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`. ## alert -This one we've seen already. It shows a message and waits for the user to press "OK". +Tuto funkci jsme už viděli. Zobrazí zprávu a počká, až uživatel stiskne tlačítko „OK“. -For example: +Příklad: ```js run -alert("Hello"); +alert("Ahoj"); ``` -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". +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“. ## prompt -The function `prompt` accepts two arguments: +Funkce `prompt` přijímá dva argumenty: ```js no-beautify -result = prompt(title, [default]); +výsledek = prompt(titulek, [default]); ``` -It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel. +Zobrazí modální okno s textovou zprávou, vstupní pole pro návštěvníka a tlačítka OK a Storno. -`title` -: The text to show the visitor. +`titulek` +: Text, který se má zobrazit návštěvníkovi. `default` -: An optional second parameter, the initial value for the input field. +: Volitelný druhý parametr, úvodní hodnota ve vstupním poli. -```smart header="The square brackets in syntax `[...]`" -The square brackets around `default` in the syntax above denote that the parameter is optional, not required. +```smart header="Hranaté závorky v syntaxi `[...]`" +Hranaté závorky okolo `default` ve výše uvedené syntaxi označují, že parametr je dobrovolný a není vyžadován. ``` -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`. +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`. -The call to `prompt` returns the text from the input field or `null` if the input was canceled. +Volání `prompt` vrátí text ze vstupního pole nebo `null`, pokud byl vstup zrušen. -For instance: +Příklad: ```js run -let age = prompt('How old are you?', 100); +let věk = prompt('Kolik je ti let?', 100); -alert(`You are ${age} years old!`); // You are 100 years old! +alert(`Je ti ${věk} let!`); // Je ti 100 let! ``` -````warn header="In IE: always supply a `default`" -The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt. +````warn header="Pro IE vždy uvádějte `default`" +Druhý parametr je nepovinný, ale jestliže ho neuvedeme, Internet Explorer vloží do dotazu text `"undefined"`. -Run this code in Internet Explorer to see: +Spusťte si v Internet Exploreru tento kód a uvidíte: ```js run let test = prompt("Test"); ``` -So, for prompts to look good in IE, we recommend always providing the second argument: +Aby dotazy vypadaly dobře i v IE, doporučujeme vždy uvádět i druhý argument: ```js run -let test = prompt("Test", ''); // <-- for IE +let test = prompt("Test", ''); // <-- pro IE ``` ```` ## confirm -The syntax: +Syntaxe: ```js -result = confirm(question); +výsledek = confirm(otázka); ``` -The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel. +Funkce `confirm` zobrazí modální okno s otázkou `otázka` a dvěma tlačítky: OK a Storno. -The result is `true` if OK is pressed and `false` otherwise. +Výsledek bude `true`, jestliže uživatel stiskne OK, jinak bude `false`. -For example: +Příklad: ```js run -let isBoss = confirm("Are you the boss?"); +let jeŠéf = confirm("Jsi šéf?"); -alert( isBoss ); // true if OK is pressed +alert( jeŠéf ); // pokud bylo stisknuto OK, tak true ``` -## Summary +## Shrnutí -We covered 3 browser-specific functions to interact with visitors: +Uvedli jsme tři funkce specifické pro prohlížeče, které umožňují interakci s uživatelem: `alert` -: shows a message. +: Zobrazí zprávu. `prompt` -: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`. +: 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`. `confirm` -: shows a message and waits for the user to press "OK" or "Cancel". It returns `true` for OK and `false` for Cancel/`key:Esc`. +: 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`. -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. +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í. -There are two limitations shared by all the methods above: +Všechny uvedené metody mají dvě omezení: -1. The exact location of the modal window is determined by the browser. Usually, it's in the center. -2. The exact look of the window also depends on the browser. We can't modify it. +1. Přesná poloha modálního okna je stanovena prohlížečem. Obvykle to bývá uprostřed. +2. Také přesný vzhled okna závisí na prohlížeči a my jej nemůžeme měnit. -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. +To je cena za jednoduchost. Existují jiné způsoby, jak zobrazit hezčí okna a umožnit bohatší interakci s návštěvníkem, ale pokud nám na cerepetičkách příliš nezáleží, tyto metody fungují dobře. \ No newline at end of file From af872baeb951af04e67c4a771b3ccddcd6536b41 Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:20:37 +0200 Subject: [PATCH 2/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- .../06-alert-prompt-confirm/1-simple-page/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md index 52d3ac346..b8632a056 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md @@ -4,6 +4,6 @@ importance: 4 # Jednoduchá stránka -Vytvořte webovou stránku, která se zeptá na jméno a pak je zobrazí. +Vytvořte webovou stránku, která se zeptá na jméno a pak ho zobrazí. [demo] From 8434f7d6377b154260ca263a35c370d02bae9930 Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:20:44 +0200 Subject: [PATCH 3/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index 443af2762..81bdefb50 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -84,7 +84,7 @@ alert( jeŠéf ); // pokud bylo stisknuto OK, tak true ## Shrnutí -Uvedli jsme tři funkce specifické pro prohlížeče, které umožňují interakci s uživatelem: +Uvedli jsme tři funkce specifické pro prohlížeče, které umožňují interakci s návštěvníky: `alert` : Zobrazí zprávu. From d50ea26d72fdb531b18d0d02f899ce1aafd370b2 Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:21:18 +0200 Subject: [PATCH 4/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index 81bdefb50..cd9f3fcd5 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -70,7 +70,7 @@ Syntaxe: výsledek = confirm(otázka); ``` -Funkce `confirm` zobrazí modální okno s otázkou `otázka` a dvěma tlačítky: OK a Storno. +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. Výsledek bude `true`, jestliže uživatel stiskne OK, jinak bude `false`. From 0d62da6c5af3803c5e2c9da2b5e95c33e324ec3e Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:22:11 +0200 Subject: [PATCH 5/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index cd9f3fcd5..c4436a1dd 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -100,6 +100,6 @@ Všechny tyto metody jsou modální: pozastaví vykonávání skriptu a neumožn Všechny uvedené metody mají dvě omezení: 1. Přesná poloha modálního okna je stanovena prohlížečem. Obvykle to bývá uprostřed. -2. Také přesný vzhled okna závisí na prohlížeči a my jej nemůžeme měnit. +2. Vzhled okna závisí na prohlížeči. Nelze jej upravit. To je cena za jednoduchost. Existují jiné způsoby, jak zobrazit hezčí okna a umožnit bohatší interakci s návštěvníkem, ale pokud nám na cerepetičkách příliš nezáleží, tyto metody fungují dobře. \ No newline at end of file From b69d7eab71a65d7e8aedfe29e91949f4af1d2a88 Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:22:17 +0200 Subject: [PATCH 6/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index c4436a1dd..0a5500e1f 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -99,7 +99,7 @@ Všechny tyto metody jsou modální: pozastaví vykonávání skriptu a neumožn Všechny uvedené metody mají dvě omezení: -1. Přesná poloha modálního okna je stanovena prohlížečem. Obvykle to bývá uprostřed. +1. Poloha modálního okna je stanovena prohlížečem. Obvykle je uprostřed. 2. Vzhled okna závisí na prohlížeči. Nelze jej upravit. To je cena za jednoduchost. Existují jiné způsoby, jak zobrazit hezčí okna a umožnit bohatší interakci s návštěvníkem, ale pokud nám na cerepetičkách příliš nezáleží, tyto metody fungují dobře. \ No newline at end of file From 3c3dd2adbb0c8b4bf21eb1eab60614663d25f7ea Mon Sep 17 00:00:00 2001 From: otmon76 <66325539+otmon76@users.noreply.github.com> Date: Sun, 1 May 2022 20:23:27 +0200 Subject: [PATCH 7/7] Update 1-js/02-first-steps/06-alert-prompt-confirm/article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Pomajbík <60559058+danipoma@users.noreply.github.com> --- 1-js/02-first-steps/06-alert-prompt-confirm/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/06-alert-prompt-confirm/article.md b/1-js/02-first-steps/06-alert-prompt-confirm/article.md index 0a5500e1f..21b53f56f 100644 --- a/1-js/02-first-steps/06-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/06-alert-prompt-confirm/article.md @@ -102,4 +102,4 @@ Všechny uvedené metody mají dvě omezení: 1. Poloha modálního okna je stanovena prohlížečem. Obvykle je uprostřed. 2. Vzhled okna závisí na prohlížeči. Nelze jej upravit. -To je cena za jednoduchost. Existují jiné způsoby, jak zobrazit hezčí okna a umožnit bohatší interakci s návštěvníkem, ale pokud nám na cerepetičkách příliš nezáleží, tyto metody fungují dobře. \ No newline at end of file +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. \ No newline at end of file