-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.html
124 lines (111 loc) · 3.7 KB
/
design.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Energy Usage Tracker</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #DFEED4;
margin: 0;
padding: 0;
}
.room-container {
margin: 20px;
border-radius: 10px;
background-color: #E1DFCF;
padding: 30px; /* increased padding */
margin-bottom: 20px; /* increased margin-bottom */
position: relative;
}
.room-title {
font-weight: bold;
margin-bottom: 20px; /* increased margin-bottom */
}
.energy-usage {
border-radius: 10px; /* adjusted border-radius to match parent */
background-color: #E2D2CB;
padding: 10px; /* decreased padding */
text-align: center;
margin-top: 30px; /* increased margin-top */
width: 100%; /* adjusted width to fit parent */
}
.add-room-button {
width: 40px;
height: 40px;
background-color: #E1DFCF;
border: none;
border-radius: 5px;
font-size: 20px;
color: #929292;
cursor: pointer;
position: fixed;
bottom: 20px;
right: 20px;
}
.above-average {
background-color: red;
color: white;
}
.nav-tabs img {
width: 50px; /* Adjust the width as needed */
height: auto; /* Maintain the aspect ratio */
}
</style>
</head>
<body>
<div id="roomContainer"></div>
<button class="add-room-button" onclick="addRoom()">+</button>
<script>
function addRoom() {
var roomContainer = document.getElementById('roomContainer');
var roomDiv = document.createElement('div');
roomDiv.classList.add('room-container');
var roomTitle = document.createElement('div');
roomTitle.classList.add('room-title');
roomTitle.textContent = 'Room: ';
var roomSelect = document.createElement('select');
var roomOptions = ['None', 'Bedroom', 'Kitchen', 'Toilet', 'Living Room']; // Updated room options
roomOptions.forEach(function(option) {
var optionElement = document.createElement('option');
optionElement.textContent = option;
roomSelect.appendChild(optionElement);
});
roomTitle.appendChild(roomSelect);
roomDiv.appendChild(roomTitle);
var energyUsageDiv = document.createElement('div');
energyUsageDiv.classList.add('energy-usage');
var energyTitle = document.createElement('div');
energyTitle.textContent = 'Average Energy Used Today';
energyUsageDiv.appendChild(energyTitle);
var energyValue = document.createElement('div');
var energyUsage = 0; // Default value
roomSelect.addEventListener('change', function() {
if (roomSelect.value !== 'None') {
energyUsage = Math.floor(Math.random() * 50) + 1; // Generate random energy usage
energyValue.textContent = energyUsage + ' kWh';
} else {
energyUsage = 0;
energyValue.textContent = energyUsage + ' kWh';
}
if (energyUsage > 29) {
energyUsageDiv.classList.add('above-average');
var aboveAverageLabel = document.createElement('div');
aboveAverageLabel.textContent = 'Energy usage here exceeds average';
energyUsageDiv.appendChild(aboveAverageLabel);
} else {
energyUsageDiv.classList.remove('above-average');
var aboveAverageLabel = energyUsageDiv.querySelector('.above-average-label');
if (aboveAverageLabel) {
energyUsageDiv.removeChild(aboveAverageLabel);
}
}
});
energyUsageDiv.appendChild(energyValue);
roomDiv.appendChild(energyUsageDiv);
roomContainer.appendChild(roomDiv);
}
</script>
</body>
</html>