-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject9_countdown_slideshow.html
More file actions
162 lines (131 loc) · 3.79 KB
/
Copy pathProject9_countdown_slideshow.html
File metadata and controls
162 lines (131 loc) · 3.79 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countdown Timer</title>
</head>
<body>
<p>How many seconds would you like to set the alarm for?</p>
<input id="seconds" value="" />
<button onclick="countdown()">Click here</button>
<p id="timer"></p>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="img1.jpg" style="width:100%">
<div class="text">Caption One</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="img2.jpg" style="width:100%">
<div class="text">Caption Two</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="img3.jpg" style="width:100%">
<div class="text">Caption Three</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* Fading animation */
.fade {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
<script src="main.js"></script>
</body>
</html>
/* ##########################################
COUNTDOWN TIMER FUNCTIONALITY
########################################## */
function countdown() {
// Gets input from user
var seconds = document.getElementById("seconds").value;
function tick() {
seconds = seconds - 1;
document.getElementById("timer").innerHTML = seconds;
// Timer delay of 1 second
var time = setTimeout(tick, 1000);
if (seconds == -1) {
alert("Time's up!");
clearTimeout(time);
document.getElementById("timer").innerHTML = "";
}
}
tick();
}
/* ##########################################
SLIDESHOW FUNCTIONALITY
########################################## */
let slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n) {
showSlides(slideIndex += n);
}
// Thumbnail image controls
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName("mySlides");
let dots = document.getElementsByClassName("dot");
// If index is greater than total slides, reset to 1
if (n > slides.length) {slideIndex = 1}
// If index is less than 1, set to last slide
if (n < 1) {slideIndex = slides.length}
// Hide all slides
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
// Remove "active" class from all dots
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
// Display the current slide and highlight the active dot
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}