-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.min.js
More file actions
98 lines (82 loc) · 3.99 KB
/
errors.min.js
File metadata and controls
98 lines (82 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
document.addEventListener("DOMContentLoaded", () => {
const code = document.getElementById("my-data").dataset.code;
const domain = location.hostname;
const homeUrl = `https://${domain}`;
const supportUrl = `https://www.theindiangeographer.com/page/support?utm_source=chatgpt.com=${domain}&utm_content=error-report`;
// Timestamp, Timezone & Year
document.getElementById("timeStamp").textContent = new Date().toLocaleString();
document.getElementById("timeZone").textContent = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.getElementById("year").textContent = new Date().getFullYear();
document.getElementById("currentURL").textContent = window.location.href;
document.getElementById("footertxt").textContent = "Managed by TheIndianGeographer. All rights reserved. (1.1.2)";
// Buttons
document.getElementById("homeBtn").href = homeUrl;
const contactBtn = document.getElementById("contactBtn");
contactBtn.href = supportUrl;
contactBtn.target = "_blank";
contactBtn.rel = "noopener noreferrer";
// Favicon Loader
(function loadFavicon() {
const domainCandidate = domain.replace(/^https?:\/\//, "");
const tryUrl = d => (d.startsWith("http") ? d : (location.protocol + "//" + d)) + "/favicon.ico";
const googleSvc = "https://www.google.com/s2/favicons?sz=128&domain=" + encodeURIComponent(domainCandidate);
const img = new Image();
img.src = tryUrl(domainCandidate);
img.crossOrigin = "anonymous";
img.onload = () => applyFavicon(img.src);
img.onerror = () => applyFavicon(googleSvc);
function applyFavicon(src) {
document.querySelectorAll("link[rel~='icon']").forEach(n => n.remove());
const link = document.createElement("link");
link.rel = "icon";
link.href = src;
document.head.appendChild(link);
// also update <img id="favicon-img">
const faviconImg = document.getElementById("logo");
if (faviconImg) faviconImg.src = src;
}
})();
// Fetch IP
fetch("https://api.ipify.org?format=json")
.then(res => res.json())
.then(data => {
document.getElementById("ipAddr").textContent = data.ip;
})
.catch(() => {
document.getElementById("ipAddr").textContent = "unavailable";
});
const copyBtn = document.querySelector(".copy-btn");
const urlBox = document.querySelector("#currentURL");
copyBtn.addEventListener("click", () => {
const text = urlBox.textContent.trim();
if (!text) return; // nothing to copy
navigator.clipboard.writeText(text).then(() => {
// give some feedback
copyBtn.textContent = "✅";
setTimeout(() => {
copyBtn.textContent = "📋";
}, 1500);
}).catch(err => {
console.error("Copy failed:", err);
});
});
// ðŸâ€ÂÂ¥ Load error data from JSON
fetch("https://res.cloudinary.com/tignetwork/raw/upload/theindiangeographer/assets/errordata.json")
.then(res => res.json())
.then(data => {
const error = data[code] || data["404"]; // fallback if not found
document.getElementById("errCode").textContent = code;
document.getElementById("errTitle").textContent = error.title;
document.getElementById("errMsg").textContent = error.txtmsg;
document.getElementById("errTip").textContent = "Tip: " + error.tips;
// ðŸâ€ÂÂ¥ Update <title>
document.title = `${code} ${error.title}  TIGNetwork`;
})
.catch(err => {
console.error("Could not load error data:", err);
});
// create watermark div
const div = document.createElement("div");
div.classList.add("bg-watermark");
document.body.appendChild(div);
});