More chatgpt modifications

This commit is contained in:
Igor Katson 2023-11-20 22:10:01 +00:00
parent 88ca5960df
commit aef1ffbd90
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 21 additions and 21 deletions

View file

@ -1,5 +1,5 @@
// Define API URL and base path
const apiUrl = window.origin == null ? 'http://localhost:3030' : '';
const apiUrl = window.origin == 'null' ? 'http://localhost:3030' : '';
// Helper function for making API requests (async/await)
async function makeRequest(method, path, data) {
@ -99,10 +99,7 @@ async function displayTorrents() {
}
// Replace the old content with the new one
const outputDiv = document.getElementById('output');
if (outputDiv) {
outputDiv.innerHTML = '';
outputDiv.appendChild(torrentsContainer);
}
outputDiv.replaceChildren(torrentsContainer);
}
catch (error) {
console.error(error);
@ -170,7 +167,7 @@ function clearErrorAlert() {
async function init() {
try {
await displayTorrents();
autoRefreshTorrents(5000); // Set the interval (in milliseconds), e.g., 5000 for every 5 seconds
autoRefreshTorrents(500); // Set the interval (in milliseconds), e.g., 5000 for every 5 seconds
}
catch (error) {
console.error(error);

View file

@ -1,5 +1,5 @@
// Define API URL and base path
const apiUrl = 'http://localhost:3030';
const apiUrl = window.origin == 'null' ? 'http://localhost:3030' : '';
// Interface for the Torrent API response
interface Torrent {
@ -149,10 +149,8 @@ async function displayTorrents(): Promise<void> {
// Replace the old content with the new one
const outputDiv = document.getElementById('output');
if (outputDiv) {
outputDiv.innerHTML = '';
outputDiv.appendChild(torrentsContainer);
}
outputDiv.innerHTML = '';
outputDiv.appendChild(torrentsContainer);
} catch (error) {
console.error(error);
}