Skip to content

Commit 33ecffd

Browse files
author
Veljko Pejović
authored
Update article.md
1 parent f0f0862 commit 33ecffd

1 file changed

Lines changed: 48 additions & 46 deletions

File tree

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,134 @@
1-
# Hello, world!
1+
# Zdravo Svijete!
22

3-
This part of the tutorial is about core JavaScript, the language itself.
3+
Ovaj deo udžbenika govori o jezgru JavaScripta, samom jeziku.
44

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+
Ali potrebno nam je radno okruženje za pokretanje naših skripti i budući da je ova knjiga na mreži, pregledač je dobar izbor. Smanjićemo količinu naredbi specifičnih za pregledač (poput „upozorenja“) na minimum tako da na njih ne trošite vreme ako se planirate koncentrisati na drugo okruženje (poput Node.js). Usredsredićemo se na JavaScript u pregledaču u [sledećem delu] (/ ui) udžbenika.
66

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+
Prvo, da vidimo kako prikačiti skriptu na web stranicu. Za okruženja na strani poslužitelja (poput Node.js), možete izvršavati skriptu pomoću naredbe poput `"node my.js"`.
88

99

10-
## The "script" tag
10+
## "script" tag
1111

12-
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
12+
JavaScript programi se mogu ubaciti u bilo koji deo HTML dokumenta uz pomoć `<script>` taga.
1313

14-
For instance:
14+
Na primjer :
1515

1616
```html run height=100
1717
<!DOCTYPE HTML>
1818
<html>
1919

2020
<body>
2121

22-
<p>Before the script...</p>
22+
<p>Prije skripte...</p>
2323

2424
*!*
2525
<script>
26-
alert( 'Hello, world!' );
26+
alert( 'Zdravo Svijete!' );
2727
</script>
2828
*/!*
2929

30-
<p>...After the script.</p>
30+
<p>...posle skripte.</p>
3131

3232
</body>
3333

3434
</html>
3535
```
3636

3737
```online
38-
You can run the example by clicking the "Play" button in the right-top corner of the box above.
38+
Primer možete pokrenuti klikom na dugme „Play“ u gornjem desnom uglu gornjeg okvira.
3939
```
4040

41-
The `<script>` tag contains JavaScript code which is automatically executed when the browser processes the tag.
41+
`<script>` tag sadrži JavaScript kod koji se automatski izvršava kada pregledač obrađuje oznaku.
4242

4343

44-
## Modern markup
44+
## Moderno označavanje
4545

46-
The `<script>` tag has a few attributes that are rarely used nowadays but can still be found in old code:
46+
`<script>` tag ima nekoliko atributa koji se danas retko koriste, ali se još uvek mogu naći u starom kodu:
4747

48-
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
49-
: 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.
48+
`type` atribut: <code>&lt;script <u>type</u>=...&gt;</code>
49+
: Stari HTML standard, HTML4, zahtevao je skriptu da sadrži `type`. Obično je to bilo `type="text/javascript"`. To više nije potrebno. Takođe, savremeni HTML standard potpuno je promenio značenje ovog atributa. Sada se može koristiti za JavaScript module. Ali to je napredna tema; razgovaraćemo o modulima u drugom delu udžbenika.
5050

51-
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
52-
: 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.
5351

54-
Comments before and after scripts.
55-
: In really ancient books and guides, you may find comments inside `<script>` tags, like this:
52+
`language` atribut: <code>&lt;script <u>language</u>=...&gt;</code>
53+
: Ovaj atribut je trebalo da pokaže jezik skripte. Ovaj atribut više nema smisla jer je JavaScript zadani jezik. Nema potrebe da se koristi.
54+
55+
Komentari pre i posle skripte.
56+
: U zaista 'drevnim' knjigama i vodičima možete pronaći komentare unutar `<script>` taga, ovako:
5657

5758
```html no-beautify
5859
<script type="text/javascript"><!--
5960
...
6061
//--></script>
6162
```
6263

