Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +38 -36
templates/index.html
CHANGED
@@ -126,7 +126,6 @@
|
|
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,41 +139,6 @@
|
|
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,5 +164,43 @@
|
|
200 |
</div>
|
201 |
</div>
|
202 |
{% endfor %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
</body>
|
204 |
</html>
|
|
|
126 |
margin-top: 20px;
|
127 |
color: #2c3e50;
|
128 |
font-size: 1em;
|
|
|
129 |
}
|
130 |
</style>
|
131 |
</head>
|
|
|
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 |
</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
|
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 |
+
document.querySelector('.loading-message').style.display = 'none';
|
186 |
+
} else if (data.status === "error") {
|
187 |
+
console.error('Error loading new feeds:', data.message);
|
188 |
+
loading.style.display = 'none';
|
189 |
+
alert('Failed to load new RSS feeds. Please try again.');
|
190 |
+
} else {
|
191 |
+
setTimeout(checkNewFeeds, 1000); // Check every second
|
192 |
+
}
|
193 |
+
})
|
194 |
+
.catch(error => {
|
195 |
+
console.error('Error checking new feeds:', error);
|
196 |
+
loading.style.display = 'none';
|
197 |
+
alert('Network error while loading new feeds. Please try again.');
|
198 |
+
});
|
199 |
+
}
|
200 |
+
checkNewFeeds();
|
201 |
+
document.querySelector('.loading-message').style.display = 'block';
|
202 |
+
}
|
203 |
+
});
|
204 |
+
</script>
|
205 |
</body>
|
206 |
</html>
|