forked from fac-14/Week3TakingAIME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom.js
44 lines (38 loc) · 1.4 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
35
36
37
38
39
40
41
42
43
44
var inputForm = document.getElementById("line-select");
var inputList = document.getElementById("tube-lines");
var logo = document.getElementById("tflphy-logo");
var submitBtn = document.querySelector(".submit");
var statusText = document.getElementById("line-status-text");
var errorMsg = document.getElementById("error");
var gif = document.getElementById("giphy-gif");
inputForm.addEventListener("submit", function(event) {
event.preventDefault();
var lineName = inputList.options[inputList.selectedIndex].value;
dom.changeColors(lineName);
logic.getLineStatus(lineName);
});
var dom = {
changeColors: function(lineName) {
var lineColor = convert.getValue("logoColor", lineName);
var backgroundColor = convert.getValue("backgroundColor", lineName);
logo.style.fill = lineColor;
submitBtn.style.backgroundColor = lineColor;
document.body.style.backgroundColor = backgroundColor;
},
renderLineStatus: function(lineStatus, lineName) {
dom.hideError();
var emoji = convert.getValue("emoji", logic.removeWhitespace(lineStatus));
statusText.innerHTML = lineStatus + " on<br>" + lineName + emoji;
},
renderGif: function(gifObj) {
dom.hideError();
gif.src = gifObj.data.images.fixed_height.url;
gif.classList.remove("hidden");
},
showError: function() {
errorMsg.classList.remove("hidden");
},
hideError: function() {
errorMsg.classList.add("hidden");
}
};