diff --git a/.gitignore b/.gitignore index 1a71fb7c8..ba979b878 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ .cache .project .settings +.vscode .tmproj .nvmrc sftp-config.json 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..b9631d952 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,7 +1,7 @@ JavaScript-code: ```js demo run -let name = prompt("What is your name?", ""); +let name = prompt("Cum te numești?", ""); alert(name); ``` @@ -10,15 +10,13 @@ The full page: ```html - + + - - + let name = prompt("Cum te numești?", ""); + alert(name); + + ``` 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..d6226de35 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 +# O simplă pagină -Create a web-page that asks for a name and outputs it. +Creează o pagină web care cere numele utilizatorului și îl afișează [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..45dd6fa66 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,106 @@ -# Interaction: alert, prompt, confirm +# Interacțiuni: 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`. +Deoarece vom folosi browserul ca mediu de demonstrație, hai să vedem câteva funcții cu care putem interacționa cu utilizatorul: `alert`, `prompt` și `confirm` ## alert -This one we've seen already. It shows a message and waits for the user to press "OK". +Pe aceasta am văzut-o deja. Ea afișează un mesaj și așteaptă ca utilizatorul să apese "OK". -For example: +De exemplu: ```js run -alert("Hello"); +alert("Salut"); ``` -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". +Mini fereastra cu mesajul se numește _modal_. Cuvântul "modal" înseamnă că vizitatorul nu poate interacționa cu restul paginii, apăsa alte butoane, etc, până nu se ocupă de fereastră. În cazul de față -- până nu apasă "OK". ## prompt -The function `prompt` accepts two arguments: +Funcția `prompt` acceptă două argumente: -```js no-beautify +```js result = prompt(title, [default]); ``` -It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel. +Aceasta afișează un modal cu un mesaj text, un câmp de introducere text pentru utilizator și butoanele OK/Anulează. `title` -: The text to show the visitor. +: Textul afișat utilizatorului. `default` -: An optional second parameter, the initial value for the input field. +: Un al doilea parametru, opțional, reprezintă valoarea inițială pentru câmpul de introducere text. -```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="Parantezele drepte din sintaxa `[...]`" +Parantezele drepte din jurul cuvântului `default` în sintaxa de mai sus denotă faptul că parametrul este opțional, nu obligatoriu. ``` -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`. +Utilizatorul poate scrie ceva în prompt și poate apăsa OK. Apoi noi primim acel text în `rezultat`. Sau poate anula introducerea de text prin apăsarea butonului Anulează sau apăsarea tastei `key:Esc`, apoi noi primim `null` ca `rezultat` -The call to `prompt` returns the text from the input field or `null` if the input was canceled. +Apelarea funcției `prompt` returnează textul din câmpul de introducere text sau `null` dacă introducerea de text a fost anulată. -For instance: +De exemplu: ```js run -let age = prompt('How old are you?', 100); +let age = prompt('Câți ani ai?', 100); -alert(`You are ${age} years old!`); // You are 100 years old! -``` +alert(`Ai ${age} de ani!`); // Ai 100 de ani! +```` -````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="Pentru Internet Explorer: mereu dă o valoare parametrului `default`" +Al doilea parametru e opțional, dar dacă nu-i dăm nici-o valoare, Internet Explorer va insera textul `"undefined"` în prompt. -Run this code in Internet Explorer to see: +Rulează acest cod în Internet Explorer ca să vezi: ```js run let test = prompt("Test"); ``` -So, for prompts to look good in IE, we recommend always providing the second argument: +Așadar, pentru ca prompt-ul să funcționeze corect și în Internet Explorer, recomandăm ca mereu să folosești și al doilea argument: ```js run -let test = prompt("Test", ''); // <-- for IE +let test = prompt("Test", ""); // <-- pentru Internet Explorer ``` + ```` ## confirm -The syntax: +Sintaxa: ```js -result = confirm(question); +result = confirm(întrebare); ``` -The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel. +Funcția `confirm` afișează un modal cu o `întrebare` și două butoane: OK și Anulează. -The result is `true` if OK is pressed and `false` otherwise. +Rezultatul este `true` dacă utilizatorul apasă OK și `false` în caz contrar. -For example: +De exemplu: ```js run -let isBoss = confirm("Are you the boss?"); +let isBoss = confirm("Ești patronul?"); -alert( isBoss ); // true if OK is pressed +alert(isBoss); // true dacă se apasă pe OK ``` -## Summary +## Rezumat -We covered 3 browser-specific functions to interact with visitors: +Am vorbit despre 3 funcții specifice browserului pentru a interacționa cu utilizatorii: `alert` -: shows a message. +: afișează un mesaj. `prompt` -: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`. +: afișează un mesaj cerându-i utilizatorului să introducă text. Returnează textul sau, dacă este apăsat butonul Anulează sau tasta `key:Esc`, `null`. `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`. +: afișează un mesaj și așteaptă ca utilizatorul să apese "OK" sau "Anulează". Returnează `true` dacă este apăsat OK și `false` dacă este apăsat Anulează/`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. +Toate aceste metode sunt modale: ele opresc execuția codului și nu permit utilizatorului să interacționeze cu restul paginii până când fereastra a fost închisă. -There are two limitations shared by all the methods above: +Există două limitări comune între toate metodele de mai sus: -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. Locația exactă a modalului este determinată de browser. De obicei, e în centrul ferestrei. +2. Aspectul exact al modalului depinde tot de browser. Nu îl putem schimba. -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. +Acesta este prețul plătit pentru simplitate. Sunt și alte moduri de a afișa ferestre mai frumoase și interacțiuni mai complexe cu utilizatorul, dar dacă "brizbrizurile" nu contează atât de mult pentru tine, aceste metode merg de minune.