Skip to content

Commit

Permalink
Merge pull request #145 from openearth/feat/cookie-welcome-dialog
Browse files Browse the repository at this point in the history
Feat/cookie welcome dialog
  • Loading branch information
Tjalling-dejong authored Feb 4, 2025
2 parents 2d33c9f + 6f64b46 commit f84a72b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
:options="tourConfig"
name="introduction"
@click.native="nextStep"
:callbacks="tourCallbacks"
/>

<v-mapbox
Expand Down Expand Up @@ -139,6 +140,7 @@
import { tourConfig, generateTourSteps, tourStepCount } from '@/plugins/vue-tour'
import FeedbackDialog from './components/FeedbackDialog/FeedbackDialog.vue'
import AcknowledgmentsDialog from '~/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue'
import { getCookie, setCookie } from './lib/cookies'
const removeRegion = locale => locale.replace(/-.+/, '')
const localeIsAvailable = locale => availableLocales.includes(locale)
Expand Down Expand Up @@ -168,6 +170,7 @@
data: () => ({
tourConfig,
tourCallbacks: {},
generateTourSteps,
tourStepCount,
accessToken: process.env.VUE_APP_MAPBOX_TOKEN,
Expand Down Expand Up @@ -237,7 +240,11 @@
await this.getAppData({ route, locale: this.currentLocale } )
this.localeIsLoading = false
})
this.showTour()
this.tourCallbacks = { onSkip: this.skipTourCallback, }
const skipTourCookie = getCookie("skipTour")
if (!skipTourCookie) {
this.showTour()
}
},
methods: {
Expand Down Expand Up @@ -332,6 +339,9 @@
showTour () {
this.$tours.introduction.start()
},
skipTourCallback() {
setCookie("skipTour", true, 30)
},
nextStep () {
if (tourStepCount == 2 ) {
const firstFolder = this.displayLayers[0]
Expand Down
22 changes: 22 additions & 0 deletions src/lib/cookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

export function getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

3 comments on commit f84a72b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://nl2120.netlify.app as production
🚀 Deployed on https://67a1e6d8198bf118af9b626f--nl2120.netlify.app

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.