arithescientist commited on
Commit
e2e78fa
·
verified ·
1 Parent(s): 5167678

Update templates/forecaster.html

Browse files
Files changed (1) hide show
  1. templates/forecaster.html +37 -23
templates/forecaster.html CHANGED
@@ -125,13 +125,24 @@
125
  </form>
126
 
127
  <!-- this will animate once the form starts submitting -->
128
- <div id="loadingBar" class="progress">
 
 
 
 
 
 
 
 
 
129
  <div
130
- class="progress-bar progress-bar-striped progress-bar-animated"
131
- role="progressbar"
132
- style="width: 0%;"
 
133
  ></div>
134
  </div>
 
135
  </div>
136
  </div>
137
  </div>
@@ -146,25 +157,28 @@
146
  <script src="{{ url_for('static', filename='assets/js/custom.js') }}"></script>
147
 
148
  <script>
149
- document.getElementById('forecastForm').addEventListener('submit', function(e) {
150
- // as soon as the browser begins navigation to your Flask endpoint...
151
- const barContainer = document.getElementById('loadingBar');
152
- const bar = barContainer.querySelector('.progress-bar');
153
- barContainer.style.display = 'block';
154
- bar.style.width = '0%';
155
-
156
- // animate it over exactly 60 seconds
157
- const duration = 60_000;
158
- const start = Date.now();
159
- const timer = setInterval(() => {
160
- const pct = Math.min(100, (Date.now() - start) / duration * 100);
161
- bar.style.width = pct + '%';
162
- if (pct === 100) clearInterval(timer);
163
- }, 100);
164
-
165
- // allow the form to actually submit—
166
- // the animation will run in the background while the new page loads
 
 
 
167
  });
168
- </script>
169
  </body>
170
  </html>
 
125
  </form>
126
 
127
  <!-- this will animate once the form starts submitting -->
128
+ <!-- Loader bar only -->
129
+ <div
130
+ id="loaderWrapper"
131
+ style="display:none;
132
+ position:relative;
133
+ width:100%;
134
+ height:4px;
135
+ background:#e9ecef;
136
+ margin-top:1rem;"
137
+ >
138
  <div
139
+ id="loaderBar"
140
+ style="width:0%;
141
+ height:100%;
142
+ background:#0d6efd;"
143
  ></div>
144
  </div>
145
+
146
  </div>
147
  </div>
148
  </div>
 
157
  <script src="{{ url_for('static', filename='assets/js/custom.js') }}"></script>
158
 
159
  <script>
160
+ document.addEventListener('DOMContentLoaded', () => {
161
+ const form = document.getElementById('forecastForm');
162
+ const wrapper = document.getElementById('loaderWrapper');
163
+ const bar = document.getElementById('loaderBar');
164
+
165
+ form.addEventListener('submit', () => {
166
+ // show & reset the bar
167
+ wrapper.style.display = 'block';
168
+ bar.style.width = '0%';
169
+
170
+ // animate 0→100% in 45s
171
+ let pct = 0;
172
+ const intervalId = setInterval(() => {
173
+ pct = Math.min(100, pct + 1);
174
+ bar.style.width = pct + '%';
175
+ if (pct === 100) clearInterval(intervalId);
176
+ }, 450);
177
+
178
+ // short delay to ensure paint, then submit
179
+ setTimeout(() => form.submit(), 50);
180
+ });
181
  });
182
+ </script>
183
  </body>
184
  </html>