-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.js
More file actions
144 lines (143 loc) · 5.13 KB
/
home.js
File metadata and controls
144 lines (143 loc) · 5.13 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
var Flight = document.getElementById("homeSection1button1");
var Hotel = document.getElementById("homeSection1button2");
var carRent = document.getElementById("homeSection1button3");
var homeSection7_1 = document.querySelector("#homeSection7_1");
var homeSection7_2 = document.querySelector("#homeSection7_2");
var homeSection7_3 = document.querySelector("#homeSection7_3");
var homeSection7_4 = document.querySelector("#homeSection7_4");
window.addEventListener("resize", navbar);
window.addEventListener("scroll", navbar);
function navbar() {
var position = document
.getElementById("homeSection1")
.getBoundingClientRect();
if (position.bottom < 0) {
document.getElementById("navBar").style.position = "fixed";
document.getElementById("navBar").style.backgroundColor = "white";
var menu = window.getComputedStyle(document.querySelector(".menu-btn i"));
if (menu.display == "block") {
document.querySelector("nav ul").style.backgroundColor = "white";
}
document.querySelector(".logo").style.color = "black";
var li = document.querySelectorAll("nav ul li a");
for (var i = 0; i < li.length; i++) {
li[i].style.color = "black";
}
document.querySelector("nav ul li a.active").style.color = "#f9be37";
} else {
document.getElementById("navBar").style.position = "absolute";
document.getElementById("navBar").style.backgroundColor = "transparent";
var menu = window.getComputedStyle(document.querySelector(".menu-btn i"));
if (menu.display == "block") {
document.querySelector("nav ul").style.backgroundColor = "black";
document.getElementById("navBar").style.backgroundColor = "black";
} else {
document.getElementById("navBar").style.backgroundColor = "transparent";
document.querySelector("nav ul").style.backgroundColor = "transparent";
}
document.querySelector(".logo").style.color = "#fff";
var li = document.querySelectorAll("nav ul li a");
for (var i = 0; i < li.length; i++) {
li[i].style.color = "#fff";
}
document.querySelector("nav ul li a.active").style.color =
"rgba(255, 255, 255, 0.5)";
}
}
window.addEventListener("scroll", checkSection7);
function checkSection7() {
var position = document
.getElementById("homeSection7")
.getBoundingClientRect();
if (position.top <= window.innerHeight) {
numberLoad();
window.removeEventListener("scroll", checkSection7);
}
}
function numberLoad() {
var num1 = parseInt(homeSection7_1.textContent.split(",").join(""));
var num2 = parseInt(homeSection7_2.textContent.split(",").join(""));
var num3 = parseInt(homeSection7_3.textContent.split(",").join(""));
var num4 = parseInt(homeSection7_4.textContent.split(",").join(""));
var s1 = 10000;
var s2 = 10000;
var s3 = 10000;
var s4 = 10000;
var f = 0;
var time = setInterval(() => {
if (f == 0) {
f = 1;
}
if (s1 < num1) {
s1 += 36;
}
if (s2 < num2) {
s2 += 12;
}
if (s3 < num3) {
s3 += 28;
}
if (s4 < num4) {
s4 += 16;
}
if (s1 >= num1 || s2 >= num2 || s3 >= num3 || s4 >= num4) {
homeSection7_1.textContent = "100,000";
homeSection7_2.textContent = "40,000";
homeSection7_3.textContent = "87,000";
homeSection7_4.textContent = "56,400";
clearInterval(time);
return;
}
if (s1 >= num1) {
s1 = num1;
}
if (s2 >= num2) {
s2 = num2;
}
if (s3 >= num3) {
s3 = num3;
}
if (s4 >= num4) {
s4 = num4;
}
var s11 = s1.toString();
var s22 = s2.toString();
var s33 = s3.toString();
var s44 = s4.toString();
homeSection7_1.textContent =
s11.substring(0, s11.length - 3) + "," + s11.substring(s11.length - 3);
homeSection7_2.textContent =
s22.substring(0, s22.length - 3) + "," + s11.substring(s22.length - 3);
homeSection7_3.textContent =
s33.substring(0, s33.length - 3) + "," + s33.substring(s33.length - 3);
homeSection7_4.textContent =
s44.substring(0, s44.length - 3) + "," + s44.substring(s44.length - 3);
}, 1);
}
Flight.addEventListener("click", section1button1);
Hotel.addEventListener("click", section1button2);
carRent.addEventListener("click", section1button3);
function section1button2() {
Flight.classList = "";
carRent.classList = "";
Hotel.classList = "homeSection1Active";
document.querySelector("#Section1form1").style.display = "none";
document.querySelector("#Section1form2").style.display = "block";
document.querySelector("#Section1form3").style.display = "none";
}
function section1button1() {
carRent.classList = "";
Hotel.classList = "";
Flight.classList = "homeSection1Active";
document.querySelector("#Section1form1").style.display = "block";
document.querySelector("#Section1form2").style.display = "none";
document.querySelector("#Section1form3").style.display = "none";
}
function section1button3() {
Hotel.classList = "";
Flight.classList = "";
carRent.classList = "homeSection1Active";
document.querySelector("#Section1form1").style.display = "none";
document.querySelector("#Section1form2").style.display = "none";
document.querySelector("#Section1form3").style.display = "block";
}