34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
(() => {
|
|
const status = document.getElementById("copy-status");
|
|
const buttons = document.querySelectorAll("[data-copy]");
|
|
|
|
buttons.forEach((btn) => {
|
|
btn.addEventListener("click", async () => {
|
|
const selector = btn.getAttribute("data-copy");
|
|
const el = document.querySelector(selector);
|
|
if (!el) return;
|
|
|
|
const value = (el.textContent || "").trim();
|
|
try {
|
|
await navigator.clipboard.writeText(value);
|
|
if (status) status.textContent = "Kopirano.";
|
|
} catch (_) {
|
|
if (status) status.textContent = "Ne mogu da kopiram automatski. Oznaci i copy rucno.";
|
|
}
|
|
});
|
|
});
|
|
|
|
const wifiQrIds = ["wifi-qr-sr", "wifi-qr-en"];
|
|
const portalQrIds = ["portal-qr-sr", "portal-qr-en"];
|
|
wifiQrIds.forEach((id) => {
|
|
const img = document.getElementById(id);
|
|
if (img) img.src = "/qr/wifi.svg";
|
|
});
|
|
portalQrIds.forEach((id) => {
|
|
const img = document.getElementById(id);
|
|
if (img) img.src = "/qr/portal.svg";
|
|
});
|
|
const bojanaQr = document.getElementById("bojana-qr");
|
|
if (bojanaQr) bojanaQr.src = "/qr/bojana.svg";
|
|
})();
|