-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.html
182 lines (159 loc) · 6.22 KB
/
homepage.html
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.8/css/line.css">
<link rel="stylesheet" href="style.css">
<title>home page</title>
</head>
<body>
<header class="header">
<a href="#" class="header__logo"><span class="logoname">finta</span>nce</a>
<i class='uil uil-bars header__toggle' id="header-toggle"></i>
<nav class="nav" id="nav-menu">
<div class="nav-content bd-grid">
<div class="nav__menu">
<ul class="nav-list">
<li class="nav-item">
<a href="#" class="nav-link active">Home</a>
</li>
<li class="nav-item">
<a href="transaction_history.php" class="nav-link">transaction history</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Privacy Policy</a>
</li>
<li class="nav-item">
<a href="transfer.html" class="nav-link active">Transfer Money</a></li>
</ul>
</div>
</div>
</nav>
</header>
<div class="slogan">
<div class="slogan_content">
<h2>Think <span class="smart">smart,</span>
<br>bank with us</h2>
<span class="moto">A customer focused bank that provides complete finincial <br>
solutions to meet your entire finincial needs</span>
</div>
</div>
<div class="customer">
<div class="customer-content">
<p>🧑🏻👧🏻 <span class="customer_count">There are more than 125 million users world wide</span></p>
</div>
</div>
<div class="exchange">
<div class="exchange_content">
<h2>Exchange<span class="money">Money</span></h2>
<p>Make your money go further</p>
</div>
<form action="#">
<div class="amount">
<p>Enter amount</p>
<input type="text" value="1">
</div>
</form>
<div class="drop-list">
<div class="from">
<div class="select-box">
<img src="https://flagcdn.com/48x36/us.png" alt="flag">
<select></select>
</div>
</div>
<div class="icon"><i class="uil uil-exchange-alt" style="color: white;"></i></div>
<div class="to">
<div class="select-box">
<img src="https://flagcdn.com/48x36/np.png" alt="flag">
<select></select>
</div>
</div>
</div>
<div class="exchange-rate">Getting exchange rate...</div><br>
<div class="exchange-button">
<button>Get Exchange Rate</button></div>
</div>
</body>
<!--this is script for country-codes-->
<script src="country-list.js"></script>
<!--this is script for responsive nav-bar-->
<script>
const showMenu = (toggleId, navId)=>{
const toggle = document.getElementById(toggleId),
nav = document.getElementById(navId)
if(toggle && nav){
toggle.addEventListener('click', ()=>{
nav.classList.toggle('show')
toggle.classList.toggle('bx-x')
})
}
}
showMenu('header-toggle','nav-menu')
const navLink = document.querySelectorAll('.nav-link');
function linkAction(){
navLink.forEach(n => n.classList.remove('active'));
this.classList.add('active');
}
navLink.forEach(n => n.addEventListener('click', linkAction));
</script>
<!--this is script for exchange rate-->
<script>
const dropList = document.querySelectorAll("form select"),
fromCurrency = document.querySelector(".from select"),
toCurrency = document.querySelector(".to select"),
getButton = document.querySelector("form button");
for (let i = 0; i < dropList.length; i++) {
for(let currency_code in country_list){
let selected = i == 0 ? currency_code == "USD" ? "selected" : "" : currency_code == "NPR" ? "selected" : "";
let optionTag = `<option value="${currency_code}" ${selected}>${currency_code}</option>`;
dropList[i].insertAdjacentHTML("beforeend", optionTag);
}
dropList[i].addEventListener("change", e =>{
loadFlag(e.target);
});
}
function loadFlag(element){
for(let code in country_list){
if(code == element.value){
let imgTag = element.parentElement.querySelector("img");
imgTag.src = `https://flagcdn.com/48x36/${country_list[code].toLowerCase()}.png`;
}
}
}
window.addEventListener("load", ()=>{
getExchangeRate();
});
getButton.addEventListener("click", e =>{
e.preventDefault();
getExchangeRate();
});
const exchangeIcon = document.querySelector("form .icon");
exchangeIcon.addEventListener("click", ()=>{
let tempCode = fromCurrency.value;
fromCurrency.value = toCurrency.value;
toCurrency.value = tempCode;
loadFlag(fromCurrency);
loadFlag(toCurrency);
getExchangeRate();
})
function getExchangeRate(){
const amount = document.querySelector("form input");
const exchangeRateTxt = document.querySelector("form .exchange-rate");
let amountVal = amount.value;
if(amountVal == "" || amountVal == "0"){
amount.value = "1";
amountVal = 1;
}
exchangeRateTxt.innerText = "Getting exchange rate...";
let url = `https://v6.exchangerate-api.com/v6/YOUR-API-KEY/latest/${fromCurrency.value}`;
fetch(url).then(response => response.json()).then(result =>{
let exchangeRate = result.conversion_rates[toCurrency.value];
let totalExRate = (amountVal * exchangeRate).toFixed(2);
exchangeRateTxt.innerText = `${amountVal} ${fromCurrency.value} = ${totalExRate} ${toCurrency.value}`;
}).catch(() =>{
exchangeRateTxt.innerText = "Something went wrong";
});
}
</script>
</html>