From 25aadab4a03347b7e3f8570ffe0e9517920586f9 Mon Sep 17 00:00:00 2001 From: a Date: Tue, 11 Aug 2020 16:34:33 +0200 Subject: [PATCH] Add flashcard --- src/background/background.ts | 7 ++- src/frontend/content_script/Translated.svelte | 47 ++++++++++++++++++- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/background/background.ts b/src/background/background.ts index 055ebbf..27eba35 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -1,4 +1,4 @@ -import { browser, Runtime, Tabs } from "webextension-polyfill-ts"; +import { browser, Runtime } from "webextension-polyfill-ts"; import { GTranslateScraper } from "./gtranslate_scraper"; import { Flashcards } from "./database"; import { Communicator, commandKinds } from "../communication"; @@ -10,9 +10,8 @@ const scraper = new GTranslateScraper(); com.translateCallback = (toTranslate) => scraper.translate(toTranslate); const db = new Flashcards(); -com.addFlashcardCallback = db.addFlashcard; -com.removeFlashcardCallback = db.removeFlashcard; -console.log(db); +com.addFlashcardCallback = (c) => db.addFlashcard(c); +com.removeFlashcardCallback = (c) => db.removeFlashcard(c); const getTabID = async (s: Runtime.MessageSender): Promise => { if (s.tab?.id) return s.tab.id; diff --git a/src/frontend/content_script/Translated.svelte b/src/frontend/content_script/Translated.svelte index 65a3249..4178498 100644 --- a/src/frontend/content_script/Translated.svelte +++ b/src/frontend/content_script/Translated.svelte @@ -1,5 +1,18 @@
{trans.result} - + + {#if !card} + + {:else} + + {/if} +