From 38b55c336eb186014e73341721c073604bb17f8a Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 5 Oct 2022 12:28:17 +0200 Subject: [PATCH] :sparkles: Added Quiz-ID to dashboard with an option to copy it to the clipboard --- frontend/src/lib/dashboard/main_slider.svelte | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/dashboard/main_slider.svelte b/frontend/src/lib/dashboard/main_slider.svelte index b7ad921..500405d 100644 --- a/frontend/src/lib/dashboard/main_slider.svelte +++ b/frontend/src/lib/dashboard/main_slider.svelte @@ -9,11 +9,13 @@ import 'swiper/css/pagination'; import 'swiper/css/navigation'; import { Pagination, EffectCoverflow, Keyboard, Mousewheel, Navigation } from 'swiper'; + import { fly } from 'svelte/transition'; import { QuizQuestionType } from '$lib/quiz_types.js'; import { getLocalization } from '$lib/i18n'; import StartGamePopup from './start_game.svelte'; import { onMount } from 'svelte'; + let copy_toast_open = false; let start_game = null; const { t } = getLocalization(); export let quizzes; @@ -32,11 +34,54 @@ start_game = null; } }; + + const copy_id = (quiz_id: string) => { + navigator.clipboard.writeText(quiz_id); + copy_toast_open = true; + setTimeout(() => { + copy_toast_open = false; + }, 2000); + }; onMount(() => { document.body.addEventListener('keydown', close_start_game_if_esc_is_pressed); }); +{#if copy_toast_open} +
+ +
+{/if} +
- {#each quizzes as quiz} + {#each quizzes as quiz, i}
{quiz.title} @@ -187,6 +232,14 @@ /> +

{ + copy_id(quiz.id); + }} + > + {quiz.id} +