diff --git a/src/App.vue b/src/App.vue index be7098b..af016fb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -55,6 +55,7 @@ :options="tourConfig" name="introduction" @click.native="nextStep" + :callbacks="tourCallbacks" /> locale.replace(/-.+/, '') const localeIsAvailable = locale => availableLocales.includes(locale) @@ -168,6 +170,7 @@ data: () => ({ tourConfig, + tourCallbacks: {}, generateTourSteps, tourStepCount, accessToken: process.env.VUE_APP_MAPBOX_TOKEN, @@ -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: { @@ -332,6 +339,9 @@ showTour () { this.$tours.introduction.start() }, + skipTourCallback() { + setCookie("skipTour", true, 30) + }, nextStep () { if (tourStepCount == 2 ) { const firstFolder = this.displayLayers[0] diff --git a/src/lib/cookies.js b/src/lib/cookies.js new file mode 100644 index 0000000..df9e079 --- /dev/null +++ b/src/lib/cookies.js @@ -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 ""; + } +