63-
This trick isn't used in modern JavaScript. These comments hid 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.
64+
Ovaj trik se ne koristi u savremenom JavaScript-u. Ovi komentari su sakrili JavaScript kod od starih pretraživača koji nisu znali kako da to obrade `<script>` tag. Budući da pregledači objavljeni u poslednjih 15 godina nemaju ovaj problem, ova vrsta komentara može vam pomoći da identifikujete zaista stari kod.
6465

6566

66-
## External scripts
67+
## Spoljne skripte
6768

68-
If we have a lot of JavaScript code, we can put it into a separate file.
69+
Ako imamo puno JavaScript koda, možemo ga staviti u odvojenu datoteku.
6970

70-
Script files are attached to HTML with the `src` attribute:
71+
Datoteke skripta su u HTML-u priložene atributom `src`
7172

7273
```html
73-
<script src="/path/to/script.js"></script>
74+
<script src="/put/do/skripta.js"></script>
7475
```
7576

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.
77+
Ovdje , `/put/do/skripta.js` je apsolutni put do skripte iz korena mesta. Takođe se može pružiti relativna putanja od trenutne stranice. Na primer, `src="skripta.js"` značilo bi da fajl `"script.js"` je u trenutnom folderu.
7778

78-
We can give a full URL as well. For instance:
79+
Takođe možemo dati punu URL adresu. Na primer:
7980

8081
```html
8182
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js"></script>
8283
```
8384

84-
To attach several scripts, use multiple tags:
85+
Da biste dodali nekoliko skripti, koristite više tagova:
8586

8687
```html
87-
<script src="/js/script1.js"></script>
88-
<script src="/js/script2.js"></script>
88+
<script src="/js/skripta1.js"></script>
89+
<script src="/js/skripta2.js"></script>
8990
9091
```
9192

9293
```smart
93-
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
94+
Po pravilu, u HTML se ubacuju samo najjednostavnije skripte. Složenije se nalaze u odvojenim fajlovima.
95+
96+
Prednost odvojene datoteke je u tome što će je pregledač preuzeti i sačuvati u svojoj [keš memoriji](https://en.wikipedia.org/wiki/Web_cache).
9497
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).
98+
Ostale stranice koje se pozivaju na isti skript uzimaće ga iz keša umesto da ga preuzmu, tako da se datoteka zapravo preuzima samo jednom.
9699
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.
98100
99-
That reduces traffic and makes pages faster.
101+
To smanjuje promet i brže stvara stranice.
100102
```
101103

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.
104+
````warn header="Ako je `src` postavljeno, sadržaj skripte se ignoriše."
105+
Pojedinačna oznaka `<script>` ne može imati atribut `src` i kod unutra.
104106

105-
This won't work:
107+
Ovo neće raditi:
106108

107109
```html
108110
<script *!*src*/!*="file.js">
109-
alert(1); // the content is ignored, because src is set
111+
alert(1); // sadržaj se ignoriše jer je podešen src
110112
</script>
111113
```
112114

113-
We must choose either an external `<script src="…">` or a regular `<script>` with code.
115+
Moramo odabrati `<script src="…">` ili regularno `<script>` sa kodom.
114116

115-
The example above can be split into two scripts to work:
117+
Gornji primer može se podeliti na dve skripte za rad:
116118

117119
```html
118-
<script src="file.js"></script>
120+
<script src="fajl.js"></script>
119121
<script>
120122
alert(1);
121123
</script>
122124
```
123125
````
124126
125-
## Summary
127+
## Rezime
126128
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>`.
129+
- Možemo koristiti `<script>` tag kako bi dodali JavaScript kod na stranici.
130+
- `type` i `language` atributi nisu potrebni.
131+
- Skripta u odvojenom fajlu se prikači sa `<script src="put/do/skripte.js"></script>`.
130132
131133
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.
134+
Postoji mnogo više da se nauči o skriptama pretraživača i njihovoj interakciji sa web stranicom. Ali imajmo na umu da je ovaj deo udžbenika posvećen JavaScript jeziku, tako da ne bismo smeli da odvlačimo pažnju pomoću njegovih pretraživača. Koristićemo pretraživač kao način pokretanja JavaScripta, što je vrlo dobro za čitanje putem interneta, ali samo jedan od mnogih.

0 commit comments

Comments
 (0)