Skip to content

Commit c7e2a0c

Browse files
authored
Merge pull request #85 from abdelrhmanali29/document
document
2 parents 5c635c0 + f352c57 commit c7e2a0c

1 file changed

Lines changed: 50 additions & 51 deletions

File tree

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,113 @@
1-
# Browser environment, specs
1+
# بيئة المتصفح ومواصفاته
22

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 فى البداية لمتصفحات الويب، منذ ذلك الحين أصبح لها استخدمات ومنصات عديدة.
44

5-
A platform may be a browser, or a web-server or another *host*, even a "smart" coffee machine, if it can run JavaScript. Each of them provides platform-specific functionality. The JavaScript specification calls that a *host environment*.
5+
قد تكون تلك المنصة متصفح، خادوم ويب او *مضيف* آخر ولكن لكل واحد منهم وظيفته الخاصة التى يقوم بها .خصائص الـ JavaScript تسمى هذا *ببيئة المضيف*.
66

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 خواص من جانب الخادم, وما إلى ذلك.
88

9-
Here's a bird's-eye view of what we have when JavaScript runs in a web browser:
9+
إليك نظرة شاملة لما لدينا عند تشغيل جافا سكريبت في متصفح ويب:
1010

1111
![](windowObjects.svg)
1212

13-
There's a "root" object called `window`. It has two roles:
13+
لدينا كائن "الجذر" `window` . له دورين:
1414

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.
17-
18-
For instance, here we use it as a global object:
15+
1. أولا، هو كائن عام لشفرة JavaScript، كما وصِف فى فصل <info:global-object>
16+
2. ثانيًا، يمثل "نافذة المتصفح" ويوفر طرقا للتحكم فيها.
17+
على سبيل المثال، نستخدمها هنا ككائن عام:
1918

2019
```js run
2120
function sayHi() {
2221
alert("Hello");
2322
}
2423

25-
// global functions are methods of the global object:
24+
// الدالات العامة هي طرق الكائن العام:
2625
window.sayHi();
2726
```
2827

29-
And here we use it as a browser window, to see the window height:
28+
وهنا نستخدمها كنافذة متصفح لرؤية ارتفاع النافذة:
3029

3130
```js run
32-
alert(window.innerHeight); // inner window height
31+
alert(window.innerHeight); // ارتفاع النافذة الداخلية
3332
```
3433

35-
There are more window-specific methods and properties, we'll cover them later.
34+
هناك المزيد من الأساليب والخصائص الخاصة بالنافذة، وسنغطيها لاحقًا.
3635

3736
## DOM (Document Object Model)
3837

39-
Document Object Model, or DOM for short, represents all page content as objects that can be modified.
38+
يمثل نموذج كائن المستند، أو اختصار DOM، محتوى الصفحة بالكامل ككائنات يمكن تعديلها.
39+
40+
كائن `document` هو "نقطة الدخول" الرئيسية للصفحة. يمكننا تغيير أو إنشاء أي شيء على الصفحة باستخدامه.
4041

41-
The `document` object is the main "entry point" to the page. We can change or create anything on the page using it.
42+
على سبيل المثال:
4243

43-
For instance:
4444
```js run
45-
// change the background color to red
45+
// تغيير لون الخلفية إلى اللون الأحمر
4646
document.body.style.background = "red";
4747

48-
// change it back after 1 second
48+
// تغييره مرة أخرى بعد ثانية واحدة
4949
setTimeout(() => document.body.style.background = "", 1000);
5050
```
5151

52-
Here we used `document.body.style`, but there's much, much more. Properties and methods are described in the specification: [DOM Living Standard](https://dom.spec.whatwg.org).
52+
استخدمنا هنا `document.body.style`، ولكن هناك الكثير والكثير. يتم وصف الخصائص والأساليب في المواصفات: **DOM الحالة القياسية** فى <https://dom.spec.whatwg.org>
5353

54-
```smart header="DOM is not only for browsers"
55-
The DOM specification explains the structure of a document and provides objects to manipulate it. There are non-browser instruments that use DOM too.
54+
```smart header="DOM ليس فقط للمتصفحات"
55+
توضح مواصفات الـ DOM بنية المستند وتوفر كائنات لمعالجته. هناك أدوات غير المتصفح تستخدم الـ DOM أيضًا.
5656
57-
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.
57+
على سبيل المثال، يمكن للبرامج النصية من جانب الخادوم التي تقوم بتنزيل صفحات HTML ومعالجتها أيضًا استخدام الـDOM. قد يدعمون جزءًا فقط من المواصفات بالرغم من ذلك.
5858
```
5959

60-
```smart header="CSSOM for styling"
61-
There's also a separate specification, [CSS Object Model (CSSOM)](https://www.w3.org/TR/cssom-1/) for CSS rules and stylesheets, that explains how they are represented as objects, and how to read and write them.
60+
يتم استخدام CSSOM مع الـ DOM عند تعديل قواعد النمط للمستند. من الناحية العملية، نادرًا ما تكون CSSOM مطلوبة، لأن قواعد CSS عادة ما تكون ثابتة. نادرًا ما نحتاج إلى إضافة/إزالة قواعد الـ CSS من الـ JavaScript، ولكن هذا ممكن أيضًا.
6261

63-
CSSOM is used together with DOM when we modify style rules for the document. In practice though, CSSOM is rarely required, because we rarely need to modify CSS rules from JavaScript (usually we just add/remove CSS classes, not modify their CSS rules), but that's also possible.
62+
```smart header="CSSOM للتصنيف"
63+
يتم تنظيم قواعد CSS وأوراق الأنماط بطريقة مختلفة عن HTML. هناك مواصفات منفصلة، [CSS Object Model (CSSOM)](https://www.w3.org/TR/cssom-1/), يشرح كيف يتم تمثيلها ككائنات، وكيفية قراءتها وكتابتها.
6464
```
6565

