-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainpage.js
369 lines (330 loc) · 12 KB
/
Mainpage.js
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/** Just a Test**/
/**Variables**/
var cardCounter = 0;
var cardAreas = {
"e1":"176,70,221,60,274,70,274,226,176,226",
"e2":"336,70,385,60,434,70,434,226,336,226",
"e3":"176,291,221,284,274,291,274,444,176,444",
"e4":"336,291,385,284,434,291,434,444,336,444",
"f1":"574,70,622,60,672,70,672,226,574,226",
"f2":"732,70,778,60,831,70,831,226,732,226",
"f3":"574,291,622,284,672,291,672,444,574,444",
"f4":"732,291,778,284,831,291,831,444,732,444"
};
var lightAreas = {
"lightArea1":"78,330,581,422",
"lightArea2":"109,174,552,386"
}
var zoomSrc = {
"b1Clip":{"margin-left": "-100px", "margin-top": "-320px", "transform": "scale(0.9,0.9)"},
"b2Clip":{"margin-left": "-349px", "margin-top": "-750px", "transform": "scale(1.1,1.1)"},
"b3Clip":{"margin-left": "-430px", "margin-top": "-100px", "transform": "scale(1.1,1.1)"},
"b4Clip":{"margin-left": "-1000px", "margin-top": "-350px", "transform": "scale(1,1)"},
"com1Clip":{"margin-left": "100px", "margin-top": "-800px", "transform": "scale(1.1,1.1)"},
"com2Clip":{"margin-left": "-349px", "margin-top": "-450px", "transform": "scale(1.1,1.1)"},
"com3Clip":{"margin-left": "-900px", "margin-top": "-100px", "transform": "scale(1.1,1.1)"},
"com4Clip":{"margin-left": "-1000px", "margin-top": "-650px", "transform": "scale(1,1)"},
"noteClip":{"margin-left": "-800px", "margin-top": "-650px", "transform": "scale(1,1)"},
"one":{"margin-left": "-430px", "margin-top": "-700px","transform": "scale(0.7, 0.7)"},
"two":{"margin-left": "-449px", "margin-top": "-520px", "transform": "scale(0.8,0.8)"}
};
var slideIndex = 0;
slides=["Sources/Marburger_Profs_Notiz.jpg","Sources/Marburger_Profs_Folie_big.jpg","Sources/Marburger_Profs_Foto_big.jpg"];
function displayModal(modalId,closeIndex=0){
var modal = document.getElementById(modalId);
var span = document.getElementsByClassName("close")[closeIndex];
modal.style.display = "block";
span.onclick = function(){
modal.style.display = "none";
}
}
function displayModalTut(modalId,closeIndex=0, nextModal, nextIndex=0){
var modal = document.getElementById(modalId);
var span = document.getElementsByClassName("close")[closeIndex];
modal.style.display = "block";
span.onclick = function(){
modal.style.display = "none";
displayModal(nextModal, nextIndex);
}
}
function displayModalNext(modalId, nextModal, nextIndex=0){
var modal = document.getElementById(modalId);
modal.style.display = "none";
displayModal(nextModal,nextIndex);
}
function overlayOn(imgId, ovImg, overlay){
var overlayImg = document.getElementById(ovImg);
var image = document.getElementById(imgId);
overlayImg.src = image.src;
displayModal(overlay);
}
function overlayOff(ovId){
document.getElementById(ovId).style.display = "none";
}
function displayCard(areaId,cardId,areaR="",cardR=""){
var card = document.getElementById(cardId);
card.style.display = "inline";
displayModal("modal4",4);
displayModal("modal3",3);
if(cardR != "" && areaR != ""){
document.getElementById(cardR).style.display = "none";
document.getElementById(areaR).setAttribute("href", "javascript:function() { return false; };");
document.getElementById(areaR).style.cursor = "default";
}
cardCounter++;
createArea(areaId,cardId);
if(cardCounter == 8){
displayModal("endingNote",9);
displayModal("ending", 8);
document.getElementById("endingIcon").style.display = "block";
}
}
function displayZoom(imgId, ovImg, overlay){
var zoomed = document.getElementById("zoomed");
zoomed.style.marginLeft = zoomSrc[imgId]["margin-left"];
zoomed.style.marginTop = zoomSrc[imgId]["margin-top"];
zoomed.style.transform = zoomSrc[imgId]["transform"];
overlayOn(imgId, ovImg, overlay);
}
function createArea(areaId,cardId){
var coords = cardAreas[cardId];
var area = document.getElementById(areaId);
area.coords = coords;
area.href = "javascript:overlayOn('"+ cardId+ "','card','cardOverlay');";
}
function createLightArea(areaId,imgId, slide){
var coords = lightAreas[areaId];
var area = document.getElementById("lightArea");
area.coords = coords;
area.href = "javascript:displayLightZoom('"+ imgId+ "','zoomed','zoomOverlay','"+slide+"');";
}
function displayLightZoom(imgId, ovImg, overlay, slide){
var zoomed = document.getElementById("zoomed");
zoomed.style.marginLeft = zoomSrc[slide]["margin-left"];
zoomed.style.marginTop = zoomSrc[slide]["margin-top"];
zoomed.style.transform = zoomSrc[slide]["transform"];
overlayOn(imgId, ovImg, overlay);
}
function displayLightroom(){
var slideImg = document.getElementById("slideImg");
slideIndex = 0;
slideImg.src = slides[slideIndex];
displayModal("modal11", 11);
displayModal("modal5", 5);
}
function plusSlides(){
slideIndex++;
if(slideIndex >= 3){
slideIndex = 0;
}
updateImage();
}
function updateImage(){
var image = document.getElementById("slideImg");
if(image.complete) {
var new_image = new Image();
//set up the new image
new_image.id = "slideImg";
new_image.src = slides[slideIndex];
new_image.useMap = "#lightMap";
if(slideIndex == 1){
createLightArea("lightArea1","slideImg","one");
}else if (slideIndex == 2) {
createLightArea("lightArea2","slideImg","two");
}else{
var area = document.getElementById("lightArea");
area.coords = "";
area.href ="";
}
// insert new image and remove old
image.parentNode.insertBefore(new_image,image);
image.parentNode.removeChild(image);
}
setTimeout(updateImage, 1000);
}
function minusSlides(){
slideIndex--;
if(slideIndex < 0){
slideIndex = 2;
}
updateImage();
}
/**Mindmap**/
function displayLine(lineId){
document.getElementById(lineId).style.strokeOpacity = 1.0;
}
function unmarkAll(){
document.getElementById("line1").style.strokeOpacity = 0.0;
document.getElementById("line2").style.strokeOpacity = 0.0;
document.getElementById("line3").style.strokeOpacity = 0.0;
document.getElementById("pin1").style.fillOpacity = 0.0;
document.getElementById("pin2").style.fillOpacity = 0.0;
document.getElementById("pin3").style.fillOpacity = 0.0;
document.getElementById("pin4").style.fillOpacity = 0.0;
pinCount = 0;
ptemp = "";
}
function uncklickAll(){
document.getElementById("apin1").setAttribute("href", "javascript:function() { return false; };");
document.getElementById("apin2").setAttribute("href", "javascript:function() { return false; };");
document.getElementById("apin3").setAttribute("href", "javascript:function() { return false; };");
document.getElementById("apin4").setAttribute("href", "javascript:function() { return false; };");
document.getElementById("apin1").style.cursor = "default";
document.getElementById("apin2").style.cursor = "default";
document.getElementById("apin3").style.cursor = "default";
document.getElementById("apin4").style.cursor = "default";
}
var pins = ["pin1","pin2","pin3","pin4"];
var pinCount = 0;
var ptemp = "";
function lineTest(pin){
if(pinCount == 0){
document.getElementById(pin).style.fillOpacity = 0.5;
ptemp = pin;
pinCount++;
}else if(pinCount == 1){
if(ptemp == pins[pinCount-1] && pin == pins[pinCount]){
document.getElementById(ptemp).style.fillOpacity = 0.0;
ptemp = pin;
pinCount++;
displayLine("line1");
}else{
unmarkAll();
}
}else if(pinCount == 2){
if(pin == pins[pinCount]){
ptemp = pin;
pinCount++;
displayLine("line2");
}else{
unmarkAll();
}
}else if(pinCount == 3){
if(pin == pins[pinCount]){
ptemp = pin;
pinCount++;
displayLine("line3");
displayCard("c3","e3");
uncklickAll();
}else{
unmarkAll();
}
}else{
unmarkAll();
}
}
/**Telephone**/
function testPhone(){
var cor1 = 9;
var cor2 = 3;
var cor3 = 7;
var cor4 = 4;
var t1Value = document.getElementById("t1").innerHTML;
var t2Value = document.getElementById("t2").innerHTML;
var t3Value = document.getElementById("t3").innerHTML;
var t4Value = document.getElementById("t4").innerHTML;
var t1Numb = parseInt(t1Value,10);
var t2Numb = parseInt(t2Value,10);
var t3Numb = parseInt(t3Value,10);
var t4Numb = parseInt(t4Value,10);
if(cor1 == t1Numb && cor2 == t2Numb && cor3 == t3Numb && cor4 == t4Numb){
displayCard("c1","e1");
document.getElementById("phone").setAttribute("onclick", "javascript:function() { return false; };");
}else{
document.getElementById("t1").style.color = "red";
document.getElementById("t2").style.color = "red";
document.getElementById("t3").style.color = "red";
document.getElementById("t4").style.color = "red";
document.getElementById("t1").innerHTML = "0";
document.getElementById("t2").innerHTML = "0";
document.getElementById("t3").innerHTML = "0";
document.getElementById("t4").innerHTML = "0";
}
}
function numbUp(numbId){
document.getElementById("t1").style.color = "white";
document.getElementById("t2").style.color = "white";
document.getElementById("t3").style.color = "white";
document.getElementById("t4").style.color = "white";
var val = document.getElementById(numbId).innerHTML;
console.log(val);
var numb = parseInt(val, 10);
if(numb >= 9){
numb = 0;
}else{
numb++;
}
console.log(numb);
$("#"+numbId).html("" + numb + "");
console.log(document.getElementById(numbId));
console.log(document.getElementById(numbId).innerHTML);
}
function numbDwn(numbId){
document.getElementById("t1").style.color = "white";
document.getElementById("t2").style.color = "white";
document.getElementById("t3").style.color = "white";
document.getElementById("t4").style.color = "white";
var val = document.getElementById(numbId).innerHTML;
console.log(val);
var numb = parseInt(val, 10);
if(numb <= 0){
numb = 9;
}else{
numb--;
}
console.log(numb);
$("#"+numbId).html("" + numb + "");
console.log(document.getElementById(numbId));
console.log(document.getElementById(numbId).innerHTML);
}
function randomNumber(){
var numb = Math.floor((Math.random()*20)+1);
console.log(numb);
$("#randomRes").html(numb);
document.getElementById("rZahl").value = numb;
}
function startForm(callback){
var tRaw;
tRaw = $.get("https://api.liveformhq.com/v1/forms/5d26e1ed-cb75-4b35-b1c1-b2f9867963fd/messages", {
api_key: "16105c44-8cde-4993-8468-cb93f00827f2"
}, function(response){
$("#adj").html(response[0].data.Adjektiv);
$("#wiss").html(response[0].data.Wissenschaft);
$("#richtung").html(response[0].data.Richtung);
$("#gegenstand").html(response[0].data.Gegenstand);
$("#ausruf").html(response[0].data.Ausruf);
$("#aktiv").html(response[0].data.Aktivitaet);
$("#zahl").html(response[0].data.Zahl);
$("#name").html(response[0].data.Name);
}, 'jsonp', async = false);
/**for Testing**/
var tData = tRaw;
console.log(tData);
}
function start(){
$.when(startForm()).then(function(){displayModalTut('startTextModal',0, 'modal13')});
}
function displayWNote(modal, mClose, note, nClose){
displayModal(note, nClose);
displayModal(modal, mClose);
}
window.onbeforeunload = function(event)
{
return confirm("Willst du wirklich gehen? Dein Spielfortschritt wird nicht gespeichert!");
};
function closeEnd(){
document.getElementById('ending').style.display = 'none';
}
/** just for testing**/
function displayAllCards(){
var cards = ["e1","e2","e3","e4","f1","f2","f3","f4"];
cards.forEach(allCards);
displayModal("modal3",3);
displayModal("endingNote",9);
displayModal("ending",8);
document.getElementById("endingIcon").style.display = "block";
}
function allCards(value){
var card = document.getElementById(value);
card.style.display = "inline";
}