Repository navigation
Expand file tree
/
Copy pathjs1.js
More file actions
154 lines (131 loc) · 4.41 KB
/
Copy pathjs1.js
File metadata and controls
154 lines (131 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// -- IF
function func_if() {
//const cislo = window.prompt("Zadej věk:");
document.writeln("Funkce: IF a SWITCH </br></br>");
const cislo = 18;
if (cislo >= 21) {
document.writeln(cislo + ": Můžeš všecko (i v US)");
}
else if (cislo >= 18) {
document.writeln(cislo + ": Můžeš dělat tamto a chlastat");
}
else if (cislo >= 15) {
document.writeln(cislo + ": Můžeš dělat tamto");
}
else {
document.writeln(cislo + ": Nemůžeš nic");
}
// -- SWITCH
document.write('<br>');
let kozy = ['1', '2', '3', '4'];
let kozyChosen = kozy[3];
switch (kozyChosen) {
case "1": document.writeln("size " + kozyChosen + ": Třešně"); break;
case "2": document.writeln("size " + kozyChosen + ": Citrony"); break;
case "3": document.writeln("size " + kozyChosen + ": Pomeranče"); break;
case "4": document.writeln("size " + kozyChosen + ": Melouny!!"); break;
default: document.writeln("size " + kozyChosen + ": nevíš?!"); break;
}
document.writeln("<hr>");
}
// -- DO / WHILE
function func_cykly() {
document.writeln("Cykly </br></br>");
document.write('do: ');
let n = 1;
do {
document.write("<b>" + n + " </b>");
n++;
} while (n <= 5);
document.write('<br>while: ');
while (n <= 10) {
document.write("<i>" + n + " </i>");
n++;
}
// -- FOR
document.write('<br>for: ');
for (let i = 10; i <= 15; i++) {
// document.write("<code>" + i + " </code>");
document.write(`<code> ${i} </code>`);
}
document.writeln("<hr>");
}
// -- pomocí cyklů a polí vygenerovat tabulku dní v týdnu
function tabulka() {
document.write('vygenerovaná tab: podmínky</br></br>');
const dny = ['po', 'út', 'st', 'čt', 'pá', 'so', 'ne'];
var styl;
document.write();
document.write('<table>');
for (let i = 0; i < dny.length; i++) {
document.writeln(`<tr>`);
(i < 5) ? styl = "" : styl = 'class="delBg"';
document.writeln(`<td ${styl}>${i + 1}</td><td ${styl}>${dny[i]}</td>`);
document.writeln(`</tr>`);
}
document.write("</table>");
document.writeln("<hr>");
}
// -- při sudém B označ celý řádek
function tabulka2() {
document.write('vygenerovaná tab 2: podmínky - celý řádek, vícenásobné styly (sudá, dělitelná 3, písmeno A):<br><br>');
const char = ['A', 'B', 'C'];
var tabulkaHere = document.getElementById('here');
var trStyle, trStyles, rand, randChar;
document.write('<table>');
for (let i = 1; i < 10; i++) {
rand = Math.floor(Math.random() * (10 - 1 + 1) + 1);
randChar = Math.floor(Math.random() * (2 - 0 + 1) + 0);
trStyle = "";
if ((rand % 2 == 0)) trStyle += 'sudaRed ';
if ((rand % 3 == 0)) trStyle += 'delBg ';
if ((char[randChar] == 'A')) trStyle += 'znakBold ';
if (trStyle == "") trStyle = 'noHighlight';
trStyles = `class="${trStyle}"`;
document.writeln(`<tr ${trStyles}>`);
document.writeln(`<td>${rand}</td><td>${char[randChar]}</td><td>${trStyles}</td>`);
document.writeln(`</tr>`);
}
document.write("</table>");
document.writeln("<hr>");
}
// -- TODO: TAB3 při sudém B označ celý řádek, vypsat do DIVu, opakovat button.onClick
function obsah(polomer) {
return Math.PI * Math.pow(polomer, 2);
}
function obsahFull() {
var polomer = window.prompt("Zadej poloměr: ");
document.write(obsah(polomer));
}
function obarvi(barva, text) {
document.write(`<p><font color="${barva}">${text}</p>`);
};
function skok_seznam() {
window.open("index.html", "_blank");
}
// --
function napis() {
// document.write("aa");
soucet.tpole2.value = "form onclick() + RND";
soucet.prvni.value = Math.floor(Math.random() * (10 - 1 + 1) + 1);
soucet.druhe.value = Math.floor(Math.random() * (10 - 1 + 1) + 1);
}
function secti() {
soucet.suma.value = parseInt(soucet.prvni.value) + parseInt(soucet.druhe.value);
}
function randoms() {
frmOperace.prvni.value = Math.floor(Math.random() * (100 - 1 + 1) + 1);
frmOperace.druhe.value = Math.floor(Math.random() * (100 - 1 + 1) + 1);
}
function opPlus() {
frmOperace.suma.value = parseInt(frmOperace.prvni.value) + parseInt(frmOperace.druhe.value);
}
function opMinus() {
frmOperace.suma.value = parseInt(frmOperace.prvni.value) - parseInt(frmOperace.druhe.value);
}
function opKrat() {
frmOperace.suma.value = parseInt(frmOperace.prvni.value) * parseInt(frmOperace.druhe.value);
}
function opDeleno() {
frmOperace.suma.value = parseInt(frmOperace.prvni.value) / parseInt(frmOperace.druhe.value);
}