From: Marc Foley Date: Wed, 2 Oct 2024 11:03:54 +0000 (+0100) Subject: tags.html: Update url when changing commit and category X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8240%2Fhead;p=thirdparty%2Fgoogle%2Ffonts.git tags.html: Update url when changing commit and category --- 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)); },