94 lines
2.7 KiB
HTML
94 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Dashboard</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; padding: 10px; }
|
|
input { margin: 5px 0; }
|
|
#logs { margin-top: 20px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h2>Auto Update Settings</h2>
|
|
<input type="text" id="baseUrl" placeholder="Enter base URL (e.g., https://novelbin.com/b/a-villains-will-to-survive/)" /><br/>
|
|
<label>
|
|
<input type="checkbox" id="autoUpdateToggle" />
|
|
Auto Update Chapters
|
|
</label><br/>
|
|
<button id="logoutBtn">Logout</button>
|
|
<div id="status"></div>
|
|
|
|
<h3>Update Logs</h3>
|
|
<ul id="logs"></ul>
|
|
|
|
<script>
|
|
const autoUpdateToggle = document.getElementById('autoUpdateToggle');
|
|
const baseUrlInput = document.getElementById('baseUrl');
|
|
const statusDiv = document.getElementById('status');
|
|
const logsUl = document.getElementById('logs');
|
|
const logoutBtn = document.getElementById('logoutBtn');
|
|
|
|
autoUpdateToggle.addEventListener('change', function(e) {
|
|
if(e.target.checked) {
|
|
const baseUrl = baseUrlInput.value.trim();
|
|
if(!baseUrl) {
|
|
statusDiv.textContent = 'Please enter a base URL.';
|
|
autoUpdateToggle.checked = false;
|
|
return;
|
|
}
|
|
startAutoUpdate(baseUrl);
|
|
} else {
|
|
stopAutoUpdate();
|
|
}
|
|
});
|
|
|
|
function startAutoUpdate(baseUrl) {
|
|
fetch('/start', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ baseUrl })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
statusDiv.textContent = data.message;
|
|
})
|
|
.catch(err => {
|
|
statusDiv.textContent = 'Error starting auto update.';
|
|
console.error(err);
|
|
});
|
|
}
|
|
|
|
function stopAutoUpdate() {
|
|
fetch('/stop', { method: 'POST' })
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
statusDiv.textContent = data.message;
|
|
})
|
|
.catch(err => {
|
|
statusDiv.textContent = 'Error stopping auto update.';
|
|
console.error(err);
|
|
});
|
|
}
|
|
|
|
// Poll the update logs every 5 seconds
|
|
setInterval(() => {
|
|
fetch('/logs')
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
logsUl.innerHTML = '';
|
|
data.updates.forEach(update => {
|
|
const li = document.createElement('li');
|
|
li.textContent = `${new Date(update.timestamp).toLocaleTimeString()}: ${update.url}`;
|
|
logsUl.appendChild(li);
|
|
});
|
|
})
|
|
.catch(err => console.error(err));
|
|
}, 5000);
|
|
|
|
logoutBtn.addEventListener('click', function() {
|
|
window.location.href = '/logout';
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|