-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilege.html
303 lines (276 loc) · 9.44 KB
/
milege.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carbon Footprint Calculator</title>
<link rel="stylesheet" href="style3.css">
<style>
*{
margin: 0px;
padding: 0px;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: rgb(255, 255, 255);
/* Set background color */
background-image: url(./images/back.jpg);
}
header {
background-color: rgb(255, 255, 255); /* Set header background color */
padding: 10px 20px; /* Add padding to header */
display: flex;
justify-content: space-between;
align-items: center;
}
.header-logo {
display: flex;
align-items: center;
}
.header-logo img {
height: 4.3rem;
margin-right: 10px; /* Add margin to separate logo and text */
}
.header-logo a {
font-size: 1.2rem; /* Set font size */
font-weight: bold; /* Set font weight to bold */
text-decoration: none; /* Remove underline */
color: black; /* Set color */
}
.header-links {
display: flex;
gap: 20px;
}
.container{
display: flex;
flex-direction: row;
background-color: transparent;
}
.home-links{
margin-top: 20px;
}
.home-links a {
text-decoration: none; /* Remove underline */
color: inherit; /* Inherit text color */
cursor: pointer; /* Change cursor to pointer on hover */
transition: color 0.3s ease; /* Add smooth color transition */
margin-right: 4px; /* Add margin between links */
padding-right: 4px; /* Add padding to visually separate links */
border-right: 1px solid #ccc; /* Add border between links */
}
.home-links a:last-child {
margin-right: 0; /* Remove margin for the last link */
padding-right: 0; /* Remove padding for the last link */
border-right: none; /* Remove border for the last link */
}
/* Remove default anchor styles */
.navbarContainer .logo {
text-decoration: none;
color: inherit;
}
/* Style for mobile navigation */
.mobile-nav {
display: none;
}
#calculateBtn{
width: 200px;
margin-top: 420px;
margin-left: -1000px;
}
#home{
position: relative;
height: 350px;
width: 500px;
background-color: rgba(198, 201, 200, 0.767);
border-radius: 22px;
display: flex;
flex-direction: column;
justify-content: center;
margin-left: -240px;
transition-duration: 0.3s;
}
#home:hover{
background-color: rgba(0, 255, 110, 0.621);
}
#car{
position: relative;
height: 350px;
width: 500px;
background-color: rgba(198, 201, 200, 0.767);
border-radius: 22px;
display: flex;
flex-direction: column;
justify-content: center;
transition-duration: 0.3s;
}
#car:hover{
background-color: rgba(0, 255, 110, 0.621);
}
#result{
margin-top: 430px;
width: 250px;
}
#name{
margin-bottom: 20px;
}
#navb{
position: relative;
margin: 10px;
border:2px solid black;
border-radius: 22px;
width: 90px;
}
#offsetbtn{
width: 190px;
margin-left: 280px;
}
@media screen and (max-width: 600px) {
/* Adjust card width for smaller screens */
.card {
width: calc(50% - 20px);
}
/* Show mobile navigation */
.home-desktop-menu {
display: none;
}
.mobile-nav {
display: block;
text-align: center;
margin-top: 10px;
}
}
/* Style for collapsible sections */
.section {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
}
.section-header {
cursor: pointer;
font-weight: bold;
}
.input-group {
display: none;
}
.input-group.active {
display: block;
}
</style>
</head>
<body>
<header>
<div class="header-logo">
<img src="images/LOGO.jpg" style="border-radius: 50px;">
<a href="index.html">ECO-CHAIN</a>
</div>
<div class="header-links">
<nav class="home-links">
<span class="bodySmall" id="navb"><a href="milege.html">Calculate</a></span>
<span class="home-nav22 bodySmall" id="navb"><a href="reduce.html">Reduce</a></span>
<span class="home-nav32 bodySmall" id="navb"><a href="measure.html">Measures</a></span>
<span class="home-nav52 bodySmall" id="navb"><a href="contact.html">Contact</a></span>
</nav>
<!-- Mobile Navigation -->
<div class="mobile-nav">
<nav class="home-links">
<span class="bodySmall"><a href="milege.html">Calculate</a></span>
<span class="home-nav22 bodySmall"><a href="reduce.html">Reduce</a></span>
<span class="home-nav32 bodySmall"><a href="measure.html">Measures</a></span>
<span class="home-nav52 bodySmall"><a href="contact.html">Contact</a></span>
</nav>
</div>
</div>
</header>
<div class="container">
<!-- Home Section -->
<div class="section" id="home">
<h2 class="section-header" onclick="toggleSection('home')">Organization</h2>
<div class="input-group">
<label for="employee">Employee Name:
</label>
<input type="text" placeholder="Enter your name" name="empname" id="name">
<label>Select the vehicle: <input list="dom" placeholder="Select your vehicle" name="dom" ></label>
<datalist id="dom" class="list">
<option value="Bike"></option>
<option value="Car"></option>
<option value="Truck"></option>
<option value="Cycle/Walk"></option>
</datalist>
<label for="fuel">Fuel Consumption (Mileage):</label>
<input type="number" id="fuel" placeholder="Enter consumption (Mileage)">
</div>
<div class="input-group">
<label for="dist">Distance Covered (km):</label>
<input type="number" id="dist" placeholder="Enter distance (km)">
</div>
</div>
<!-- Car Section -->
<div class="section" id="car">
<h2 class="section-header" onclick="toggleSection('car')">Individual</h2>
<div class="input-group">
<form action="/calculate" method="post">
<label for="individual">Enter your name: </label>
<input type="text" name="indiname" placeholder="Enter the name" id="name">
<label>Select the vehicle: <input list="dom" placeholder="Select your vehicle" name="dom"></label>
<datalist id="dom" class="list">
<option value="Bike"></option>
<option value="Car"></option>
<option value="Truck"></option>
<option value="Cycle/Walk"></option>
</datalist>
<label for="fuelConsumption" >Fuel Consumption (Mileage):</label>
<input type="number" id="fuelConsumption" placeholder="Enter consumption (Mileage)">
</form>
</div>
<div class="input-group">
<form action="/calculate" method="post">
<label for="distance">Distance Covered (km):</label>
<input type="number" id="distance" placeholder="Enter distance (km)">
</form>
</div>
</div>
<button id="calculateBtn" onclick="reduce()">Calculate</button>
<div id="result">
<div id="result1"></div>
<div id="result2"></div>
<div id="result3"></div>
</div>
</div>
<button id="offsetbtn" onclick="popup()">Offset</button>
<script src="reduce.js"></script>
<script>
let collaborationType = '';
function toggleSection(sectionId) {
var section = document.getElementById(sectionId);
var inputGroups = section.getElementsByClassName('input-group');
for (var i = 0; i < inputGroups.length; i++) {
inputGroups[i].classList.toggle('active');
}
}
function popup() {
let Amount_Sequeration_Of_Trees = 22;
let Amount_CO2_Released = document.getElementById("result1").innerText.trim(); // Get the text content and remove any leading/trailing whitespace
let numericalValue = parseFloat(Amount_CO2_Released.match(/\d+(\.\d+)?/)); // Extract numerical value using regular expression
if (!isNaN(numericalValue) && numericalValue > 0 && numericalValue < 1) {
// If the value is a valid number and between 0 and 1
let Trees_To_Be_Planted = 1; // Set the number of trees to 1
window.alert("The amount of trees to be planted: " + Trees_To_Be_Planted);
} else if (!isNaN(numericalValue)) {
// If the value is a valid number but not between 0 and 1
let Trees_To_Be_Planted = numericalValue / Amount_Sequeration_Of_Trees;
window.alert("The amount of trees to be planted: " + Trees_To_Be_Planted);
} else {
window.alert("Error: The CO2 value is not valid.");
}
}
document.getElementById("offsetbtn").addEventListener("click", popup);
if (sectionId === 'home') {
collaborationType = 'Organization';
} else if (sectionId === 'car') {
collaborationType = 'Individual';
}
</script>
</body>
</html>