Skip to content

Commit 677612d

Browse files
committed
merging all conflicts
2 parents f87eacd + 2020876 commit 677612d

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

1-js/01-getting-started/1-intro/article.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ Contoh sekatan tersebut termasuk:
7474

7575
Ini dipanggil "Dasar Asal Sama". Untuk mengatasinya, *kedua-dua halaman* mesti bersetuju untuk pertukaran data dan mesti mengandungi kod JavaScript khas yang mengendalikannya. Kami akan membincangkannya dalam tutorial.
7676

77+
<<<<<<< HEAD
7778
Had ini, sekali lagi, untuk keselamatan pengguna. Halaman daripada `http://anysite.com` yang dibuka oleh pengguna mestilah tidak boleh mengakses tab penyemak imbas lain dengan URL `http://gmail.com`, sebagai contoh, dan mencuri maklumat dari sana.
7879
- JavaScript boleh berkomunikasi dengan mudah melalui jaring ke pelayan tempat asal halaman semasa. Tetapi keupayaannya untuk menerima data daripada tapak/domain lain adalah lumpuh. Walaupun boleh, ia memerlukan persetujuan yang jelas (dinyatakan dalam pengepala HTTP) dari bahagian jauh. Sekali lagi, itu adalah had keselamatan.
80+
=======
81+
This is called the "Same Origin Policy". To work around that, *both pages* must agree for data exchange and must contain special JavaScript code that handles it. We'll cover that in the tutorial.
82+
83+
This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL `http://gmail.com`, for example, and steal information from there.
84+
- JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is severely limited. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.
85+
>>>>>>> 20208769e528337949e946f526534d61d38bac47
7986
8087
![](limitations.svg)
8188

1-js/02-first-steps/15-function-basics/4-pow/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function pow(x, n) {
1010
return result;
1111
}
1212

13-
let x = prompt("x?", '');
14-
let n = prompt("n?", '');
13+
let x = +prompt("x?", '');
14+
let n = +prompt("n?", '');
1515

1616
if (n < 1) {
1717
alert(`Power ${n} is not supported, use a positive integer`);

2-ui/99-ui-misc/01-mutation-observer/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ Such snippet in an HTML markup looks like this:
128128
...
129129
```
130130

131-
For better readability and at the same time, to beautify it, we'll be using a JavaScript syntax highlighting library on our site, like [Prism.js](https://prismjs.com/). To get syntax highlighting for above snippet in Prism, `Prism.highlightElem(pre)` is called, which examines the contents of such `pre` elements and adds special tags and styles for colored syntax highlighting into those elements, similar to what you see in examples here, on this page.
131+
For better readability and at the same time, to beautify it, we'll be using a JavaScript syntax highlighting library on our site, like [Prism.js](https://prismjs.com/). To get syntax highlighting for above snippet in Prism, `Prism.highlightElement(pre)` is called, which examines the contents of such `pre` elements and adds special tags and styles for colored syntax highlighting into those elements, similar to what you see in examples here, on this page.
132132

133-
When exactly should we run that highlighting method? Well, we can do it on `DOMContentLoaded` event, or put the script at the bottom of the page. The moment our DOM is ready, we can search for elements `pre[class*="language"]` and call `Prism.highlightElem` on them:
133+
When exactly should we run that highlighting method? Well, we can do it on `DOMContentLoaded` event, or put the script at the bottom of the page. The moment our DOM is ready, we can search for elements `pre[class*="language"]` and call `Prism.highlightElement` on them:
134134

135135
```js
136136
// highlight all code snippets on the page
137-
document.querySelectorAll('pre[class*="language"]').forEach(Prism.highlightElem);
137+
document.querySelectorAll('pre[class*="language"]').forEach(elem => Prism.highlightElement(elem));
138138
```
139139

140140
Everything's simple so far, right? We find code snippets in HTML and highlight them.
@@ -146,9 +146,9 @@ let article = /* fetch new content from server */
146146
articleElem.innerHTML = article;
147147
```
148148

149-
The new `article` HTML may contain code snippets. We need to call `Prism.highlightElem` on them, otherwise they won't get highlighted.
149+
The new `article` HTML may contain code snippets. We need to call `Prism.highlightElement` on them, otherwise they won't get highlighted.
150150

151-
**Where and when to call `Prism.highlightElem` for a dynamically loaded article?**
151+
**Where and when to call `Prism.highlightElement` for a dynamically loaded article?**
152152

153153
We could append that call to the code that loads an article, like this:
154154

@@ -158,7 +158,7 @@ articleElem.innerHTML = article;
158158

159159
*!*
160160
let snippets = articleElem.querySelectorAll('pre[class*="language-"]');
161-
snippets.forEach(Prism.highlightElem);
161+
snippets.forEach(elem => Prism.highlightElement(elem));
162162
*/!*
163163
```
164164

0 commit comments

Comments
 (0)