-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
215 lines (175 loc) · 6.36 KB
/
script.js
File metadata and controls
215 lines (175 loc) · 6.36 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
(function () {
"use strict";
//clock
document.addEventListener("DOMContentLoaded", function () {
let c = document.getElementById("clock");
//setTimeout(updateClock, 2000);
setInterval(updateClock, 1000);
function updateClock() {
let tähis = "EL";
let date = new Date();
//kuna setInterval uuendab sekundi tagant, siis lisasin hetke ajale 1 sekundi :)
date.setSeconds(date.getSeconds() + 1);
if (date.getHours() >= 12) tähis = "PL";
let h = date.getHours() % 12;
let m = date.getMinutes();
let s = date.getSeconds();
/*
if (h < 10) {
h = "0" + h;
}
*/
if (h == 0) h = "12";
if (m < 10) {
m = "0" + m;
}
if (s < 10) {
s = "0" + s;
}
c.innerHTML = h + ":" + m + ":" + s + " " + tähis;
}
});
// forms
document.getElementById("form").addEventListener("submit", estimateDelivery);
let e = document.getElementById("delivery");
e.innerHTML = "0,00 €";
const present = 5.0;
const contactless = 1.0;
const tln = 0.0;
const trt = 2.5;
const nrv = 2.5;
const prn = 3.0;
function containsNumber(inputString) {
return !/^[A-Za-z]+$/.test(inputString);
}
function estimateDelivery(event) {
let summa = 0.0;
event.preventDefault();
let linn = document.getElementById("linn");
let eesnimi = document.getElementById("fname").value;
let perenimi = document.getElementById("lname").value;
if (
//Kontrollime, et radiobuttonis oleks valik tehtud
!(
document.getElementById("hommik").checked ||
document.getElementById("õhtu").checked ||
document.getElementById("päev").checked
)
) {
alert("Palun valige tarne jaoks sobiv kellaaeg");
return;
}
/*console.log("Eesnimi on " + eesnimi);
console.log("Perenimi on " + perenimi);
console.log("Eesnimi sisaldab numbreid: " + containsNumber(eesnimi));
console.log("Perenimi sisaldab numbreid: " + containsNumber(perenimi));*/
if (containsNumber(eesnimi) || containsNumber(perenimi)) {
alert("Nimi ei saa sisaldada numbreid!!!");
document.getElementById("input-fields").focus();
return;
}
if (linn.value === "") {
alert("Palun valige linn nimekirjast");
linn.focus();
return;
} else if (eesnimi.value === "" || perenimi.value === "") {
alert("Oled sa kindel, et lisasid enda kontaktandmed?");
document.getElementById("input-fields").focus();
return;
} else {
if (document.getElementById("v1").checked) summa += present;
if (document.getElementById("v2").checked) summa += contactless;
switch (linn.value) {
case "tln":
summa += tln;
break;
case "trt":
summa += trt;
break;
case "nrv":
summa += nrv;
break;
case "prn":
summa += prn;
break;
default:
alert("Sellisesse linna tarnet ei toimu");
return;
}
e.innerHTML = summa + " €";
}
console.log("Tarne hind on arvutatud");
}
})();
// map
// Abifunktsioon, mis teha kui vajutatakse pushpinile
function pushpinClicked(pin) {
if (pin.target.metadata) {
infobox.setOptions({
location: pin.target.getLocation(),
title: pin.target.metadata.title,
description: pin.target.metadata.description,
visible: true,
});
}
}
let mapAPIKey = "ApKlMiOmmU01Z0Jy2oKZf2jRm0iEwKI1Gc5Uq2X3a6BbWI42avYp7kodnh7-uNOD";
let map;
let infobox;
function GetMap() {
"use strict";
let uTLat = 58.38104;
let uTLong = 26.71992;
let talTechLat = 59.39661;
let talTechLong = 24.67106;
let uT = new Microsoft.Maps.Location(uTLat, uTLong);
let talTech = new Microsoft.Maps.Location(talTechLat, talTechLong);
let centerPoint = new Microsoft.Maps.Location((uTLat + talTechLat) / 2, (uTLong + talTechLong) / 2);
let minuStiil = {
elements: {
water: { fillColor: "#a1e0ff" },
waterPoint: { iconColor: "#a1e0ff" },
transportation: { strokeColor: "#aa6de0" },
road: { fillColor: "#b892db" },
railway: { strokeColor: "#a495b2" },
structure: { fillColor: "#ffffff" },
runway: { fillColor: "#ff7fed" },
area: { fillColor: "#f39ebd" },
political: { borderStrokeColor: "#fe6850", borderOutlineColor: "#55ffff" },
point: { iconColor: "#ffffff", fillColor: "#FF6FA0", strokeColor: "#DB4680" },
transit: { fillColor: "#AA6DE0" },
},
version: "1.0",
};
map = new Microsoft.Maps.Map("#map", {
credentials: mapAPIKey,
center: centerPoint,
zoom: 7,
mapTypeId: Microsoft.Maps.MapTypeId.cavasDark,
disablePanning: true,
customMapStyle: minuStiil,
});
infobox = new Microsoft.Maps.Infobox(centerPoint, { visible: false });
infobox.setMap(map);
let pushpinUT = new Microsoft.Maps.Pushpin(uT, {
title: "Tartu Ülikool",
text: "UT",
});
let pushpinTalTech = new Microsoft.Maps.Pushpin(talTech, {
title: "TalTech",
text: "TTÜ",
});
pushpinUT.metadata = {
title: "Tartu Ülikool",
description: "Tartu Ülikool on vaieldamatult parim ülikool Tartus",
};
pushpinTalTech.metadata = {
title: "TalTech - Tallinna Tehnikaülikool",
description: "TalTech on vaieldavalt parim ülikool Tallinnas",
};
Microsoft.Maps.Events.addHandler(pushpinUT, "click", pushpinClicked);
Microsoft.Maps.Events.addHandler(pushpinTalTech, "click", pushpinClicked);
map.entities.push(pushpinUT);
map.entities.push(pushpinTalTech);
}
// https://dev.virtualearth.net/REST/v1/Locations?q=1000 Vin Scully Ave, Los Angeles,CA&key=YOUR_KEY_HERE