-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
158 lines (157 loc) · 4.39 KB
/
script.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
// Scrolling to the top on reload
$(document).ready(function () {
$(this).scrollTop(0);
});
// Covering the whole document with loadingScreen
let totalHeight = document.body.clientHeight;
$(document).ready(function () {
$("#loadingScreen").height(totalHeight);
});
// Function accordion()
// Open all parts of accordion
function accordion() {
$("#buttonShow").click(function () {
$(".infoContent").show(600);
$(".collapsible").addClass("infoActive");
});
// Close all parts of accordion
$("#buttonHide").click(function () {
$(".infoContent").hide(300);
$(".collapsible").removeClass("infoActive");
});
// Open/ Hide siblings of current .collapsible
$(".collapsible").click(function () {
if ($(this).next().is(":hidden")) {
$(this).next().show(600).siblings(".infoContent").hide(300);
} else {
$(this).next().hide(300);
}
});
// Change class for siblings of current .collapsible
$(document).ready(function () {
$(".collapsible").click(function () {
if ($(this).hasClass("infoActive")) {
$(this).removeClass("infoActive");
} else {
$(this).addClass("infoActive").siblings(this).removeClass("infoActive");
}
});
});
}
accordion();
// Scripts for Curtain Info
function infoChange() {
let curtainHeight = document.getElementById("myInfo").clientHeight; //Using clientHeight to get the actual height, ignoring style rules style.height.
if (curtainHeight == "0") {
document.getElementById("myInfo").style.height = "100%";
} else {
document.getElementById("myInfo").style.height = "0";
}
}
function playHorse() {
let horseAudio = document.getElementById("horseAudio");
horseAudio.volume = 0.45;
horseAudio.play();
}
// Scripts for closing the Info Curtain
function infoClose() {
setTimeout(function () {
document.getElementById("myInfo").style.height = "0%";
}, 7000);
}
function closePlay() {
let moveIt = document.getElementById("moveIt");
moveIt.volume = 0.8;
moveIt.play();
}
// Function that shakes the image
function shakeButton() {
$("#btnClose").addClass("active");
$("#infoClose").addClass("hide");
$("#infoClose2").removeClass("hide");
$("#btnClose").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
$("#btnClose").removeClass("active");
$("#infoClose").removeClass("hide");
$("#infoClose2").addClass("hide");
});
}
// Function for shaking the bigButton
$(document).ready(function () {
$(".bigButton").click(function () {
$(".bigButton").effect("shake", {times: 5}, 1100);
});
});
// Functions for manipulating the progress bar
$(document).ready(function () {
$("#btnClose").click(function () {
$("#progressDiv").show(800);
$("p#title").show(1500);
$("p#title").delay(4000).hide(1000);
});
});
$(document).ready(function () {
$(".bigButton").click(function () {
$("#progressDiv").hide();
});
});
// Countdown timer
function countdownTimer() {
let timeRemaining = 140;
let countdownTimer = setInterval(function () {
timeRemaining--;
document.getElementById("progressBar").value = 140 - timeRemaining;
if (timeRemaining <= 0) {
clearInterval(countdownTimer);
}
document.getElementById("counting").innerHTML = `Time remaining: ${(timeRemaining / 20).toFixed(2)} seconds`;
}, 50);
}
// Tooltips - Credits and Curtain2
$("#creditsButton, #buttonCurtain2, #LoadData, #trISS_passes>th").tooltip({
hide: {
effect: "explode",
delay: 250,
},
});
// Dialog (Modal) /taken from the home page of jQuery UI/
$(function () {
$("#dialog").dialog({
buttons: {
Ok: function () {
$(this).dialog("close");
},
},
autoOpen: false,
modal: true,
width: "auto",
height: "auto",
closeOnEscape: true,
show: {
effect: "blind",
duration: 1000,
},
hide: {
effect: "explode",
duration: 1000,
},
position: {my: "center", at: "center"},
});
$("#creditsButton").on("click", function () {
$("#dialog").dialog("open");
});
});
// Functions to open and close the Curtain 2
// Adding the sound
function doorCreakPlay() {
let doorCreak = document.getElementById("doorCreak");
doorCreak.volume = 0.8;
doorCreak.play();
}
function openCurtain2() {
doorCreakPlay();
document.getElementById("curtain2").style.width = "100%";
}
function closeCurtain2() {
doorCreakPlay();
document.getElementById("curtain2").style.width = "0%";
}