broadfield-dev commited on
Commit
33970e1
·
verified ·
1 Parent(s): 8004f63

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +30 -8
templates/index.html CHANGED
@@ -19,8 +19,8 @@
19
  .description { color: #555; font-size: 0.9em; height: 150px; overflow-y: clip; }
20
  .published { font-size: 0.8em; color: #95a5a6; }
21
  .no-articles { text-align: center; color: #2c3e50; margin-top: 20px; }
22
- .loading-message { text-align: center; color: #3498db; margin: 10px 0; }
23
- .loading-spinner { display: none; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 20px; height: 20px; animation: spin 1s linear infinite; margin-left: 10px; }
24
  @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
25
  </style>
26
  </head>
@@ -33,12 +33,14 @@
33
  <button id="backButton" style="display: none; margin-top: 10px;">Back to Main</button>
34
  </div>
35
  {% if loading %}
36
- <div class="loading-message">Fetching new RSS feeds in the background...</div>
 
 
37
  {% endif %}
38
  {% if has_articles %}
39
  {% for category, articles in categorized_articles.items() %}
40
  <div class="category-section">
41
- <div class="category-title" onclick="toggleCategory('{{ category }}')">{{ category }} <span class="loading-spinner" id="spinner-{{ category }}"></span></div>
42
  <div class="tiles" id="category-{{ category }}" data-last-update="0">
43
  {% for article in articles %}
44
  <div class="article-tile" data-published="{{ article.published }}" data-id="{{ loop.index }}">
@@ -72,12 +74,10 @@
72
  const tilesDiv = document.getElementById(`category-${category}`);
73
  const allTilesDiv = document.getElementById(`all-${category}`);
74
  if (expandedCategories.has(category)) {
75
- // Collapse: show only 10 articles
76
  tilesDiv.style.display = 'grid';
77
  allTilesDiv.style.display = 'none';
78
  expandedCategories.delete(category);
79
  } else {
80
- // Expand: load all articles
81
  spinner.style.display = 'inline-block';
82
  fetch(`/get_all_articles/${category}`)
83
  .then(response => response.json())
@@ -177,7 +177,8 @@
177
  }
178
  }
179
  }
180
- document.querySelector('.loading-message').style.display = 'none';
 
181
  }
182
  setTimeout(updateArticles, 2000);
183
  })
@@ -187,6 +188,22 @@
187
  });
188
  }
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  document.addEventListener('DOMContentLoaded', () => {
191
  const tiles = document.querySelectorAll('.tiles');
192
  tiles.forEach(tile => {
@@ -194,6 +211,11 @@
194
  });
195
  updateArticles();
196
 
 
 
 
 
 
197
  const form = document.getElementById('searchForm');
198
  const backButton = document.getElementById('backButton');
199
  form.addEventListener('submit', (event) => {
@@ -214,7 +236,7 @@
214
 
215
  const categoriesHtml = Object.entries(data.categorized_articles).map(([cat, articles]) => `
216
  <div class="category-section">
217
- <div class="category-title" onclick="toggleCategory('${cat}')">${cat} <span class="loading-spinner" id="spinner-${cat}"></span></div>
218
  <div class="tiles" id="category-${cat}" data-last-update="0">
219
  ${articles.map((article, index) => `
220
  <div class="article-tile" data-published="${article.published}" data-id="${index}">
 
19
  .description { color: #555; font-size: 0.9em; height: 150px; overflow-y: clip; }
20
  .published { font-size: 0.8em; color: #95a5a6; }
21
  .no-articles { text-align: center; color: #2c3e50; margin-top: 20px; }
22
+ .loading-container { text-align: center; margin: 10px 0; }
23
+ .loading-spinner { display: inline-block; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 20px; height: 20px; animation: spin 1s linear infinite; }
24
  @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
25
  </style>
26
  </head>
 
33
  <button id="backButton" style="display: none; margin-top: 10px;">Back to Main</button>
34
  </div>
35
  {% if loading %}
36
+ <div class="loading-container" id="loadingContainer">
37
+ <span class="loading-spinner"></span>
38
+ </div>
39
  {% endif %}
40
  {% if has_articles %}
41
  {% for category, articles in categorized_articles.items() %}
42
  <div class="category-section">
43
+ <div class="category-title" onclick="toggleCategory('{{ category }}')">{{ category }} <span class="loading-spinner" id="spinner-{{ category }}" style="display: none;"></span></div>
44
  <div class="tiles" id="category-{{ category }}" data-last-update="0">
45
  {% for article in articles %}
46
  <div class="article-tile" data-published="{{ article.published }}" data-id="{{ loop.index }}">
 
74
  const tilesDiv = document.getElementById(`category-${category}`);
75
  const allTilesDiv = document.getElementById(`all-${category}`);
76
  if (expandedCategories.has(category)) {
 
77
  tilesDiv.style.display = 'grid';
78
  allTilesDiv.style.display = 'none';
79
  expandedCategories.delete(category);
80
  } else {
 
81
  spinner.style.display = 'inline-block';
82
  fetch(`/get_all_articles/${category}`)
83
  .then(response => response.json())
 
177
  }
178
  }
179
  }
180
+ const loadingContainer = document.getElementById('loadingContainer');
181
+ if (loadingContainer) loadingContainer.style.display = 'none';
182
  }
183
  setTimeout(updateArticles, 2000);
184
  })
 
188
  });
189
  }
190
 
191
+ function checkLoadingStatus() {
192
+ fetch('/check_loading')
193
+ .then(response => response.json())
194
+ .then(data => {
195
+ if (data.status === 'complete') {
196
+ window.location.reload(); // Refresh the page when loading is complete
197
+ } else {
198
+ setTimeout(checkLoadingStatus, 2000); // Check again after 2 seconds
199
+ }
200
+ })
201
+ .catch(error => {
202
+ console.error('Error checking loading status:', error);
203
+ setTimeout(checkLoadingStatus, 2000);
204
+ });
205
+ }
206
+
207
  document.addEventListener('DOMContentLoaded', () => {
208
  const tiles = document.querySelectorAll('.tiles');
209
  tiles.forEach(tile => {
 
211
  });
212
  updateArticles();
213
 
214
+ // Start checking loading status if loading is active
215
+ if (document.getElementById('loadingContainer')) {
216
+ checkLoadingStatus();
217
+ }
218
+
219
  const form = document.getElementById('searchForm');
220
  const backButton = document.getElementById('backButton');
221
  form.addEventListener('submit', (event) => {
 
236
 
237
  const categoriesHtml = Object.entries(data.categorized_articles).map(([cat, articles]) => `
238
  <div class="category-section">
239
+ <div class="category-title" onclick="toggleCategory('${cat}')">${cat} <span class="loading-spinner" id="spinner-${cat}" style="display: none;"></span></div>
240
  <div class="tiles" id="category-${cat}" data-last-update="0">
241
  ${articles.map((article, index) => `
242
  <div class="article-tile" data-published="${article.published}" data-id="${index}">