You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This part of the tutorial is about core JavaScript, the language itself.
3
+
هذا الجزء من البرنامج التعليمي عن أساسيات لغة الجافا سكريبت، اللغة نفسها.
4
4
5
-
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like`alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui)of the tutorial.
5
+
لكن نحتاج إلى بيئة عمل من أجل تشغيل النصوص الخاصة بنا، وبما أن هذا الكتاب عبر الانترنت، لذافإن المتصفح خيار جيد.سوف نقوم بالاحتفاظ بالأوامر الخاصة بالمتصفح (مثل`alert`) للحد الأدنى بحيث لا تقضي وقتًا عليها إذا كنت تخطط للتركيز على بيئة أخرى (مثل Node.js). سوف نركز على الجافا سكريبت في المتصفح [الجزء التالي](/ui)من البرنامج التعليمي.
6
6
7
-
So first, let's see how we attach a script to a webpage. For server-side environments (like Node.js), you can execute the script with a command like`"node my.js"`.
7
+
لذا أولاً, دعونا نرفق نص برمجي في صفحة الويب. بالنسبة للبيئات التي تعمل على الخوادم (مثل Node.js), يمكنك تنفيذها من خلال استخدام أمر مثل`"node my.js"`.
8
8
9
9
10
-
## The "script" tag
10
+
## الوسم "script"
11
11
12
-
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
12
+
يمكن وضع برامج الجافاسكريبت في أي جزء في مستند HTML باستخدام وسم`<script>`.
13
13
14
-
For instance:
14
+
على سبيل المثال:
15
15
16
16
```html run height=100
17
17
<!DOCTYPE HTML>
@@ -23,7 +23,7 @@ For instance:
23
23
24
24
*!*
25
25
<script>
26
-
alert( 'Hello, world!' );
26
+
alert( 'أهلاً, بالعالم!' );
27
27
</script>
28
28
*/!*
29
29
@@ -35,53 +35,53 @@ For instance:
35
35
```
36
36
37
37
```online
38
-
You can run the example by clicking the "Play" button in the right-top corner of the box above.
38
+
يمكن أن تقوم بتشغيل المثال بالضغط على زر "تشغيل" في الجانب الأيمن العلوي بالمربع الأعلى.
39
39
```
40
40
41
-
The`<script>`tag contains JavaScript code which is automatically executed when the browser processes the tag.
41
+
الوسم`<script>`يحتوي على شفرات جافاسكريبت التي يمكن أن تُنفذ بشكل تلقائي عندما يقوم المتصفح بمعالجة الوسم.
42
42
43
43
44
-
## Modern markup
44
+
## الترميز الحديث
45
45
46
-
The`<script>`tag has a few attributes that are rarely used nowadays but can still be found in old code:
46
+
الوسم`<script>`يحتوي على بعض الخصائص التي نادراً مايتم استخدامها في وقتنا الحاضر، لكن يمكن أن تجدها في الشفرات البرمجية القديمة:
: The old HTML standard, HTML4, required a script to have a`type`. Usually it was`type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic, we'll talk about modules in another part of the tutorial.
: معيار HTML القديم, HTML4, يتطلب أن يحتوي وسم script على`type`. عادة ما كان`type="text/javascript"`. لم تعد مطلوبة الآن. وأيضاً,معايير HTML الحديثةغيرت معني هذه الخاصية. والآن، يمكن أن تستخدم لوحدات الجافا سكريبت. لكن هذا الموضوع متقدم، وسنتحدث عن الوحدات في جزءآخر من البرنامج التعليمي.
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
: كان الغرض من استخدام هذه الخاصية هو إظهار لغة النص البرمجي، لم تعد هذه الخاصية منطقية الآن لأن الجافا سكريبت هي اللغة الافتراضية. فليست هناك حاجة لاستخدامها.
53
53
54
-
Comments before and after scripts.
55
-
: In really ancient books and guides, you may find comments inside`<script>`tags, like this:
54
+
التعليقات قبل وبعد النصوص البرمجية.
55
+
: في الكتب والأدلة القديمة جداً، قد تجد تعليقات داخل وسم `<script>`, مثل هذا:
56
56
57
57
```html no-beautify
58
58
<script type="text/javascript"><!--
59
59
...
60
60
//--></script>
61
61
```
62
62
63
-
This trick isn't used in modern JavaScript. These comments hide JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
63
+
لاستم استخدام هذه الخدعة في الجافاسكريبت الحديثة. تخفي هذه التعليقات شفرات الجافاسكريبت في المتصفحات القديمة التي لاتعرف كيفية عمل معالجة للوسم `<script>. نظراً لأن المتصحات التي تم إصدارها في آخر 15 عاماً لاتوجد فيها هذه المشكلة، فإن هذا النوع من التعليقات يمكن أن يساعدك في تحديد الشفرة القديمة حقاً.
64
64
65
65
66
-
## External scripts
66
+
## النصوص البرمجية الخارجية
67
67
68
-
If we have a lot of JavaScript code, we can put it into a separate file.
68
+
إذا كان لدينا عدد كبير من أكواد الجافا سكريبت، فإننا يمكن أن نضعها في ملف منفصل.
69
69
70
-
Script files are attached to HTML with the `src`attribute:
70
+
يتم إرفاق ملفات النصوص البرمجية HTML باستخدام خاصية `src` :
71
71
72
72
```html
73
73
<scriptsrc="/path/to/script.js"></script>
74
74
```
75
75
76
-
Here, `/path/to/script.js`is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"`would mean a file `"script.js"`in the current folder.
76
+
هنا, `/path/to/script.js`هو مسار منفرد للنص البرمجي من جذر الموقع. يمكن أيضاً توفير مسار نسبي من خلال الصفحة الحالية.. على سبيل المثال، `src="script.js"`تعني أن الملف `"script.js"`في نفس المجلد.
77
77
78
-
We can give a full URL as well. For instance:
78
+
يمكن أن نعطي المسار الكامل أيضاً. على سبيل المثال :
لكي نرفق العديد من النصوص البرمجية، استخدم To attach several scripts, use الوسوم بصورة مضاعفة:
85
85
86
86
```html
87
87
<scriptsrc="/js/script1.js"></script>
@@ -90,29 +90,29 @@ To attach several scripts, use multiple tags:
90
90
```
91
91
92
92
```smart
93
-
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
93
+
كقاعدة، يتم وضع النصوص البرمجية البسيطة داخل HTML. والنصوص المعقدة يتم وضعها في ملفات منفصلة.
94
94
95
-
The benefit of a separate file is that the browser will download it and store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
95
+
فائدة الملفات المنفصلة هي أن المتصفح يقوم بتحميلهاوتخزينها في[ذاكرة التخزين المؤقتة](https://en.wikipedia.org/wiki/Web_cache).
96
96
97
-
Other pages that reference the same script will take it from the cache instead of downloading it, so the file is actually downloaded only once.
97
+
الصفحات الأخرى التي تشير إلى نفس النص البرمجي سوف تحصل عليه من ذاكرة التخزين المؤقتة بدلاً من تنزيله، لذا فإن الملف يتم تحميله مرة واحدة.
98
98
99
-
That reduces traffic and makes pages faster.
99
+
هذا يقلل من الحركة ويجعل الصفحات تكون أسرع.
100
100
```
101
101
102
-
````warn header="If`src`is set, the script content is ignored."
103
-
A single `<script>`tag can't have both the `src`attribute and code inside.
102
+
````warn header="إذا`src`تم تعيين, يتم تجاهل محتوى النص البرمجي."
103
+
وسم `<script>`منفرداً لايمكن أن يحتوي على خاصية `src` والكود بداخله.
104
104
105
-
This won't work:
105
+
هذا لايعمل:
106
106
107
107
```html
108
108
<script*!*src*/!*="file.js">
109
109
alert(1); // the content is ignored, because src is set
110
110
</script>
111
111
```
112
112
113
-
We must choose either an external `<script src="…">`or a regular `<script>`with code.
113
+
يجب اختيار إما خارجي `<script src="…">`أو عادي `<script>`باستخدام الكود.
114
114
115
-
The example above can be split into two scripts to work:
115
+
يمكن تقسيم المثال أعلاه إلى نصين برمجيين لكي يعمل:
116
116
117
117
```html
118
118
<scriptsrc="file.js"></script>
@@ -122,11 +122,11 @@ The example above can be split into two scripts to work:
122
122
```
123
123
````
124
124
125
-
## Summary
125
+
## ملخص
126
126
127
-
- We can use a `<script>` tag to add JavaScript code to a page.
128
-
- The `type` and `language` attributes are not required.
129
-
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
127
+
- يمكن استخدام وسم `<script>` لإضافة كود الجافا سكريبت إلى صفحة.
128
+
- الخصائص `type` و `language` غير مطلوبة.
129
+
- يمكن إدراج النص البرمجي في ملف خارجي باستخدام `<script src="path/to/script.js"></script>`.
130
130
131
131
132
-
There is much more to learn about browser scripts and their interaction with the webpage. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves with browser-specific implementations of it. We'll be using the browser as a way to run JavaScript, which is very convenient for online reading, but only one of many.
132
+
هناك الكثير لتتعلمه عن نصوص المتصفح البرمجية وتفاعلها مع صفحة الويب. ولكن دعنا نضع في اعتبارنا أن هذا الجزء من البرنامج التعليمي مخصص للغة جافا سكريبت ، لذلك لا ينبغي أن نشتت انتباهنا بالتطبيقات الخاصة بالمتصفح. سنستخدم المتصفح كوسيلة لتشغيل جافا سكريبت ، وهو مناسب جدًا للقراءة عبر الإنترنت ، ولكن واحدًا فقط من بين العديد.
0 commit comments