From 14f1d4f4fbd32b15e85e138fb4f5462af058bd60 Mon Sep 17 00:00:00 2001 From: Kelvin-Macapagal Date: Tue, 16 Jun 2026 08:45:30 +0800 Subject: [PATCH 1/2] Add logic for Vietnam region for cookie compliance and add footer --- src/apisof.net/Pages/_Host.cshtml | 44 +++++++++++++++ src/apisof.net/Shared/MainLayout.razor | 44 ++++++++++++++- src/apisof.net/wwwroot/css/site.css | 77 ++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 1 deletion(-) diff --git a/src/apisof.net/Pages/_Host.cshtml b/src/apisof.net/Pages/_Host.cshtml index 14f066af..9a94d0ad 100644 --- a/src/apisof.net/Pages/_Host.cshtml +++ b/src/apisof.net/Pages/_Host.cshtml @@ -16,8 +16,11 @@ + + + @@ -37,6 +40,47 @@ - + diff --git a/src/apisof.net/wwwroot/js/site.js b/src/apisof.net/wwwroot/js/site.js new file mode 100644 index 00000000..00f728ec --- /dev/null +++ b/src/apisof.net/wwwroot/js/site.js @@ -0,0 +1,79 @@ +var siteConsent = null; + +function setCookieManagementVisibility(isVisible) { + var elements = document.querySelectorAll(".manageCookieChoice"); + for (var i = 0; i < elements.length; i++) { + elements[i].style.display = isVisible ? "list-item" : "none"; + } +} + +function initializeCookieConsent() { + if (typeof WcpConsent === "undefined" || typeof WcpConsent.init !== "function") { + return; + } + + WcpConsent.init("en-US", "cookie-banner", function (err, consentInstance) { + if (err || !consentInstance) { + return; + } + + siteConsent = consentInstance; + setCookieManagementVisibility(!!siteConsent.isConsentRequired); + + if (typeof siteConsent.onConsentChanged === "function") { + siteConsent.onConsentChanged(function () { + setCookieManagementVisibility(!!siteConsent.isConsentRequired); + }); + } + }); +} + +function manageConsent() { + if (siteConsent && typeof siteConsent.manageConsent === "function") { + siteConsent.manageConsent(); + } +} + +if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", initializeCookieConsent); +} else { + initializeCookieConsent(); +} + +function scrollIntoMainContent() { + var mainContent = document.getElementById("main-content"); + if (mainContent) { + mainContent.scrollIntoView({ behavior: "smooth" }); + mainContent.focus(); + } +} + +var observer = new MutationObserver(function () { + $('[data-toggle="popover"]').popover({ + placement: 'top', + trigger: 'hover', + boundary: 'body' + }); + $('[data-toggle="popover"]').on('click', function () { + $('[data-toggle="popover"]').popover('dispose'); + }); + $('.search-result-row.selected').each(function () { + this.scrollIntoView({ block: "nearest" }); + }); + $("#skipToMain").on('keydown', function (e) { + if (e.key === "Enter" || e.key === " ") { + scrollIntoMainContent(); + e.preventDefault(); + } + }); + $("#skipToMain").on('click', function (e) { + scrollIntoMainContent(); + e.preventDefault(); + }); +}); + +observer.observe(document, { + subtree: true, + childList: true, + attributes: true +});