From f62d5217fc6078bad14f969b03d5d049f3654bdd Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Wed, 2 Oct 2024 12:03:54 +0100 Subject: [PATCH] tags.html: Update url when changing commit and category --- .ci/tags.html | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.ci/tags.html b/.ci/tags.html index 04f1228af4..b09000a4a9 100644 --- a/.ci/tags.html +++ b/.ci/tags.html @@ -110,10 +110,30 @@ history: [], }; }, + watch: { + commit(newCommit) { + this.updateURL(); + }, + CurrentCategory(newCategory) { + this.updateURL(); + } + }, created() { this.loadCSV(); this.loadFamilyPangrams(); }, + mounted() { + const urlParams = new URLSearchParams(window.location.search); + const category = urlParams.get('category'); + if (category) { + this.CurrentCategory = category; + } + const commit = urlParams.get('commit'); + if (commit) { + this.commit = commit; + this.loadCSV(); + } + }, computed: { sortedFamilies() { let ll = this.Families; @@ -129,6 +149,20 @@ } }, methods: { + updateURL() { + const url = new URL(window.location); + if (this.commit) { + url.searchParams.set('commit', this.commit); + } else { + url.searchParams.delete('commit'); + } + if (this.CurrentCategory) { + url.searchParams.set('category', this.CurrentCategory); + } else { + url.searchParams.delete('category'); + } + history.pushState(null, '', url); + }, familyPangram(family) { return this.Pangrams.get(this.FamilyScripts.get(family.Family)); }, -- 2.47.2