Skip to content

Commit 52cf420

Browse files
committed
1-js/02-first-steps/09-alert-prompt-confirm
1 parent 84700d1 commit 52cf420

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
JavaScript-code:
1+
Codul JavaScript:
22

33
```js demo run
44
let name = prompt("What is your name?", "");
55
alert(name);
66
```
77

8-
The full page:
8+
Pagina întreagă:
99

1010
```html
1111
<!DOCTYPE html>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
importance: 4
1+
importanță: 4
22

33
---
44

5-
# A simple page
5+
# O pagină simplă
66

7-
Create a web-page that asks for a name and outputs it.
7+
Creează o pagină web care cere un nume și îl afișează.
88

99
[demo]
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
# Interaction: alert, prompt, confirm
1+
# Interacțiune: alert, prompt, confirm
22

3-
This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks.
3+
Această parte a tutorialului țintește să acopere JavaScript-ul "așa cum este", fără trucurile specifice mediului.
44

5-
But still we use a browser as the demo environment. So we should know at least a few user-interface functions. In this chapter we'll get familiar with the browser functions `alert`, `prompt` and `confirm`.
5+
Dar totuși folosim browser-ul ca și mediu de demo. Așadar ar trebui să știm câteva funcții de interfață. În acest capitol ne vom familiariza cu funcțiile browser-ului `alert`, `prompt` and `confirm`.
66

77
## alert
88

9-
Syntax:
9+
Sintaxă:
1010

1111
```js
1212
alert(message);
1313
```
1414

15-
This shows a message and pauses the script execution until the user presses "OK".
15+
Acest cod afișează un mesaj și pauzează script-ul până când user-ul apasă "OK".
1616

17-
For example:
17+
De exemplu:
1818

1919
```js run
2020
alert("Hello");
2121
```
2222

23-
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".
23+
Mini fereastra cu mesajul este denumită *fereastră modal*. Cuvântul "modal" semnifică faptul că vizitatorul nu poate interacționa cu restul paginii, să apese alt buton etc, până ce nu s-a ocupat de pagină. În acest caz -- până când acesta apasă "OK".
2424

2525
## prompt
2626

27-
Function `prompt` accepts two arguments:
27+
Funcția `prompt` acceptă două argumente:
2828

2929
```js no-beautify
3030
result = prompt(title[, default]);
3131
```
3232

33-
It shows a modal window with a text message, an input field for the visitor and buttons OK/CANCEL.
33+
Afișează o fereastră modal cu un mesaj text, un câmp input pentru vizitator și butoanele OK/CANCEL.
3434

3535
`title`
36-
: The text to show to the visitor.
36+
: Textul de arătat vizitatorului.
3737

3838
`default`
39-
: An optional second parameter, the initial value for the input field.
39+
: Un parametru secundar opțional, valoarea inițială pentru câmpul input.
4040

41-
The visitor may type something in the prompt input field and press OK. Or they can cancel the input by pressing the CANCEL button or hitting the `key:Esc` key.
41+
Vizitatorul poate tipări ceva în câmpul de input din prompt și să apese OK. Sau acesta poate poate anula inputul apăsând butonul CANCEL sau apăsând tasta `key:Esc`.
4242

43-
The call to `prompt` returns the text from the field or `null` if the input was canceled.
43+
Apelul lui `prompt` returnează textul din câmp sau `null` dacă input-ul a fost anulat.
4444

45-
For instance:
45+
Spre exemplu:
4646

4747
```js run
4848
let age = prompt('How old are you?', 100);
@@ -51,15 +51,15 @@ alert(`You are ${age} years old!`); // You are 100 years old!
5151
```
5252

5353
````warn header="IE: always supply a `default`"
54-
The second parameter is optional. But if we don't supply it, Internet Explorer would insert the text `"undefined"` into the prompt.
54+
Al doilea parametru este opțional. Dar dacă nu îl dăm Internet Explorer va insera textul `"undefined"` în prompt.
5555

56-
Run this code in Internet Explorer to see that:
56+
Rulează acest cod în Internet Explorer pentru a vedea acest lucru:
5757

5858
```js run
5959
let test = prompt("Test");
6060
```
6161

62-
So, to look good in IE, it's recommended to always provide the second argument:
62+
Așadar pentru a arăta bine în IE este recomandat ca întotdeauna să se furnizeze al doilea argument:
6363

6464
```js run
6565
let test = prompt("Test", ''); // <-- for IE
@@ -68,42 +68,42 @@ let test = prompt("Test", ''); // <-- for IE
6868
6969
## confirm
7070
71-
The syntax:
71+
Sintaxa:
7272
7373
```js
7474
result = confirm(question);
7575
```
7676
77-
Function `confirm` shows a modal window with a `question` and two buttons: OK and CANCEL.
77+
Funcția `confirm` afișează o fereastră modal cu o `întrebare` și două butoane: OK și CANCEL.
7878
79-
The result is `true` if OK is pressed and `false` otherwise.
79+
Rezultatul este `true` dacă OK a fost apăsat și `false` altfel.
8080
81-
For example:
81+
De exemplu:
8282
8383
```js run
8484
let isBoss = confirm("Are you the boss?");
8585
8686
alert( isBoss ); // true if OK is pressed
8787
```
8888
89-
## Summary
89+
## Rezumat
9090
91-
We covered 3 browser-specific functions to interact with the visitor:
91+
Am acoperit 3 funcții de interacțiune cu vizitatorul, specifice browser-ului:
9292
9393
`alert`
94-
: shows a message.
94+
: afișează un mesaj.
9595
9696
`prompt`
97-
: shows a message asking the user to input text. It returns the text or, if CANCEL or `key:Esc` is clicked, all browsers return `null`.
97+
: afișează un mesaj, cerând utilizatorului să introducă text. Returnează textul sau dacă butoanele CANCEL sau `key:Esc` sunt apăsate toate browserele vor returna `null`.
9898
9999
`confirm`
100-
: shows a message and waits for the user to press "OK" or "CANCEL". It returns `true` for OK and `false` for CANCEL/`key:Esc`.
100+
: afișează un mesaj și așteaptă ca utilizatorul să apese "OK" or "CANCEL". Va returna `true` pentru OK și `false` for CANCEL/`key:Esc`.
101101
102-
All these methods are modal: they pause the script execution and don't allow the visitor to interact with the rest of the page until the message has been dismissed.
102+
Toate aceste metode sunt de tip modal: ele vor pauza execuția scriptului și nu vor permite vizitatorului să interacționeze cu restul paginii până ce mesajul a fost respins.
103103
104-
There are two limitations shared by all the methods above:
104+
Există două limitări împărțite de toate metodele de mai sus:
105105
106-
1. The exact location of the modal window is determined by the browser. Usually it's in the center.
107-
2. The exact look of the window also depends on the browser. We can't modify it.
106+
1. Locația exactă a ferestrei modal este determinată de browser. De obicei este în centru.
107+
2. Aspectul exact al ferestrei depinde de asemenea de browser. Nu îl putem modifica.
108108
109-
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.
109+
Acesta este prețul pentru simplitate. Există alte modalități de a arăta ferestre mai frumoase și interacțiune mai bogată cu vizitatorul, dar dacă "clopotele și fluierele" nu contează prea mult, aceste metode vor fi suficiente.

0 commit comments

Comments
 (0)