-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpage3.html
264 lines (225 loc) · 9.43 KB
/
page3.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
<!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 href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/@aptos-labs/aptos-sdk@latest"></script>
<style>
body {
font-family: 'Poppins', sans-serif;
background-color: #f4f4f4;
background-image: url('carbon.jpg');
background-repeat: no-repeat;
background-size: cover;
margin: 0;
padding: 0;
}
header {
background-color: rgba(0, 134, 60, 1);
padding: 10px 20px;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 2;
color: white;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1200px;
margin: auto;
}
.nav-options {
display: flex;
}
.nav-options a {
margin-left: 150px;
color: white;
text-decoration: none;
font-size: 20px;
font-weight: bold;
transition: transform 0.3s ease;
}
.nav-options a:hover {
text-decoration: underline;
transform: scale(1.1);
}
.container {
margin-top: 80px;
background-color: #ffffff;
opacity: 0.9;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 1200px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 20px auto;
}
.questions, .result-container {
background: rgba(255, 255, 255, 0.9);
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
width: 45%;
}
.questions input, .questions select, .questions button {
width: 100%;
padding: 12px;
margin-bottom: 15px;
border: 1px solid #ddd;
border-radius: 6px;
box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1);
}
.questions button {
background-color: #5cb85c;
color: white;
transition: background-color 0.3s;
}
.questions button:hover {
background-color: #4cae4c;
}
.result-title {
font-size: 24px;
font-weight: bold;
color: #333;
}
.result-value {
font-size: 18px;
color: #444;
}
canvas {
margin-top: 20px;
}
.logo img {
width: 130px;
}
.main-heading {
position: relative;
z-index: 0;
color: white;
text-align: center;
font-size: 500px;
margin-top: 20px;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<div class="background-section">
<header>
<div class="header-content">
<span class = 'logo'>
<img src="logo (1).png" alt="">
</span>
<nav class="nav-options">
<a href="EcoSort.html">EcoSort</a>
<a href="page3.html">CarbonCalc</a>
<a href="page4.html">Green Tips</a>
</nav>
</div>
</header>
</div>
<br><br><br><br><br>
<div class="container">
<div class="questions">
<h2>Carbon Footprint Calculator</h2>
<label for="banana-waste">Organic Waste (kg):</label>
<input type="number" id="banana-waste" placeholder="Enter banana waste">
<label for="plastic-waste">Plastic Waste (kg):</label>
<input type="number" id="plastic-waste" placeholder="Enter plastic waste">
<label for="paper-waste">Paper Waste (kg):</label>
<input type="number" id="paper-waste" placeholder="Enter paper waste">
<button onclick="calculateFootprint()">Calculate</button>
</div>
<div class="result-container">
<center><h2 class="result-title">Results</h2></center>
<p id="result" class="result-value">Your carbon footprint will be shown here.</p>
<canvas id="myChart" width="400" height="400"></canvas>
</div>
</div>
<!-- <script>
//here we integrates a Move-based smart contract with a JavaScript/HTML frontend, allowing users to record and store their carbon footprint data on the blockchain.
// Initialize Aptos SDK
// const { AptosClient, AptosAccount } = window.aptos;
// // Replace this with your Aptos node URL
// const client = new AptosClient('https://fullnode.devnet.aptoslabs.com/v1');
// // Replace with your Aptos account's private key (for testing only)
// const account = AptosAccount.fromPrivateKey('0x2495388a20d202da293b3e49cc5ba3d83f951048e6a2be9f461513b5d74d9ec9');
// async function calculateFootprint() {
// const bananaWaste = parseFloat(document.getElementById('banana-waste').value) || 0;
// const plasticWaste = parseFloat(document.getElementById('plastic-waste').value) || 0;
// const paperWaste = parseFloat(document.getElementById('paper-waste').value) || 0;
// const bananaFootprint = bananaWaste * 0.1; // 0.1 kg CO2 per kg
// const plasticFootprint = plasticWaste * 0.3; // 0.3 kg CO2 per kg
// const paperFootprint = paperWaste * 0.2; // 0.2 kg CO2 per kg
// const totalFootprint = bananaFootprint + plasticFootprint + paperFootprint;
// document.getElementById('result').textContent = `Total Carbon Footprint: ${totalFootprint.toFixed(2)} kg CO2`; // Fixed syntax error with template literal
// // Send data to Aptos
// await sendToBlockchain(totalFootprint);
// }
// async function sendToBlockchain(totalFootprint) {
// try {
// // Transaction payload
// const payload = {
// type: 'entry_function_payload',
// function: '0x2495388a20d202da293b3e49cc5ba3d83f951048e6a2be9f461513b5d74d9ec9::CarbonFootprint', // Replace with your function
// type_arguments: [],
// arguments: [totalFootprint],
// };
// const response = await client.generateTransaction(account.address(), payload);
// const signedTx = await account.signTransaction(response);
// const txnHash = await client.submitTransaction(signedTx);
// await client.waitForTransaction(txnHash); // Wait for transaction to be confirmed
// alert(`Transaction successful! Hash: ${txnHash}`);
// } catch (error) {
// console.error(error);
// alert('Sending data to blockchain.');
// }
// }
// </script> -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
function calculateFootprint() {
const bananaWaste = parseFloat(document.getElementById('banana-waste').value) || 0;
const plasticWaste = parseFloat(document.getElementById('plastic-waste').value) || 0;
const paperWaste = parseFloat(document.getElementById('paper-waste').value) || 0;
const bananaFootprint = bananaWaste * 0.1; // 0.1 kg CO2 per kg
const plasticFootprint = plasticWaste * 0.3; // 0.3 kg CO2 per kg
const paperFootprint = paperWaste * 0.2; // 0.2 kg CO2 per kg
const totalFootprint = bananaFootprint + plasticFootprint + paperFootprint;
document.getElementById('result').textContent = `Total Carbon Footprint: ${totalFootprint.toFixed(2)} kg CO2`;
// Plot data on a bar chart
const ctx = document.getElementById('myChart').getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Organic', 'Plastic', 'Paper'],
datasets: [{
label: 'Carbon Footprint (kg CO2)',
data: [bananaFootprint, plasticFootprint, paperFootprint],
backgroundColor: ['rgba(75, 192, 192, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)'],
borderColor: ['rgba(75, 192, 192, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)'],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
}
</script>
</body>
</html>