diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-22 14:44:26 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-22 14:44:26 +0100 |
| commit | 58ef5833b3f77f321c587dd86448c888029016ce (patch) | |
| tree | fe5e6f47781573cc1fb5938f9b8cd8b51022946a /code/api/wwwroot/scripts/components/index.js | |
| parent | 82ade3c31fb17b662feec59e9e654ceb66edbb7a (diff) | |
| download | storage-58ef5833b3f77f321c587dd86448c888029016ce.tar.xz storage-58ef5833b3f77f321c587dd86448c888029016ce.zip | |
feat: Many things
- Working Login/Logout
- Groundwork for web components
- Loading web-components with version tag
- Load temporal-polyfill globally
Diffstat (limited to 'code/api/wwwroot/scripts/components/index.js')
| -rw-r--r-- | code/api/wwwroot/scripts/components/index.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/code/api/wwwroot/scripts/components/index.js b/code/api/wwwroot/scripts/components/index.js new file mode 100644 index 0000000..ffae0e3 --- /dev/null +++ b/code/api/wwwroot/scripts/components/index.js @@ -0,0 +1,19 @@ +function load_components() { + 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)
\ No newline at end of file |
