-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom.js
34 lines (31 loc) · 1.11 KB
/
dom.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
if (typeof module !== "undefined") {
var logic = require("./logic.js");
}
// Setup DOM Vars
var form = document.querySelector(".line-select");
var submitButton = document.querySelector(".submit");
var statusDescr = document.querySelector("#status-description");
var giphyDiv = document.querySelector(".giphy-div");
var giphyImg = document.querySelector("#giphy-img");
var nextButton = document.querySelector(".next");
var prevButton = document.querySelector(".previous");
//EVENT LISTENER ON FORM
form.addEventListener("submit", function(event) {
event.preventDefault();
var line = document.getElementById("tube-lines");
var value = line.options[line.selectedIndex].value;
var lineId = line.options[line.selectedIndex].id;
// CALL GET LINE STATUS (WHICH CALLS GIPHY)
getLineStatus(value);
// CALL GET COLOR FUNCTION TO CHANGE BUTTON AND LOGO BACKGROUND
getColor(lineId);
});
// Event Listeners on next, prev buttons to skip through list
nextButton.addEventListener("click", function(e) {
e.preventDefault();
next();
});
prevButton.addEventListener("click", function(e) {
e.preventDefault();
previous();
});