From 5368b1815fdf18099c3d1b7e9756c57cea2f1611 Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Fri, 4 Aug 2023 15:12:24 +0200 Subject: [PATCH] Move some things around --- script.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/script.js b/script.js index 16814e9..2073a9c 100644 --- a/script.js +++ b/script.js @@ -1,15 +1,18 @@ async function websiteUp(url) { // TODO Fix CORS try { - const response = await fetch(url, { method: 'head' }); - console.log(response); - return false; + const response = await fetch(url, { method: 'options' }); + return response.ok; } catch (error) { console.error(`An error occurred while checking the URL '${url}': ${error.message}`); } } async function check(destination, container, dot, message, button) { + dot.className = 'dot orange'; + message.textContent = 'Checking availability...'; + button.style.visibility = 'hidden'; + const destinationUp = await websiteUp(destination); if (destinationUp) { @@ -34,14 +37,8 @@ async function check(destination, container, dot, message, button) { function createCheckButton(destination) { const dot = document.createElement('span'); - dot.className = 'dot orange'; - dot.id = 'checkDot'; - const message = document.createElement('span'); - message.textContent = 'Checking availability...'; - const button = document.createElement('button'); - button.style.visibility = 'hidden'; const container = document.getElementById('checkContainer'); container.appendChild(dot);