rajkhanke commited on
Commit
c028e0d
·
verified ·
1 Parent(s): d38f151

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +1 -11
templates/index.html CHANGED
@@ -7,13 +7,11 @@
7
  /* Import a Google Font for a modern look */
8
  @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
9
 
10
- /* Keyframe for fade-in effect */
11
  @keyframes fadeIn {
12
  from { opacity: 0; transform: translateY(20px); }
13
  to { opacity: 1; transform: translateY(0); }
14
  }
15
 
16
- /* Global Styles */
17
  body {
18
  margin: 0;
19
  padding: 0;
@@ -25,7 +23,6 @@
25
  min-height: 100vh;
26
  }
27
 
28
- /* Container Styles */
29
  .container {
30
  width: 95%;
31
  max-width: 800px;
@@ -37,7 +34,6 @@
37
  animation: fadeIn 1s ease-out;
38
  }
39
 
40
- /* Heading Styles */
41
  h1 {
42
  color: #2e7d32;
43
  text-align: center;
@@ -45,7 +41,6 @@
45
  font-size: 2.8em;
46
  }
47
 
48
- /* Form Styles */
49
  form {
50
  display: flex;
51
  flex-direction: column;
@@ -93,7 +88,6 @@
93
  text-align: center;
94
  }
95
 
96
- /* Map Section Styles */
97
  .map {
98
  margin-top: 40px;
99
  text-align: center;
@@ -175,6 +169,7 @@
175
  {% if image_url %}
176
  <div class="map" id="mapContainer">
177
  <h2>Fetched Results</h2>
 
178
  <img src="{{ image_url }}" alt="Map for {{ selected_param }} parameter" onerror="handleImageError(this)">
179
  <div id="dataNotAvailable" class="error" style="display:none;">Data Not Available. Cannot plot map.</div>
180
  </div>
@@ -191,7 +186,6 @@
191
  const pestSelect = document.getElementById("pest");
192
  const selectedCrop = cropSelect.value;
193
 
194
- // Clear existing options
195
  pestSelect.innerHTML = "";
196
  const defaultOption = document.createElement("option");
197
  defaultOption.value = "";
@@ -204,14 +198,12 @@
204
  const option = document.createElement("option");
205
  option.value = p;
206
  option.textContent = p;
207
- // Preserve previous selection if any
208
  if (p === "{{ selected_pest }}") {
209
  option.selected = true;
210
  }
211
  pestSelect.appendChild(option);
212
  });
213
  }
214
- // Fetch week options if Year is selected
215
  if (document.getElementById("year").value) {
216
  fetchWeeks();
217
  }
@@ -247,13 +239,11 @@
247
  .catch(err => console.error("Error fetching weeks:", err));
248
  }
249
 
250
- // Error handler for image load failure
251
  function handleImageError(img) {
252
  img.style.display = "none";
253
  document.getElementById("dataNotAvailable").style.display = "block";
254
  }
255
 
256
- // Initialize pest dropdown and fetch weeks on page load
257
  window.onload = function() {
258
  updatePestDropdown();
259
  if ("{{ selected_year }}" && "{{ selected_crop }}" && "{{ selected_pest }}") {
 
7
  /* Import a Google Font for a modern look */
8
  @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
9
 
 
10
  @keyframes fadeIn {
11
  from { opacity: 0; transform: translateY(20px); }
12
  to { opacity: 1; transform: translateY(0); }
13
  }
14
 
 
15
  body {
16
  margin: 0;
17
  padding: 0;
 
23
  min-height: 100vh;
24
  }
25
 
 
26
  .container {
27
  width: 95%;
28
  max-width: 800px;
 
34
  animation: fadeIn 1s ease-out;
35
  }
36
 
 
37
  h1 {
38
  color: #2e7d32;
39
  text-align: center;
 
41
  font-size: 2.8em;
42
  }
43
 
 
44
  form {
45
  display: flex;
46
  flex-direction: column;
 
88
  text-align: center;
89
  }
90
 
 
91
  .map {
92
  margin-top: 40px;
93
  text-align: center;
 
169
  {% if image_url %}
170
  <div class="map" id="mapContainer">
171
  <h2>Fetched Results</h2>
172
+ <!-- Use the proxy URL for the image -->
173
  <img src="{{ image_url }}" alt="Map for {{ selected_param }} parameter" onerror="handleImageError(this)">
174
  <div id="dataNotAvailable" class="error" style="display:none;">Data Not Available. Cannot plot map.</div>
175
  </div>
 
186
  const pestSelect = document.getElementById("pest");
187
  const selectedCrop = cropSelect.value;
188
 
 
189
  pestSelect.innerHTML = "";
190
  const defaultOption = document.createElement("option");
191
  defaultOption.value = "";
 
198
  const option = document.createElement("option");
199
  option.value = p;
200
  option.textContent = p;
 
201
  if (p === "{{ selected_pest }}") {
202
  option.selected = true;
203
  }
204
  pestSelect.appendChild(option);
205
  });
206
  }
 
207
  if (document.getElementById("year").value) {
208
  fetchWeeks();
209
  }
 
239
  .catch(err => console.error("Error fetching weeks:", err));
240
  }
241
 
 
242
  function handleImageError(img) {
243
  img.style.display = "none";
244
  document.getElementById("dataNotAvailable").style.display = "block";
245
  }
246
 
 
247
  window.onload = function() {
248
  updatePestDropdown();
249
  if ("{{ selected_year }}" && "{{ selected_crop }}" && "{{ selected_pest }}") {