From 175c3d0b8db964f047c9ea1237c94729b80a82ec Mon Sep 17 00:00:00 2001 From: kernoeb Date: Mon, 2 Sep 2024 22:37:01 +0200 Subject: [PATCH] snackbar --- components/Snackbar.vue | 58 ++++++++++++++++++++++++++++++++++------- pages/index.vue | 4 +-- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/components/Snackbar.vue b/components/Snackbar.vue index bfa31ca..a27c679 100644 --- a/components/Snackbar.vue +++ b/components/Snackbar.vue @@ -3,20 +3,54 @@ export default { name: 'Snackbar', data () { return { - snackbar: false + snackbar: false, + storageKey: 'show-snackbar-2024' } }, mounted () { - if (localStorage.getItem('show-snackbar') == null || localStorage.getItem('show-snackbar') === 'true') { + if (window.location.hostname !== 'planningsup.app' && window.location.hostname !== 'localhost') { + console.log('Snackbar disabled because we are not on planningsup.app', window.location.hostname) + return + } + + // Remove old show-snackbar from localStorage to show the snackbar again + try { + localStorage.removeItem('show-snackbar') + } catch (err) {} + + // Remove keys starting with /show-snackbar- + try { + for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i) + if (key.startsWith('show-snackbar-') && key !== this.storageKey) { + console.log('Remove old show-snackbar key', key) + localStorage.removeItem(key) + } + } + } catch (err) {} + + if (localStorage.getItem(this.storageKey) == null || localStorage.getItem(this.storageKey) === 'true') { this.snackbar = true } }, methods: { + open () { + this.snackbar = false + localStorage.setItem(this.storageKey, 'false') + + window.open('https://paypal.me/kernoeb', '_blank') + + try { + console.log('Track donation-click') + this.$plausible.trackEvent('donation-click') + } catch (err) {} + }, close () { this.snackbar = false - localStorage.setItem('show-snackbar', 'false') + localStorage.setItem(this.storageKey, 'false') try { + console.log('Track donation-close') this.$plausible.trackEvent('donation-close') } catch (err) {} } @@ -28,24 +62,28 @@ export default { - Hello tout le monde !

Si vous souhaitez faire un petit don pour financer le serveur, le nom de domaine et, ou les futures fonctionnalités, c'est par ici : -

+
+ Hello ! +
+
+ PlanningSup est un projet open-source, gratuit et sans publicité. Si vous souhaitez soutenir le projet, vous pouvez faire un don via PayPal :) +
paypal.me/kernoeb -

Merci ! 🤍 +
diff --git a/pages/index.vue b/pages/index.vue index 7f7b451..6a5db02 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -3,9 +3,9 @@ v-if="mounted" :class="{hideWeekends}" > - +