Skip to content

Commit 34a13fd

Browse files
committed
alert prompt confirm
1 parent 753ed22 commit 34a13fd

3 files changed

Lines changed: 31 additions & 31 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let name = prompt("What is your name?", "");
55
alert(name);
66
```
77

8-
The full page:
8+
الصفحة كاملة:
99

1010
```html
1111
<!DOCTYPE html>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ importance: 4
44

55
# A simple page
66

7-
Create a web-page that asks for a name and outputs it.
7+
قم بإنشاء صفحة ويب تسأل المستخدم لإدخال إسم ثم تظهره له.
88

99
[demo]
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
# Interaction: 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+
بينما نستخدم المتصفح كبيئة تجريبية، تعال نرى بعض الدوال المستخدمة في التعامل مع المستخدم: `alert`و `prompt` و `confirm`.
44

55
## alert
66

7-
This one we've seen already. It shows a message and waits for the user to presses "OK".
7+
هذه رأيناها بالفعل. إنها تظهر رسالة وتنتظر من المستخدم أن يضغط على "OK".
88

9-
For example:
9+
على سبيل المثال:
1010

1111
```js run
1212
alert("Hello");
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+
النافذة الصغيرة التي تحتوي على رسالة تدعى *modal window*. الكلمة "modal" تعني أن المستخدم لا يستطيع أن يتفاعل مع باقي الصفحة، مثل الضغط على أزرار أخرى، إلخ، حتى يتعامل مع هذه النافذة. في هذه الحالة -- حتى يضغط على "OK".
1616

1717
## prompt
1818

19-
The function `prompt` accepts two arguments:
19+
الدالة `prompt` تقبل معاملين اثنين:
2020

2121
```js no-beautify
2222
result = prompt(title, [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+
إنها تظهر نافذة مشروطة برسالة نصية و حقل إدخال للزائر و وأزرار OK/Cancel.
2626

2727
`title`
28-
: The text to show the visitor.
28+
: النص الذي يظهر في الزائر.
2929

3030
`default`
31-
: An optional second parameter, the initial value for the input field.
31+
: معامل ثاني إختياري، القيمة الأولية لحقل الإدخال.
3232

3333
```smart header="The square brackets in syntax `[...]`"
34-
The square brackets around `default` in the syntax above denote that the parameter as optional, not required.
34+
الأقواس المربعة حول `default` في الكود أعلاه يوضح أن المعامل إختياري، ليس مطلوب.
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+
الزائر يستطيع كتابة أي شئ في حقل الإدخال ويضغط أوك. ثم نحصل على النص في `النتيجة`. أو يستطيع إلغاء الإدخال بالضغط على إلغاء أو الضغط على زرار `key:Esc` ، عندها سنحصل على `null` ك`result`.
3838
39-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
39+
إستدعاء `prompt` ترجع النص من حقل الإدخال أو `null` لو هذا الإدخال تم إلغاؤه.
4040
41-
For instance:
41+
على سبيل المثال:
4242
4343
```js run
4444
let age = prompt('How old are you?', 100);
@@ -47,15 +47,15 @@ alert(`You are ${age} years old!`); // You are 100 years old!
4747
```
4848

4949
````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.
50+
المعامل الثاني إختياري، لكن إذا لم يتم إدخاله، انترنت اكسبلورر سيدخل النص `"undefined"` داخل حقل الإدخال.
5151

52-
Run this code in Internet Explorer to see:
52+
جرب هذا الكود في متصفح إنترنت إكسبلورر وسترى:
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+
لذلك، ال prompts لكي تظهر بشكل جيد في انترنت اكسبلورر، ننصح دائما بتزويد المتصفح بالمعامل الثاني:
5959

6060
```js run
6161
let test = prompt("Test", ''); // <-- for IE
@@ -64,42 +64,42 @@ let test = prompt("Test", ''); // <-- for IE
6464
6565
## confirm
6666
67-
The syntax:
67+
الكود:
6868
6969
```js
7070
result = confirm(question);
7171
```
7272
73-
The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel.
73+
الدالة `confirm` تظهر نافذة مشروطة ب `سؤال` و زرارين: OK and Cancel.
7474
75-
The result is `true` if OK is pressed and `false` otherwise.
75+
النتيجة هي `true` لو تم الضغط على زر أوك أو`false` لغير ذلك.
7676
77-
For example:
77+
على سبيل المثال:
7878
7979
```js run
8080
let isBoss = confirm("Are you the boss?");
8181
82-
alert( isBoss ); // true if OK is pressed
82+
alert( isBoss ); // true لو زر أوك تم الضغط عليه
8383
```
8484
8585
## Summary
8686
87-
We covered 3 browser-specific functions to interact with visitors:
87+
غطينا 3 دوال خاصة بالمتصفح للتعامل مع الزوار:
8888
8989
`alert`
90-
: shows a message.
90+
: يظهر رسالة.
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+
: يظهر رسالة تسال المستخدم لإدخال نص. يتم إرجاع النص ، أو زر إلغاء أو زر `key:Esc` تم الضغط عليه، أو `null`.
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+
: تظهر رسالة وتنتظر المستخدم ليضغط على زر "OK" أو "Cancel". ترجع `true` في حالة أوك و `false` في حالة Cancel/`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+
كل هذه الطرق مشروطة: إنها توقف تنفيذ الكود ولا تسمح للزائر للتعامل مع باقي الصفحة حتى يتم صرف النافذة .
9999
100-
There are two limitations shared by all the methods above:
100+
يوجد قيدان مشتركان لكل الطرق أعلاه :
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. الموقع المضبوط للنافذة المشروطة يتم تقريره من خلال المتصفح. عادة، إنها تكون في المنتصف.
103+
2. الشكل المضبوط للنافذة أيضاً يعتمد على المتصفح . لا نستطيع تعديله.
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+
هذا ثمن البساطة. هناك طرق أخرى تظهر نوافذ ألطف و أغنى في التعامل مع المستخدم، لكن لو "الأجراس و الصفارات" لا تهم كثيراً، هذه الطرق تعمل بشكل جيد.

0 commit comments

Comments
 (0)