6666
## BOM (Browser Object Model)
6767

68-
The Browser Object Model (BOM) represents additional objects provided by the browser (host environment) for working with everything except the document.
68+
يمثل نموذج كائن المتصفح (BOM) كائنات إضافية يوفرها المتصفح (البيئة المضيفة) للعمل مع كل شيء باستثناء المستند.
6969

70-
For instance:
70+
على سبيل المثال:
7171

72-
- 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).
73-
- The [location](mdn:api/Window/location) object allows us to read the current URL and can redirect the browser to a new one.
72+
- يوفر كائن [navigator](mdn:api/Window/navigator) معلومات أساسية حول المتصفح ونظام التشغيل. هناك العديد من الخصائص ، لكن الأكثر شهرة هما: `navigator.userAgent` -- حول المتصفح الحالي، و `navigator.platform` -- حول النظام الأساسي (يمكن أن يساعد على تحديد الاختلاف بين Windows/Linux/Mac إلخ).
73+
- يسمح لنا كائن [location](mdn:api/Window/location) بقراءة عنوان URL الحالي ويمكنه إعادة توجيه المتصفح إلى عنوان جديد.
7474

75-
Here's how we can use the `location` object:
75+
إليك كيفية استخدام كائن `location`:
7676

7777
```js run
78-
alert(location.href); // shows current URL
78+
alert(location.href); //يظهر الـ URL الحالى
7979
if (confirm("Go to Wikipedia?")) {
80-
location.href = "https://wikipedia.org"; // redirect the browser to another URL
80+
location.href = "https://wikipedia.org"; //إعادة توجيه المتصفح إلى عنوان URL آخر
8181
}
8282
```
8383

84-
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.
84+
تعد الدوال `alert/confirm/prompt` جزءًا من الـ BOM: فهي لا تتعلق مباشرة بالمستند، ولكنها تمثل طرق متصفح خالصة للتواصل مع المستخدم.
8585

86-
```smart header="Specifications"
87-
BOM is the part of the general [HTML specification](https://html.spec.whatwg.org).
86+
```smart header="مواصفات"
87+
BOM هو جزء من مواصفات[HTML specification](https://html.spec.whatwg.org).
8888
89-
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>.
89+
نعم سمعت ذلك جيدا. مواصفات الـ HTML في <https://html.spec.whatwg.org>لا تتعلق فقط بـ "لغة HTML" (العلامات، السمات) ،ولكنه يغطي أيضًا مجموعة من الكائنات والأساليب وإضافات DOM الخاصة بالمتصفح. هذا هو "الـ HTML بعبارات عامة".أيضًا، تحتوي بعض الأجزاء على مواصفات إضافية مدرجة في <https://spec.whatwg.org>.
9090
```
9191

92-
## Summary
93-
94-
Talking about standards, we have:
92+
## ملخص
9593

96-
DOM specification
97-
: Describes the document structure, manipulations and events, see <https://dom.spec.whatwg.org>.
94+
بالحديث عن المعايير، لدينا:
9895

99-
CSSOM specification
100-
: Describes stylesheets and style rules, manipulations with them and their binding to documents, see <https://www.w3.org/TR/cssom-1/>.
96+
مواصفات الـ DOM
97+
: يصف هيكل الوثيقة والتلاعب والأحداث، راجع <https://dom.spec.whatwg.org>.
10198

102-
HTML specification
103-
: 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.
99+
مواصفات الـ CSSOM
100+
: يصف أوراق الأنماط وقواعد الأنماط والتلاعب بها وربطها بالمستندات، راجع <https://www.w3.org/TR/cssom-1/>.
104101

105-
Additionally, some classes are described separately at <https://spec.whatwg.org/>.
102+
مواصفات الـ HTML
103+
: تصف لغة HTML (مثل العلامات) وكذلك BOM (طراز كائن المتصفح) - وظائف المتصفح المختلفة: `setTimeout`, `alert`, `location` وما إلى ذلك، راجع <https://html.spec.whatwg.org>. يأخذ مواصفات الـ DOM ويوسعها بالعديد من الخصائص والأساليب الإضافية.
106104

107-
Please note these links, as there's so much stuff to learn it's impossible to cover and remember everything.
105+
بالإضافة إلى ذلك، يتم وصف بعض الفئات بشكل منفصل في <https://spec.whatwg.org/>.
108106

109-
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.
107+
يرجى ملاحظة هذه الروابط، حيث أن هناك الكثير من الأشياء لمعرفة أنه من المستحيل تغطية وتذكر كل شيء.
110108

111-
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>.
109+
عندما ترغب في القراءة عن خاصية أو طريقة ما، فإن دليل Mozilla على <https://developer.mozilla.org/en-US/search> هو أيضًا مورد جيد، ولكن المواصفات المقابلة قد تكون أفضل: إنها أكثر تعقيدًا وأطول وقتًا للقراءة، ولكنها ستجعل معرفتك الأساسية سليمة وكاملة.
112110

113-
Now we'll get down to learning DOM, because the document plays the central role in the UI.
111+
للعثور على شيء ما، غالبًا ما يكون من الملائم استخدام البحث على الإنترنت "WHATWG [مصطلح]" او "MDN [مصطلح]", مثل <https://google.com?q=whatwg+localstorage>, <https://google.com?q=mdn+localstorage>.
114112

113+
سنبدأ الآن في تعلم الـ DOM, لأن المستند يلعب الدور المركزي في واجهة المستخدم.

0 commit comments

Comments
 (0)