aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/wwwroot/scripts/components/index.js
blob: 95b40840112fa4ba7e218535020ad0a4e0b06e93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function load_components() {
	document.body.appendChild(script_tag("/scripts/components/dialog.js", 1));
    document.body.appendChild(script_tag("/scripts/components/profile-modal.js", 1));
}

function get_script_version_hash(key, salt) {
    const currentHash = localStorage.getItem(key) ?? "";
    const hash = get_md5_hash(key + salt);
    if (currentHash === hash) return currentHash;
    localStorage.setItem(key, hash);
    return hash;
}

function script_tag(scriptSrc, version) {
    return create_element("script", {
        src: scriptSrc + "?v=" + get_script_version_hash(scriptSrc, version)
    })
}

document.addEventListener("DOMContentLoaded", load_components)