Move some things around
This commit is contained in:
parent
9873502b08
commit
5368b1815f
1 changed files with 6 additions and 9 deletions
15
script.js
15
script.js
|
@ -1,15 +1,18 @@
|
||||||
async function websiteUp(url) {
|
async function websiteUp(url) {
|
||||||
// TODO Fix CORS
|
// TODO Fix CORS
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { method: 'head' });
|
const response = await fetch(url, { method: 'options' });
|
||||||
console.log(response);
|
return response.ok;
|
||||||
return false;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`An error occurred while checking the URL '${url}': ${error.message}`);
|
console.error(`An error occurred while checking the URL '${url}': ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function check(destination, container, dot, message, button) {
|
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);
|
const destinationUp = await websiteUp(destination);
|
||||||
|
|
||||||
if (destinationUp) {
|
if (destinationUp) {
|
||||||
|
@ -34,14 +37,8 @@ async function check(destination, container, dot, message, button) {
|
||||||
|
|
||||||
function createCheckButton(destination) {
|
function createCheckButton(destination) {
|
||||||
const dot = document.createElement('span');
|
const dot = document.createElement('span');
|
||||||
dot.className = 'dot orange';
|
|
||||||
dot.id = 'checkDot';
|
|
||||||
|
|
||||||
const message = document.createElement('span');
|
const message = document.createElement('span');
|
||||||
message.textContent = 'Checking availability...';
|
|
||||||
|
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.style.visibility = 'hidden';
|
|
||||||
|
|
||||||
const container = document.getElementById('checkContainer');
|
const container = document.getElementById('checkContainer');
|
||||||
container.appendChild(dot);
|
container.appendChild(dot);
|
||||||
|
|
Loading…
Reference in a new issue