fix read modal and header
This commit is contained in:
@@ -331,35 +331,24 @@
|
||||
// Check Internet Connection status
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function updateConnectionStatus() {
|
||||
const statusTextEl = document.querySelector('.connection-status-text');
|
||||
console.log('checking internet connection');
|
||||
if (!statusTextEl) {
|
||||
return;
|
||||
}
|
||||
const $statusTextEl = $('.connection-status-text');
|
||||
const $icon = $('#connection-status-item i');
|
||||
|
||||
statusTextEl.innerText = "Connecting";
|
||||
statusTextEl.style.color = "white";
|
||||
document.querySelector('#connection-status-item i').style.color = "white";
|
||||
if ($statusTextEl.length === 0) return;
|
||||
|
||||
$statusTextEl.text("Connecting").css("color", "white");
|
||||
$icon.css("color", "white");
|
||||
|
||||
|
||||
fetch("https://www.google.com/generate_204?_=" + new Date().getTime(), {
|
||||
method: 'GET',
|
||||
mode: 'no-cors',
|
||||
cache: 'no-store'
|
||||
})
|
||||
.then(function(res) {
|
||||
console.log(res);
|
||||
statusTextEl.innerText = "Online";
|
||||
statusTextEl.style.color = "lightgreen";
|
||||
document.querySelector('#connection-status-item i').style.color = "lightgreen";
|
||||
})
|
||||
.catch(function(e) {
|
||||
console.log("error", e);
|
||||
statusTextEl.innerText = "Offline";
|
||||
statusTextEl.style.color = "#ffcdd2";
|
||||
document.querySelector('#connection-status-item i').style.color = "#ffcdd2";
|
||||
});
|
||||
const img = new Image();
|
||||
img.onload = function () {
|
||||
$statusTextEl.text("Online").css("color", "lightgreen");
|
||||
$icon.css("color", "lightgreen");
|
||||
};
|
||||
img.onerror = function () {
|
||||
$statusTextEl.text("Offline").css("color", "#ffcdd2");
|
||||
$icon.css("color", "#ffcdd2");
|
||||
};
|
||||
img.src = "https://www.google.com/favicon.ico?_=" + new Date().getTime(); // avoid cache
|
||||
}
|
||||
|
||||
updateConnectionStatus();
|
||||
|
||||
Reference in New Issue
Block a user