|
1 | | -# Browser environment, specs |
| 1 | +# بيئة المتصفح ومواصفاته |
2 | 2 |
|
3 | | -The JavaScript language was initially created for web browsers. Since then it has evolved and become a language with many uses and platforms. |
| 3 | +تم إنشاء لغة javascript فى البداية لمتصفحات الويب , منذ ذلك الحين وأصبح لها استخدمات ومنصات عديدة. |
4 | 4 |
|
5 | | -A platform may be a browser, or a web-server or another *host*, even a coffee machine. Each of them provides platform-specific functionality. The JavaScript specification calls that a *host environment*. |
| 5 | +قد تكون تلك المنصة متصفح , خادم ويب او مضيف آخر ولكن لكل واحد منهم وظيفته الخاصة التى يقوم بها .خصائص الjavascript تسمى هذا بيئة المضيف. |
6 | 6 |
|
7 | | -A host environment provides own objects and functions additional to the language core. Web browsers give a means to control web pages. Node.js provides server-side features, and so on. |
| 7 | +توفر بيئة العمل كائنات و وظائف خاصة إلى جزهر اللغة , تعتبر المتصفحات وسيلة للتحكم بصفحات الويب , وتوفر الnode.js خواص إلى جانب الخادم, وما إلى ذلك. |
8 | 8 |
|
9 | | -Here's a bird's-eye view of what we have when JavaScript runs in a web-browser: |
| 9 | +إليك نظرة شاملة لما لدينا عند تشغيل جافا سكريبت في متصفح ويب: |
10 | 10 |
|
11 | 11 |  |
12 | 12 |
|
13 | | -There's a "root" object called `window`. It has two roles: |
| 13 | +لدينا كائن الجذر `window` , له دورين: |
14 | 14 |
|
15 | | -1. First, it is a global object for JavaScript code, as described in the chapter <info:global-object>. |
16 | | -2. Second, it represents the "browser window" and provides methods to control it. |
| 15 | +1. أولا, هو كائن عالمى لشفرة javascript ,كما وصِف فى فصل <info:global-object> |
17 | 16 |
|
18 | | -For instance, here we use it as a global object: |
| 17 | +2. ثانيًا ، يمثل "نافذة المتصفح" ويوفر طرقًا للتحكم فيها. |
| 18 | + |
| 19 | +على سبيل المثال ، نستخدمها هنا ككائن عام: |
19 | 20 |
|
20 | 21 | ```js run |
21 | 22 | function sayHi() { |
22 | 23 | alert("Hello"); |
23 | 24 | } |
24 | 25 |
|
25 | | -// global functions are methods of the global object: |
| 26 | +// الدالات العامة هي طرق الكائن العام: |
26 | 27 | window.sayHi(); |
27 | 28 | ``` |
28 | 29 |
|
29 | | -And here we use it as a browser window, to see the window height: |
| 30 | +وهنا نستخدمها كنافذة متصفح لرؤية ارتفاع النافذة: |
30 | 31 |
|
31 | 32 | ```js run |
32 | | -alert(window.innerHeight); // inner window height |
| 33 | +alert(window.innerHeight); // ارتفاع النافذة الداخلية |
33 | 34 | ``` |
34 | 35 |
|
35 | | -There are more window-specific methods and properties, we'll cover them later. |
| 36 | +هناك المزيد من الأساليب والخصائص الخاصة بالنافذة ، وسنغطيها لاحقًا. |
36 | 37 |
|
37 | 38 | ## DOM (Document Object Model) |
38 | 39 |
|
39 | | -Document Object Model, or DOM for short, represents all page content as objects that can be modified. |
| 40 | +يمثل نموذج كائن المستند ، أو اختصار DOM ، محتوى الصفحة بالكامل ككائنات يمكن تعديلها. |
| 41 | + |
| 42 | +كائن `document` هو "نقطة الدخول" الرئيسية للصفحة. يمكننا تغيير أو إنشاء أي شيء على الصفحة باستخدامه. |
40 | 43 |
|
41 | | -The `document` object is the main "entry point" to the page. We can change or create anything on the page using it. |
| 44 | +على سبيل المثال: |
42 | 45 |
|
43 | | -For instance: |
44 | 46 | ```js run |
45 | | -// change the background color to red |
| 47 | +// تغيير لون الخلفية إلى اللون الأحمر |
46 | 48 | document.body.style.background = "red"; |
47 | 49 |
|
48 | | -// change it back after 1 second |
49 | | -setTimeout(() => document.body.style.background = "", 1000); |
| 50 | +// تغييره مرة أخرى بعد ثانية واحدة |
| 51 | +setTimeout(() => (document.body.style.background = ""), 1000); |
50 | 52 | ``` |
51 | 53 |
|
52 | | -Here we used `document.body.style`, but there's much, much more. Properties and methods are described in the specification: |
| 54 | +استخدمنا هنا `document.body.style` ، ولكن هناك الكثير والكثير. يتم وصف الخصائص والأساليب في المواصفات: |
53 | 55 |
|
54 | | -- **DOM Living Standard** at <https://dom.spec.whatwg.org> |
| 56 | +- **DOM الحالة القياسية** فى <https://dom.spec.whatwg.org> |
55 | 57 |
|
56 | | -```smart header="DOM is not only for browsers" |
57 | | -The DOM specification explains the structure of a document and provides objects to manipulate it. There are non-browser instruments that use DOM too. |
| 58 | +```smart header="DOM ليس فقط للمتصفحات" |
| 59 | +توضح مواصفات DOM بنية المستند وتوفر كائنات لمعالجته. هناك أدوات غير متصفح تستخدم DOM أيضًا. |
58 | 60 |
|
59 | | -For instance, server-side scripts that download HTML pages and process them can also use DOM. They may support only a part of the specification though. |
| 61 | +على سبيل المثال ، يمكن للبرامج النصية من جانب الخادم التي تقوم بتنزيل صفحات HTML ومعالجتها أيضًا استخدام DOM. قد يدعمون جزءًا فقط من المواصفات بالرغم من ذلك. |
60 | 62 | ``` |
61 | 63 |
|
62 | | -```smart header="CSSOM for styling" |
63 | | -CSS rules and stylesheets are structured in a different way than HTML. There's a separate specification, [CSS Object Model (CSSOM)](https://www.w3.org/TR/cssom-1/), that explains how they are represented as objects, and how to read and write them. |
| 64 | +```smart header="CSSOM للتصنيف" |
| 65 | +يتم تنظيم قواعد CSS وأوراق الأنماط بطريقة مختلفة عن HTML. هناك مواصفات منفصلة ، [CSS Object Model (CSSOM)](https://www.w3.org/TR/cssom-1/), يشرح كيف يتم تمثيلها ككائنات ، وكيفية قراءتها وكتابتها. |
| 66 | +them. |
64 | 67 |
|
65 | | -CSSOM is used together with DOM when we modify style rules for the document. In practice though, CSSOM is rarely required, because usually CSS rules are static. We rarely need to add/remove CSS rules from JavaScript, but that's also possible. |
| 68 | +يتم استخدام CSSOM مع DOM عند تعديل قواعد النمط للمستند. من الناحية العملية ، نادرًا ما تكون CSSOM مطلوبة ، لأن قواعد CSS عادة ما تكون ثابتة. نادرًا ما نحتاج إلى إضافة / إزالة قواعد CSS من JavaScript ، ولكن هذا ممكن أيضًا. |
66 | 69 | ``` |
67 | 70 |
|
68 | 71 | ## BOM (Browser Object Model) |
69 | 72 |
|
70 | | -The Browser Object Model (BOM) represents additional objects provided by the browser (host environment) for working with everything except the document. |
| 73 | +يمثل نموذج كائن المتصفح (BOM) كائنات إضافية يوفرها المتصفح (البيئة المضيفة) للعمل مع كل شيء باستثناء المستند. |
| 74 | + |
| 75 | +على سبيل المثال: |
71 | 76 |
|
72 | | -For instance: |
| 77 | +- يوفر كائن [navigator](mdn:api/Window/navigator) معلومات أساسية حول المتصفح ونظام التشغيل. هناك العديد من الخصائص ، لكن الأكثر شهرة هما: |
| 78 | + `navigator.userAgent` -- حول المتصفح الحالي ، و `navigator.platform` -- حول النظام الأساسي (يمكن أن يساعد على الاختلاف بين Windows / Linux / Mac إلخ). |
73 | 79 |
|
74 | | -- The [navigator](mdn:api/Window/navigator) object provides background information about the browser and the operating system. There are many properties, but the two most widely known are: `navigator.userAgent` -- about the current browser, and `navigator.platform` -- about the platform (can help to differ between Windows/Linux/Mac etc). |
75 | | -- The [location](mdn:api/Window/location) object allows us to read the current URL and can redirect the browser to a new one. |
| 80 | +- يسمح لنا كائن [location](mdn:api/Window/location) بقراءة عنوان URL الحالي ويمكنه إعادة توجيه المتصفح إلى عنوان جديد. |
76 | 81 |
|
77 | | -Here's how we can use the `location` object: |
| 82 | +إليك كيفية استخدام كائن `location`: |
78 | 83 |
|
79 | 84 | ```js run |
80 | | -alert(location.href); // shows current URL |
| 85 | +alert(location.href); //يظهر URL الحالى |
81 | 86 | if (confirm("Go to Wikipedia?")) { |
82 | | - location.href = "https://wikipedia.org"; // redirect the browser to another URL |
| 87 | + location.href = "https://wikipedia.org"; //إعادة توجيه المتصفح إلى عنوان URL آخر |
83 | 88 | } |
84 | 89 | ``` |
85 | 90 |
|
86 | | -Functions `alert/confirm/prompt` are also a part of BOM: they are directly not related to the document, but represent pure browser methods of communicating with the user. |
| 91 | +تعد `alert/confirm/prompt` الوظائف أيضًا جزءًا من DOM المواد: فهي لا تتعلق مباشرة بالمستند ، ولكنها تمثل طرق متصفح خالصة للتواصل مع المستخدم. |
87 | 92 |
|
88 | | -```smart header="Specifications" |
89 | | -BOM is the part of the general [HTML specification](https://html.spec.whatwg.org). |
| 93 | +```smart header="مواصفات" |
| 94 | +BOM هو جزء من مواصفات[HTML specification](https://html.spec.whatwg.org). |
90 | 95 |
|
91 | | -Yes, you heard that right. The HTML spec at <https://html.spec.whatwg.org> is not only about the "HTML language" (tags, attributes), but also covers a bunch of objects, methods and browser-specific DOM extensions. That's "HTML in broad terms". Also, some parts have additional specs listed at <https://spec.whatwg.org>. |
| 96 | +نعم سمعت ذلك جيدا. مواصفات HTML في <https://html.spec.whatwg.org>لا تتعلق فقط بـ "لغة HTML" (العلامات ، السمات) ،ولكنه يغطي أيضًا مجموعة من الكائنات والأساليب وإضافات DOM الخاصة بالمتصفح. هذا هو "HTML بعبارات عامة".أيضًا ، تحتوي بعض الأجزاء على مواصفات إضافية مدرجة في <https://spec.whatwg.org> |
92 | 97 | ``` |
93 | 98 |
|
94 | | -## Summary |
| 99 | +## ملخص |
95 | 100 |
|
96 | | -Talking about standards, we have: |
| 101 | +بالحديث عن المعايير ، لدينا: |
97 | 102 |
|
98 | | -DOM specification |
99 | | -: Describes the document structure, manipulations and events, see <https://dom.spec.whatwg.org>. |
| 103 | +DOM مواصفات |
| 104 | +: يصف هيكل الوثيقة والتلاعب والأحداث ، راجع <https://dom.spec.whatwg.org>. |
100 | 105 |
|
101 | | -CSSOM specification |
102 | | -: Describes stylesheets and style rules, manipulations with them and their binding to documents, see <https://www.w3.org/TR/cssom-1/>. |
| 106 | +CSSOM مواصفات |
| 107 | +: يصف أوراق الأنماط وقواعد الأنماط والتلاعب بها وربطها بالمستندات ، راجع <https://www.w3.org/TR/cssom-1/>. |
103 | 108 |
|
104 | | -HTML specification |
105 | | -: Describes the HTML language (e.g. tags) and also the BOM (browser object model) -- various browser functions: `setTimeout`, `alert`, `location` and so on, see <https://html.spec.whatwg.org>. It takes the DOM specification and extends it with many additional properties and methods. |
| 109 | +HTML مواصفات |
| 110 | +: تصف لغة HTML (مثل العلامات) وكذلك BOM (طراز كائن المتصفح) - وظائف المتصفح المختلفة: |
| 111 | +`setTimeout`, `alert`, `location` وما إلى ذلك, راجع <https://html.spec.whatwg.org>. يأخذ مواصفات DOM ويوسعها بالعديد من الخصائص والأساليب الإضافية. |
106 | 112 |
|
107 | | -Additionally, some classes are described separately at <https://spec.whatwg.org/>. |
| 113 | +بالإضافة إلى ذلك ، يتم وصف بعض الفئات بشكل منفصل في |
| 114 | +<https://spec.whatwg.org/>. |
108 | 115 |
|
109 | | -Please note these links, as there's so much stuff to learn it's impossible to cover and remember everything. |
| 116 | +يرجى ملاحظة هذه الروابط ، حيث أن هناك الكثير من الأشياء لمعرفة أنه من المستحيل تغطية وتذكر كل شيء. |
110 | 117 |
|
111 | | -When you'd like to read about a property or a method, the Mozilla manual at <https://developer.mozilla.org/en-US/search> is also a nice resource, but the corresponding spec may be better: it's more complex and longer to read, but will make your fundamental knowledge sound and complete. |
| 118 | +عندما ترغب في القراءة عن خاصية أو طريقة ما ، فإن دليل Mozilla على |
| 119 | +<https://developer.mozilla.org/en-US/search> هو أيضًا مورد جيد ، ولكن المواصفات المقابلة قد تكون أفضل: إنها أكثر تعقيدًا وأطول وقتًا للقراءة ، ولكنها ستجعل معرفتك الأساسية سليمة وكاملة. |
112 | 120 |
|
113 | | -To find something, it's often convenient to use an internet search "WHATWG [term]" or "MDN [term]", e.g <https://google.com?q=whatwg+localstorage>, <https://google.com?q=mdn+localstorage>. |
| 121 | +للعثور على شيء ما ، غالبًا ما يكون من الملائم استخدام البحث على الإنترنت |
| 122 | +"WHATWG [مصطلح]" او "MDN [مصطلح]", e.g <https://google.com?q=whatwg+localstorage>, <https://google.com?q=mdn+localstorage>. |
114 | 123 |
|
115 | | -Now we'll get down to learning DOM, because the document plays the central role in the UI. |
| 124 | +سنبدأ الآن في تعلم DOM ، لأن المستند يلعب الدور المركزي في واجهة المستخدم. |
0 commit comments