[c164f8f] | 1 | document.getElementById('startScraperButton').addEventListener('click', function() {
|
---|
| 2 |
|
---|
| 3 | fetch('/admin/start-scraper', { method: 'POST' })
|
---|
| 4 | .then(response => response.json())
|
---|
| 5 | .then(data => alert(data.message))
|
---|
| 6 | .catch(error => console.error('Error:', error));
|
---|
| 7 |
|
---|
| 8 | fetchLastUpdateTime();
|
---|
| 9 | });
|
---|
| 10 | function popupConfirm(){
|
---|
| 11 | const div = document.getElementById('warning').style.display = 'block';
|
---|
| 12 | }
|
---|
| 13 | function popupClose(){
|
---|
| 14 | const div = document.getElementById('warning').style.display = 'none';
|
---|
| 15 | }
|
---|
| 16 | document.getElementById('confirmDrop').addEventListener('click', function() {
|
---|
| 17 |
|
---|
| 18 | fetch('/admin/drop-db', {method: 'GET'}).then(r => alert("Database dropped")).catch(err => console.error(err));
|
---|
| 19 | popupClose();
|
---|
| 20 | });
|
---|
| 21 | function fetchLastUpdateTime() {
|
---|
| 22 | fetch('/admin/last-update-time')
|
---|
| 23 | .then(response => response.json())
|
---|
| 24 | .then(data => {
|
---|
| 25 | document.getElementById('lastUpdateTime').textContent = new Date(data.lastUpdateTime).toLocaleString();
|
---|
| 26 | })
|
---|
| 27 | .catch(error => console.error('Error fetching last update time:', error));
|
---|
| 28 | }
|
---|
| 29 | function fetchCurrentOptionsCount() {
|
---|
| 30 | fetch('/admin/current-options-count')
|
---|
| 31 | .then(response => response.json())
|
---|
| 32 | .then(data => {
|
---|
| 33 | document.getElementById('currentOptionsCount').textContent = data.currentOptionsCount;
|
---|
| 34 | })
|
---|
| 35 | .catch(error => console.error('Error fetching current options count:', error));
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | // Fetch data when the page loads
|
---|
| 39 | document.addEventListener('DOMContentLoaded', function() {
|
---|
| 40 | fetchLastUpdateTime();
|
---|
| 41 | fetchCurrentOptionsCount();
|
---|
| 42 | });
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | document.getElementById('logoutButton').addEventListener('click', function() {
|
---|
| 46 | sessionStorage.removeItem('loggedIn');
|
---|
| 47 | sessionStorage.removeItem('userEmail');
|
---|
| 48 | window.location.href = 'index.html'; // Redirect
|
---|
| 49 | }); |
---|