aboutsummaryrefslogtreecommitdiff
path: root/asset-sources/fietsboek.ts
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2024-04-04 21:31:57 +0200
committerDaniel Schadt <kingdread@gmx.de>2024-04-04 21:31:57 +0200
commit6ee21f6c078891e4453415cbebd6b7d591185c5f (patch)
treef57490cda863521a352570cb5081435470a4564a /asset-sources/fietsboek.ts
parentf3902c84e07514f252f02a38a2795946f70ba896 (diff)
parent3968fad3a060c40a84eb07a0cf93e22e1161da61 (diff)
downloadfietsboek-6ee21f6c078891e4453415cbebd6b7d591185c5f.tar.gz
fietsboek-6ee21f6c078891e4453415cbebd6b7d591185c5f.tar.bz2
fietsboek-6ee21f6c078891e4453415cbebd6b7d591185c5f.zip
Merge branch 'language-chooser'
Diffstat (limited to 'asset-sources/fietsboek.ts')
-rw-r--r--asset-sources/fietsboek.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/asset-sources/fietsboek.ts b/asset-sources/fietsboek.ts
index b76b98b..1073ae4 100644
--- a/asset-sources/fietsboek.ts
+++ b/asset-sources/fietsboek.ts
@@ -52,6 +52,20 @@ function addHandler<K extends keyof GlobalEventHandlersEventMap>(
}
/**
+ * Handler for when a language is clicked. Sets the cookie to the correct locale.
+ *
+ * @param event - The triggering event.
+ */
+function languageClicked(event: MouseEvent) {
+ const language = (event.target as HTMLElement).getAttribute("data-langcode");
+ document.cookie = "fietsboek_locale=" + language;
+ window.location.reload();
+ event.preventDefault();
+}
+
+addHandler(".language-choice", "click", languageClicked);
+
+/**
* Handler for when a tag is clicked. Removes the tag from the tag list.
*
* @param event - The triggering event.