fix read modal and header

This commit is contained in:
aungthetkhaing
2025-05-28 11:55:59 +06:30
parent 75fa4436ff
commit b82e2197fd
2 changed files with 51 additions and 73 deletions

View File

@@ -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();