|
1 |
| -# Developer console |
| 1 | +# Kehityskonsoli |
2 | 2 |
|
3 |
| -Code is prone to errors. You will quite likely make errors... Oh, what am I talking about? You are *absolutely* going to make errors, at least if you're a human, not a [robot](https://en.wikipedia.org/wiki/Bender_(Futurama)). |
| 3 | +Koodi on altis virheille. Tulet todennäköisesti tekemään virheitä.. Tai siis, mitä höpisen? Tulet *takuuvarmasti* tekemään virheitä ainakin, jos olet ihminen etkä [robotti](https://en.wikipedia.org/wiki/Bender_(Futurama)). |
4 | 4 |
|
5 |
| -But in the browser, users don't see errors by default. So, if something goes wrong in the script, we won't see what's broken and can't fix it. |
| 5 | +Selaimessa virheitä ei kuitenkaan oletuksena näe. Jos jokin skriptissä menee pieleen, emme näe mikä on rikki emmekä voi korjata sitä. |
6 | 6 |
|
7 |
| -To see errors and get a lot of other useful information about scripts, "developer tools" have been embedded in browsers. |
| 7 | +Nähdäksemme virheet ja paljon muuta hyödyllistä skripteihin liittyvää, selaimiin on upotettu "kehitystyökaluja". |
8 | 8 |
|
9 |
| -Most developers lean towards Chrome or Firefox for development because those browsers have the best developer tools. Other browsers also provide developer tools, sometimes with special features, but are usually playing "catch-up" to Chrome or Firefox. So most developers have a "favorite" browser and switch to others if a problem is browser-specific. |
| 9 | +Useimmat sovelluskehittäjät käyttävät Chromea tai Firefoxia, koska niissä on parhaat kehitystyökalut. Muissakin selaimissa on kehitystyökaluja, mutta ne seuraavat yleensä Chromen ja Firefoxin esimerkkiä. Useimmilla kehittäjillä onkin yksi "lempiselain" ja he käyttävät muita, jos ongelma on selainkohtainen. |
10 | 10 |
|
11 |
| -Developer tools are potent; they have many features. To start, we'll learn how to open them, look at errors, and run JavaScript commands. |
| 11 | +Kehitystyökalut ovat tehokkaita; niissä on monia toimintoja. Aluksi opimme, miten työkalut saa näkyviin, katsomme virheitä ja ajamme JavaScript -komentoja. |
12 | 12 |
|
13 | 13 | ## Google Chrome
|
14 | 14 |
|
15 |
| -Open the page [bug.html](bug.html). |
| 15 | +Avaa tämä sivu: [bug.html](bug.html). |
16 | 16 |
|
17 |
| -There's an error in the JavaScript code on it. It's hidden from a regular visitor's eyes, so let's open developer tools to see it. |
| 17 | +Sivun JavaScript -koodissa on virhe. Se on piilossa tavallisille vierailijoille, joten avataanpa kehitystyökalut, niin näemme sen. |
18 | 18 |
|
19 |
| -Press `key:F12` or, if you're on Mac, then `key:Cmd+Opt+J`. |
| 19 | +Paina `key:F12` tai, jos käytät Macciä, paina `key:Cmd+Opt+J`. |
20 | 20 |
|
21 |
| -The developer tools will open on the Console tab by default. |
| 21 | +Kehitystyökalut avautuvat oletuksena konsoliin (Console). |
22 | 22 |
|
23 |
| -It looks somewhat like this: |
| 23 | +Sen pitäisi näyttää suurin piirtein tältä: |
24 | 24 |
|
25 | 25 | 
|
26 | 26 |
|
27 |
| -The exact look of developer tools depends on your version of Chrome. It changes from time to time but should be similar. |
| 27 | +Työkalujen tarkka ulkoasu riippuu Chromen versiosta. Tarkka ulkoasu muuttuu silloin tällöin, mutta sen pitäisi näyttää samankaltaiselta. |
28 | 28 |
|
29 |
| -- Here we can see the red-colored error message. In this case, the script contains an unknown "lalala" command. |
30 |
| -- On the right, there is a clickable link to the source `bug.html:12` with the line number where the error has occurred. |
| 29 | +- Täällä näemme punaisen virhetekstin. Tässä tapauksessa skripti sisältää tuntemattoman komennon "lalala". |
| 30 | +- Oikealla on klikattava linkki lähteeseen `bug.html:12`, jossa näkyy sen rivin numero, jolta virhe löytyy. |
31 | 31 |
|
32 |
| -Below the error message, there is a blue `>` symbol. It marks a "command line" where we can type JavaScript commands. Press `key:Enter` to run them. |
| 32 | +Virhetekstin alla näkyy sininen `>` symboli. Se osoittaa "komentoriviä", johon voimme kirjoittaa JavaScript -komentoja. Paina `key:Enter` suorittaaksesi niitä. |
33 | 33 |
|
34 |
| -Now we can see errors, and that's enough for a start. We'll come back to developer tools later and cover debugging more in-depth in the chapter <info:debugging-chrome>. |
| 34 | +Näemme nyt virheet, ja se riittää alkuun. Palaamme kehitystyökaluihin myöhemmin ja käymme virheenkorjausta tarkemmin kappaleessa <info:debugging-chrome>. |
35 | 35 |
|
36 |
| -```smart header="Multi-line input" |
37 |
| -Usually, when we put a line of code into the console, and then press `key:Enter`, it executes. |
| 36 | +```smart header="Monirivinen syöttö" |
| 37 | +Kun syötämme rivin koodia konsoliin ja painamme `key:Enter`, koodi suoritetaan. |
38 | 38 |
|
39 |
| -To insert multiple lines, press `key:Shift+Enter`. This way one can enter long fragments of JavaScript code. |
| 39 | +Voimme painaa `key:Shift+Enter` syöttääksemme useamman rivin. Näin voimme syöttää pidempiä JavaScript -koodipätkiä. |
40 | 40 | ```
|
41 | 41 |
|
42 |
| -## Firefox, Edge, and others |
| 42 | +## Firefox, Edge ja muut |
43 | 43 |
|
44 |
| -Most other browsers use `key:F12` to open developer tools. |
| 44 | +Suurimmassa osassa selaimista kehittäjätyökalut saa avattua painamalla `key:F12`. |
45 | 45 |
|
46 |
| -The look & feel of them is quite similar. Once you know how to use one of these tools (you can start with Chrome), you can easily switch to another. |
| 46 | +Niiden ulkoasu ja tuntuma on melko samanlainen. Kun opit käyttämään yhden selaimen työkaluja (voit aloittaa Chromella), toiseen selaimeen vaihtaminen on helppoa. |
47 | 47 |
|
48 | 48 | ## Safari
|
49 | 49 |
|
50 |
| -Safari (Mac browser, not supported by Windows/Linux) is a little bit special here. We need to enable the "Develop menu" first. |
| 50 | +Safari (Macin selain, jota Windows/Linux eivät tue) on vähän erityinen. Meidän täytyy ensin ottaa "Develop menu" (suom. "kehitysvalikko") käyttöön. |
51 | 51 |
|
52 |
| -Open Preferences and go to the "Advanced" pane. There's a checkbox at the bottom: |
| 52 | +Avaa "Preferences" (suom. "Asetukset") ja mene kohtaan "Advanced" (suom. "Lisäasetukset"). Alaosasta löytyy valinta: |
53 | 53 |
|
54 | 54 | 
|
55 | 55 |
|
56 |
| -Now `key:Cmd+Opt+C` can toggle the console. Also, note that the new top menu item named "Develop" has appeared. It has many commands and options. |
| 56 | +Nyt näppäinyhdistelmällä `key:Cmd+Opt+C` saa avattua konsolin. Huomaa myös, että yläpalkkiin on ilmestynyt uusi valinta "Develop" (suom. "Kehitä"). Sieltä löytyy monia komentoja ja valintoja. |
57 | 57 |
|
58 |
| -## Summary |
| 58 | +## Yhteenveto |
59 | 59 |
|
60 |
| -- Developer tools allow us to see errors, run commands, examine variables, and much more. |
61 |
| -- They can be opened with `key:F12` for most browsers on Windows. Chrome for Mac needs `key:Cmd+Opt+J`, Safari: `key:Cmd+Opt+C` (need to enable first). |
| 60 | +- Kehitystyökalujen avulla voimme nähdä virheet, suorittaa komentoja, tutkia muuttujia ja paljon muuta. |
| 61 | +- Työkalut saa suurimmassa osassa Windows-selaimista auki painamalla `key:F12`. Chrome Macillä vaatii näppäinyhdistelmää `key:Cmd+Opt+J`, Safari `key:Cmd+Opt+C` (kun työkalut on ensin otettu käyttöön). |
62 | 62 |
|
63 |
| -Now we have the environment ready. In the next section, we'll get down to JavaScript. |
| 63 | +Nyt meillä on kehitysympäristö valmiina. Seuraavassa osiossa paneudumme JavaScriptiin. |
0 commit comments