broadfield-dev commited on
Commit
cea6372
·
verified ·
1 Parent(s): 1e338bc

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +37 -37
templates/index.html CHANGED
@@ -96,7 +96,7 @@
96
  margin-top: 10px;
97
  }
98
  #loading {
99
- display: none; /* Initially hidden, shown during new feed loading */
100
  position: fixed;
101
  top: 0;
102
  left: 0;
@@ -126,6 +126,7 @@
126
  margin-top: 20px;
127
  color: #2c3e50;
128
  font-size: 1em;
 
129
  }
130
  </style>
131
  </head>
@@ -139,6 +140,41 @@
139
  </div>
140
  {% if loading_new_feeds %}
141
  <div class="loading-message">Loading new RSS feeds in the background...</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  {% endif %}
143
  {% for category, articles in categorized_articles.items() %}
144
  <div class="category-section">
@@ -164,41 +200,5 @@
164
  </div>
165
  </div>
166
  {% endfor %}
167
-
168
- <script>
169
- document.addEventListener('DOMContentLoaded', () => {
170
- const form = document.getElementById('searchForm');
171
- const loading = document.getElementById('loading');
172
-
173
- form.addEventListener('submit', () => {
174
- loading.style.display = 'block';
175
- });
176
-
177
- // Poll until new feeds are loaded (if loading_new_feeds is True)
178
- if ("{{ loading_new_feeds }}" === "True") {
179
- function checkNewFeeds() {
180
- fetch('/check_feeds')
181
- .then(response => response.json())
182
- .then(data => {
183
- if (data.status === "loaded") {
184
- location.reload(); // Refresh to show new articles
185
- } else if (data.status === "error") {
186
- console.error('Error loading new feeds:', data.message);
187
- loading.style.display = 'none';
188
- alert('Failed to load new RSS feeds. Please try again.');
189
- } else {
190
- setTimeout(checkNewFeeds, 1000); // Check every second
191
- }
192
- })
193
- .catch(error => {
194
- console.error('Error checking new feeds:', error);
195
- loading.style.display = 'none';
196
- alert('Network error while loading new feeds. Please try again.');
197
- });
198
- }
199
- checkNewFeeds();
200
- }
201
- });
202
- </script>
203
  </body>
204
  </html>
 
96
  margin-top: 10px;
97
  }
98
  #loading {
99
+ display: none; /* Initially hidden, shown during new feed loading or search */
100
  position: fixed;
101
  top: 0;
102
  left: 0;
 
126
  margin-top: 20px;
127
  color: #2c3e50;
128
  font-size: 1em;
129
+ display: none; /* Hidden by default, shown when loading new feeds */
130
  }
131
  </style>
132
  </head>
 
140
  </div>
141
  {% if loading_new_feeds %}
142
  <div class="loading-message">Loading new RSS feeds in the background...</div>
143
+ <script>
144
+ document.addEventListener('DOMContentLoaded', () => {
145
+ const loading = document.getElementById('loading');
146
+ const form = document.getElementById('searchForm');
147
+
148
+ form.addEventListener('submit', () => {
149
+ loading.style.display = 'block';
150
+ });
151
+
152
+ // Poll until new feeds are loaded
153
+ function checkNewFeeds() {
154
+ fetch('/check_feeds')
155
+ .then(response => response.json())
156
+ .then(data => {
157
+ if (data.status === "loaded") {
158
+ location.reload(); // Refresh to show new articles
159
+ document.querySelector('.loading-message').style.display = 'none';
160
+ } else if (data.status === "error") {
161
+ console.error('Error loading new feeds:', data.message);
162
+ loading.style.display = 'none';
163
+ alert('Failed to load new RSS feeds. Please try again.');
164
+ } else {
165
+ setTimeout(checkNewFeeds, 1000); // Check every second
166
+ }
167
+ })
168
+ .catch(error => {
169
+ console.error('Error checking new feeds:', error);
170
+ loading.style.display = 'none';
171
+ alert('Network error while loading new feeds. Please try again.');
172
+ });
173
+ }
174
+ checkNewFeeds();
175
+ document.querySelector('.loading-message').style.display = 'block';
176
+ });
177
+ </script>
178
  {% endif %}
179
  {% for category, articles in categorized_articles.items() %}
180
  <div class="category-section">
 
200
  </div>
201
  </div>
202
  {% endfor %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  </body>
204
  </html>