All files / Scripts/ui privacy.ts

0% Statements 0/15
0% Branches 0/6
0% Functions 0/4
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                         
import "../../Content/Office.css";
import "../../Content/privacy.css";
 
// Initialize privacy policy page
document.addEventListener("DOMContentLoaded", () => {
    const closeButton = document.getElementById("close-button");
 
    // Function to handle closing/going back
    const handleClose = () => {
        // Try to go back to the previous page first
        if (window.history.length > 1) {
            window.history.back();
        } else {
            // If no history, try to close the window/tab
            window.close();
 
            // If window.close() doesn't work (some browsers prevent it),
            // navigate back to the main add-in page
            setTimeout(() => {
                window.location.href = "uitoggle.html";
            }, 100);
        }
    };
 
    // Handle close button click
    if (closeButton) {
        closeButton.addEventListener("click", handleClose);
    }
 
    // Handle Escape key press
    document.addEventListener("keydown", (event) => {
        if (event.key === "Escape") {
            handleClose();
        }
    });
});