From fb02fc80a0acac557f6f53c5ecd81710301fbcc1 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 26 May 2023 17:06:38 -0400 Subject: [PATCH] Making things easier. --- app/index.current.html | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/app/index.current.html b/app/index.current.html index cadb59b..6ddb121 100644 --- a/app/index.current.html +++ b/app/index.current.html @@ -62,6 +62,51 @@ document.aether = { name: 'Aether Native App (Electron and Svelte)' }; + + function is_online(uri) { + let xhr = new XMLHttpRequest(); + xhr.open('GET',uri,false); + try { + xhr.send(null); + } catch (error) { + console.error(error); + } + if(xhr.status == 200) { + //is online + return xhr.responseText; + } + else { + //is offline + return null; + } + } + + if (is_online(native_app_config.native_app_js_css_base_url)) { + console.log(`Appears to be live: ${native_app_config.native_app_js_css_base_url}`); + } else if (native_app_config.native_app_js_css_base_url_bak) { + console.log(`Appears to be live: ${native_app_config.native_app_js_css_base_url_bak}`); + native_app_js_css_base_url = native_app_config.native_app_js_css_base_url_bak; + } else if (is_online('https://app.oneskyit.com')) { + console.log(`Appears to be live: https://app.oneskyit.com`); + native_app_js_css_base_url = 'https://app.oneskyit.com'; + } else if (is_online('https://oneskyit.com')) { + console.log(`One Sky IT appears to be online`); + native_app_js_css_base_url = 'https://oneskyit.com'; + } else if (is_online('https://google.com')) { + console.log(`Google appears to be online`); + native_app_js_css_base_url = 'https://google.com'; + } else { + console.log('We are offline!'); + } + + // console.log(`One Sky IT appears to be online ${is_online('https://oneskyit.com')}`); + // console.log(`Google appears to be online ${is_online('https://google.com')}`); + + // console.log(is_online('https://oneskyit.com')); + // console.log(is_online('https://cmsc.oneskyit.com')); + // console.log(is_online('https://dev-cmsc.oneskyit.com')); + // console.log(is_online('https://google.com')); + @@ -107,7 +152,7 @@ const client_user_jwt = {}; // Future use let client_account_id = native_app_config.account_id; - console.log(client_account_id); + // console.log(client_account_id); // END: Client constants set by server when rendering HTML