addEventListener("load", function() {

let menu = document.getElementById('siteSettings');
let button = document.getElementById('siteSettingsButton');

menu.onclick = function() {
	menu.style.display = 'none';
};

function hbodyHref() {
    let hbody = document.getElementById('hbody');
    let links = hbody.querySelectorAll('a[href]');
    links.forEach(link => {
        let originalHref = link.getAttribute('href');
        link.removeAttribute('href');
        link.onclick = function(event) {
            event.preventDefault();
            hbodyHrefFunction(originalHref);
        };
    });
}

async function hbodyHrefFunction(href) {
    if (basis3.style.visibility === "visible" && window.contentIsEdit == true) {
        messageQueue.push("{{save_data_question}}");
        try {
            const userConfirmed = await messageCreateQuestion();
            if (userConfirmed) {
                if (window.newPageFunValue == "newPage") {
                    document.getElementById("saveHow").click();
                    messageFunction("{{save_new_page}}");
                    return;
                } else {
                    await saveChanges();
                }
            }
        } catch (error) {
            console.log("Ошибка: ", error);
        }
    }
    window.location.href = href;
}

hbodyHref();

});