mirror of
https://github.com/xodivorce/isdowndetectordown.git
synced 2025-12-20 01:09:34 +05:30
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
(function () {
|
|
const url = new URL(window.location.href);
|
|
const geo = url.searchParams.get('geo');
|
|
|
|
if (geo) {
|
|
return;
|
|
}
|
|
|
|
if (!navigator.geolocation) {
|
|
url.searchParams.set('geo', 'unsupported');
|
|
window.history.replaceState({}, '', url.toString());
|
|
return;
|
|
}
|
|
|
|
navigator.geolocation.getCurrentPosition(
|
|
function (pos) {
|
|
url.searchParams.set('geo', '1');
|
|
url.searchParams.set('lat', pos.coords.latitude.toFixed(6));
|
|
url.searchParams.set('lon', pos.coords.longitude.toFixed(6));
|
|
window.location.href = url.toString();
|
|
},
|
|
function () {
|
|
url.searchParams.set('geo', 'denied');
|
|
window.location.href = url.toString();
|
|
},
|
|
{
|
|
enableHighAccuracy: false,
|
|
timeout: 8000,
|
|
maximumAge: 600000
|
|
}
|
|
);
|
|
})();
|
|
|
|
(function () {
|
|
const el = document.getElementById('copyright-text');
|
|
if (!el) return;
|
|
|
|
const config = window.APP_CONFIG || {};
|
|
const startYear = Number(config.startYear) || new Date().getFullYear();
|
|
const currentYear = new Date().getFullYear();
|
|
|
|
let displayText;
|
|
if (currentYear === startYear) {
|
|
displayText = `© ${startYear}. All rights reserved.`;
|
|
} else {
|
|
const shortYear = String(currentYear).slice(2);
|
|
displayText = `© ${startYear} - ${shortYear}. All rights reserved.`;
|
|
}
|
|
|
|
el.textContent = displayText;
|
|
})(); |