forked from nitral/Arista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showDayContent.js
111 lines (86 loc) · 3.47 KB
/
showDayContent.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
var button_roseDay = document.getElementById("rose-day");
var button_proposeDay = document.getElementById("propose-day");
var button_chocolateDay = document.getElementById("chocolate-day");
var button_teddyDay = document.getElementById("teddy-day");
var button_promiseDay = document.getElementById("promise-day");
var button_hugDay = document.getElementById("hug-day");
var button_kissDay = document.getElementById("kiss-day");
var button_valentineDay = document.getElementById("valentine-day");
var mainMenu = document.getElementById("main-menu");
var currentActiveDayContent = null;
var requestBaseURL = "http://www.google.com/";
button_roseDay.addEventListener("click", function() {
showDayContent("rose-day");
}, false);
button_proposeDay.addEventListener("click", function() {
showDayContent("propose-day");
}, false);
button_chocolateDay.addEventListener("click", function() {
showDayContent("chocolate-day");
}, false);
button_teddyDay.addEventListener("click", function() {
showDayContent("teddy-day");
}, false);
button_promiseDay.addEventListener("click", function() {
showDayContent("promise-day");
}, false);
button_hugDay.addEventListener("click", function() {
showDayContent("hug-day");
}, false);
button_kissDay.addEventListener("click", function() {
showDayContent("kiss-day");
}, false);
button_valentineDay.addEventListener("click", function() {
showDayContent("valentine-day");
}, false);
var buttonArray_backToMainMenu = document.getElementsByClassName("back-main-menu");
for(i = 0; i < buttonArray_backToMainMenu.length; i++) {
buttonArray_backToMainMenu[i].addEventListener("click", hideDayContent, false);
}
function showAJAXLoader() {
// Show AJAX Loader
document.getElementById("notification-overlay").style.display = "block";
document.getElementById("notification").style.display = "block";
document.getElementById("ajax-loader").style.display = "block";
}
function hideAJAXLoader() {
// Hide AJAX Loader
document.getElementById("notification-overlay").style.display = "none";
document.getElementById("notification").style.display = "none";
document.getElementById("ajax-loader").style.display = "none";
}
function getAdvice(dayID) {
// Show AJAX Loader Notification
showAJAXLoader();
var xmlHTTPRequest = new XMLHttpRequest({
mozSystem: true
});
// Make Request URL
var requestURL = requestBaseURL + "";
xmlHTTPRequest.onreadystatechange = function() {
if (xmlHTTPRequest.readyState == 4 && xmlHTTPRequest.status == 200) {
// Set Advice
document.getElementById(dayID + "-content-advice").innerHTML = xmlHTTPRequest.responseText;
// Hide AJAX Loader Notification
hideAJAXLoader();
}
}
xmlHTTPRequest.open("GET", requestURL, true);
xmlHTTPRequest.send();
}
function showDayContent(dayID) {
mainMenu.style.display = "none";
document.getElementById(dayID + "-content").style.display = "block";
// Set Active Day Content ID
currentActiveDayContent = dayID;
// Start Retreival of Advise and Set onreadystatechange attribute
getAdvice(dayID);
}
function hideDayContent() {
// Remove Advice from Day Content
document.getElementById(currentActiveDayContent + "-content-advice").innerHTML = "";
// Hide Day Content
document.getElementById(currentActiveDayContent + "-content").style.display = "none";
// Show Main Menu
mainMenu.style.display = "block";
}