-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-16.html
More file actions
207 lines (181 loc) · 6.23 KB
/
app-16.html
File metadata and controls
207 lines (181 loc) · 6.23 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
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
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PlantenPilaar Simulatie</title>
<style>
/* CSS voor de visuele opmaak */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #eafaf1;
margin: 0;
color: #333;
}
.container {
text-align: center;
background: white;
padding: 30px 40px;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
width: 350px;
}
h1 {
color: #2c5b42;
margin-bottom: 25px;
}
.controls {
margin: 20px 0;
}
.slider-container {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
label {
font-size: 1.1em;
}
input[type="range"] {
width: 60%;
cursor: pointer;
-webkit-appearance: none;
appearance: none;
height: 8px;
background: #d3d3d3;
border-radius: 5px;
outline: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
background: #4CAF50;
border-radius: 50%;
cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
width: 20px;
height: 20px;
background: #4CAF50;
border-radius: 50%;
cursor: pointer;
}
.value {
font-weight: bold;
font-size: 1.1em;
background-color: #f0f0f0;
padding: 5px 10px;
border-radius: 5px;
}
.plant-area {
width: 100%;
height: 300px;
background-color: #d4e7d9;
border-radius: 10px;
margin: 20px auto;
display: flex;
align-items: flex-end;
justify-content: center;
overflow: hidden;
}
#plant {
width: 60px;
/* Initiële hoogte en kleur worden door JavaScript ingesteld */
border-radius: 10px 10px 0 0;
transition: all 0.5s ease-in-out;
}
#status {
font-size: 1.2em;
font-weight: bold;
color: #555;
height: 40px; /* Vaste hoogte om layout-verschuivingen te voorkomen */
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<div class="container">
<h1>PlantenPilaar</h1>
<div class="controls">
<div class="slider-container">
<label for="sunlight">☀️ Zonlicht:</label>
<input type="range" id="sunlight" min="0" max="10" value="5">
<span id="sunlight-value" class="value">5</span>
</div>
<div class="slider-container">
<label for="water">💧 Water:</label>
<input type="range" id="water" min="0" max="10" value="5">
<span id="water-value" class="value">5</span>
</div>
</div>
<div class="plant-area">
<div id="plant"></div>
</div>
<p id="status"></p>
</div>
<script>
// JavaScript voor de functionaliteit
const sunlightSlider = document.getElementById('sunlight');
const waterSlider = document.getElementById('water');
const sunlightValueSpan = document.getElementById('sunlight-value');
const waterValueSpan = document.getElementById('water-value');
const plant = document.getElementById('plant');
const statusText = document.getElementById('status');
let plantHeight = 100; // Beginhoogte in pixels
const maxHeight = 280; // Maximale hoogte
const minHeight = 40; // Minimale hoogte
// Functie om de status van de plant bij te werken
function updatePlantStatus() {
const sun = parseInt(sunlightSlider.value);
const water = parseInt(waterSlider.value);
// Waardes naast de schuifbalken bijwerken
sunlightValueSpan.textContent = sun;
waterValueSpan.textContent = water;
// Controleer de condities voor groei of verwelking
if (sun >= 4 && sun <= 7 && water >= 4 && water <= 7) {
// Groeiconditie
plant.style.backgroundColor = '#2ecc71'; // Levendig groen
statusText.textContent = 'De plant groeit goed!';
if (plantHeight < maxHeight) {
plantHeight += 5;
}
} else {
// Verwelkingsconditie
plant.style.backgroundColor = '#a0522d'; // Bruine kleur
if (plantHeight > minHeight) {
plantHeight -= 4;
}
// Bepaal de juiste uitleg
if (sun < 4 && water < 4) {
statusText.textContent = 'Te weinig zonlicht en water.';
} else if (sun > 7 && water > 7) {
statusText.textContent = 'Teveel zonlicht en water!';
} else if (sun < 4) {
statusText.textContent = 'Te weinig zonlicht, de plant verwelkt.';
} else if (sun > 7) {
statusText.textContent = 'Teveel zonlicht, de plant verbrandt.';
} else if (water < 4) {
statusText.textContent = 'Te weinig water, de plant verdroogt.';
} else if (water > 7) {
statusText.textContent = 'Teveel water, de plant verdrinkt.';
}
}
// Pas de hoogte van de plant aan
plant.style.height = plantHeight + 'px';
}
// Voeg 'event listeners' toe aan de schuifbalken
sunlightSlider.addEventListener('input', updatePlantStatus);
waterSlider.addEventListener('input', updatePlantStatus);
// Roep de functie eenmaal aan bij het laden van de pagina om de beginstatus in te stellen
window.onload = updatePlantStatus;
</script>
</body>
</html>