From 261b5ca52a7e61c88a35402228c554a3ca111d6b Mon Sep 17 00:00:00 2001 From: 4Source <38220764+4Source@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:55:12 +0200 Subject: [PATCH 1/5] Added delay option for the review buttons --- src/gui/FlashcardReviewView.tsx | 20 +++++++++++++++ src/lang/locale/ar.ts | 3 +++ src/lang/locale/cz.ts | 3 +++ src/lang/locale/de.ts | 3 +++ src/lang/locale/en.ts | 3 +++ src/lang/locale/es.ts | 3 +++ src/lang/locale/it.ts | 3 +++ src/lang/locale/ja.ts | 3 +++ src/lang/locale/ko.ts | 3 +++ src/lang/locale/pl.ts | 3 +++ src/lang/locale/pt-br.ts | 3 +++ src/lang/locale/ru.ts | 3 +++ src/lang/locale/zh-cn.ts | 3 +++ src/lang/locale/zh-tw.ts | 3 +++ src/settings.ts | 45 ++++++++++++++++++++++++++------- 15 files changed, 95 insertions(+), 9 deletions(-) diff --git a/src/gui/FlashcardReviewView.tsx b/src/gui/FlashcardReviewView.tsx index 18dd25e3..16054442 100644 --- a/src/gui/FlashcardReviewView.tsx +++ b/src/gui/FlashcardReviewView.tsx @@ -16,6 +16,7 @@ import { Note } from "src/Note"; import { RenderMarkdownWrapper } from "src/util/RenderMarkdownWrapper"; import { CardScheduleInfo } from "src/CardSchedule"; import { FlashcardModalMode } from "./FlashcardModal"; +import { now } from "moment"; export class FlashcardReviewView { public app: App; @@ -44,6 +45,7 @@ export class FlashcardReviewView { public goodButton: HTMLButtonElement; public easyButton: HTMLButtonElement; public answerButton: HTMLButtonElement; + public lastPressed: number; private reviewSequencer: IFlashcardReviewSequencer; private settings: SRSettings; @@ -278,6 +280,15 @@ export class FlashcardReviewView { } private _showAnswer(): void { + const timeNow = now(); + if ( + this.lastPressed && + timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay + ) { + return; + } + this.lastPressed = timeNow; + this.mode = FlashcardModalMode.Back; this.resetButton.disabled = false; @@ -332,6 +343,15 @@ export class FlashcardReviewView { } private async _processReview(response: ReviewResponse): Promise { + const timeNow = now(); + if ( + this.lastPressed && + timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay + ) { + return; + } + this.lastPressed = timeNow; + await this.reviewSequencer.processReview(response); await this._handleSkipCard(); } diff --git a/src/lang/locale/ar.ts b/src/lang/locale/ar.ts index ca621a78..0fc5de97 100644 --- a/src/lang/locale/ar.ts +++ b/src/lang/locale/ar.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes. : أدخل مسا FLASHCARD_EASY_DESC: '"تخصيص التسمية للزر "سهل', FLASHCARD_GOOD_DESC: '"تخصيص التسمية للزر "جيد', FLASHCARD_HARD_DESC: '"تخصيص التسمية للزر "صعب', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "وُسوم البطاقات", FLASHCARD_TAGS_DESC: "#2أدخل الوُسوم مفصولة بمسافات أو أسطر جديدة ، أي بطاقات# رزمة3# رزمة", CONVERT_FOLDERS_TO_DECKS: "تحويل المجلدات إلى ملفات أصلية و ملفات الفرعية؟", diff --git a/src/lang/locale/cz.ts b/src/lang/locale/cz.ts index b7256cd7..2321dce0 100644 --- a/src/lang/locale/cz.ts +++ b/src/lang/locale/cz.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Tag pro kartičky", FLASHCARD_TAGS_DESC: "Zadete tagy oodělené mezerou nebo odřádkováním například. #kartičky #balíčke2 #balíček3.", diff --git a/src/lang/locale/de.ts b/src/lang/locale/de.ts index 8173697f..a1bf1477 100644 --- a/src/lang/locale/de.ts +++ b/src/lang/locale/de.ts @@ -86,6 +86,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_GOOD_DESC: 'Passe die Beschriftung für "Gut" Knopf an', FLASHCARD_EASY_DESC: 'Passe die Beschriftung für "Einfach" Knopf an', FLASHCARD_HARD_DESC: 'Passe die Beschriftung für "Schwer" Knopf an', + REVIEW_BUTTON_DELAY: "Druckknopfverzögerung", + REVIEW_BUTTON_DELAY_DESC: + "Fügt den Überprüfungsschaltflächen („Einfach“, „Gut“, „Schwer“, „Antwort anzeigen“) eine Verzögerung hinzu, bevor sie erneut gedrückt werden können.", FLASHCARD_TAGS: "Lernkarten Tags", FLASHCARD_TAGS_DESC: "Mehrere Tags mit Leerzeichen oder Zeilenumbrüchen getrennt angeben. Bsp. #karte #stapel2 #stapel3.", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 6ac84336..4b5fc071 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Flashcard tags", FLASHCARD_TAGS_DESC: "Enter tags separated by spaces or newlines i.e. #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index e80b93c7..13b588b9 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "Personalize la etiqueta para el botón: Fácil", FLASHCARD_GOOD_DESC: "Personalize la etiqueta para el botón: Bien", FLASHCARD_HARD_DESC: "Personalize la etiqueta para el botón: Difícil", + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Etiquetas de las Tarjetas de Memorización", FLASHCARD_TAGS_DESC: "Escriba las etiquetas separadas por espacios o saltos de línea, por ejemplo, #memorizar #mazo2 #mazo3", diff --git a/src/lang/locale/it.ts b/src/lang/locale/it.ts index 4c256692..764b4831 100644 --- a/src/lang/locale/it.ts +++ b/src/lang/locale/it.ts @@ -81,6 +81,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Personalizza il testo per il pulsante "Facile"', FLASHCARD_GOOD_DESC: 'Personalizza il testo per il pulsante "Buono"', FLASHCARD_HARD_DESC: 'Personalizza il testo per il pulsante "Difficile"', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Etichette delle schede", FLASHCARD_TAGS_DESC: "Inserire etichette separate da spazi o a capi, per esempio #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index 9ecac8fb..025e7e57 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -81,6 +81,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "フラッシュカードに使用するタグ", FLASHCARD_TAGS_DESC: 'タグをスペースまたは改行で区切って入力してください。例: "#flashcards #deck2 #deck3"', diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index a86fac08..6a7e79cf 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "플래시카드 태그", FLASHCARD_TAGS_DESC: "태그를 공백 또는 빈 줄로 구분해서 입력해주세요. 예) '#flashcards #deck2 #deck3'", diff --git a/src/lang/locale/pl.ts b/src/lang/locale/pl.ts index 735d2bd5..ceaa279e 100644 --- a/src/lang/locale/pl.ts +++ b/src/lang/locale/pl.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Dostosuj etykietę dla przycisku "Łatwe"', FLASHCARD_GOOD_DESC: 'Dostosuj etykietę dla przycisku "Średnio trudne"', FLASHCARD_HARD_DESC: 'Dostosuj etykietę dla przycisku "Trudne"', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Tagi fiszek", FLASHCARD_TAGS_DESC: "Wprowadź tagi oddzielone spacją lub nowymi liniami, np. #fiszki #talia2 #talia3.", diff --git a/src/lang/locale/pt-br.ts b/src/lang/locale/pt-br.ts index 354e9b46..c4b24fd2 100644 --- a/src/lang/locale/pt-br.ts +++ b/src/lang/locale/pt-br.ts @@ -82,6 +82,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize o rótulo para o botão de "Fácil"', FLASHCARD_GOOD_DESC: 'Customize o rótulo para o botão de "OK"', FLASHCARD_HARD_DESC: 'Customize o rótulo para o botão de "Difícil"', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Etiquetas dos Flashcards", FLASHCARD_TAGS_DESC: "Insira etiquetas separadas por espaços ou quebras de linha ex: #flashcards #baralho2 #baralho3.", diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index cdfeea1d..901c07c8 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -89,6 +89,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Настроить ярлык для кнопки "Легко"', FLASHCARD_GOOD_DESC: 'Настроить ярлык для кнопки "Нормально"', FLASHCARD_HARD_DESC: 'Настроить ярлык для кнопки "Сложно"', + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "Теги карточек", FLASHCARD_TAGS_DESC: "Укажите теги разделенные Enter-ом или пробелом, например: #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts index 78cbdf19..db910792 100644 --- a/src/lang/locale/zh-cn.ts +++ b/src/lang/locale/zh-cn.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "自定义“简单”按钮的标签", FLASHCARD_GOOD_DESC: "自定义“记得”按钮的标签", FLASHCARD_HARD_DESC: "自定义“较难”按钮的标签", + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "卡片标签", FLASHCARD_TAGS_DESC: "输入标签,用空格或新建行分隔,例如:#flashcards #deck2 #deck3.", CONVERT_FOLDERS_TO_DECKS: "是否将文件夹内容转换为卡片组和子卡片组?", diff --git a/src/lang/locale/zh-tw.ts b/src/lang/locale/zh-tw.ts index dbc4d506..adafb61b 100644 --- a/src/lang/locale/zh-tw.ts +++ b/src/lang/locale/zh-tw.ts @@ -80,6 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "自訂「簡單」按鈕的標籤", FLASHCARD_GOOD_DESC: "自訂「記得」按鈕的標籤", FLASHCARD_HARD_DESC: "自訂「較難」按鈕的標籤", + REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", FLASHCARD_TAGS: "卡片標籤", FLASHCARD_TAGS_DESC: "輸入標籤(用空白或換行字元分隔),例如:#flashcards #deck2 #deck3.", CONVERT_FOLDERS_TO_DECKS: "是否將資料夾內容轉換為牌組和子牌組?", diff --git a/src/settings.ts b/src/settings.ts index e500ec16..e4618be3 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -8,6 +8,7 @@ export interface SRSettings { flashcardEasyText: string; flashcardGoodText: string; flashcardHardText: string; + reviewButtonDelay: number; flashcardTags: string[]; convertFoldersToDecks: boolean; cardCommentOnSameLine: boolean; @@ -51,6 +52,7 @@ export const DEFAULT_SETTINGS: SRSettings = { flashcardEasyText: t("EASY"), flashcardGoodText: t("GOOD"), flashcardHardText: t("HARD"), + reviewButtonDelay: 0, flashcardTags: ["#flashcards"], convertFoldersToDecks: false, cardCommentOnSameLine: false, @@ -706,6 +708,31 @@ export class SRSettingTab extends PluginSettingTab { this.display(); }); }); + + new Setting(containerEl) + .setName(t("REVIEW_BUTTON_DELAY")) + .setDesc(t("REVIEW_BUTTON_DELAY_DESC")) + .addSlider((slider) => + slider + .setLimits(0, 5000, 100) + .setValue(this.plugin.data.settings.reviewButtonDelay) + .setDynamicTooltip() + .onChange(async (value) => { + this.plugin.data.settings.reviewButtonDelay = value; + await this.plugin.savePluginData(); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.reviewButtonDelay = + DEFAULT_SETTINGS.reviewButtonDelay; + await this.plugin.savePluginData(); + this.display(); + }); + }); } private async tabAlgorithm(containerEl: HTMLElement): Promise { @@ -929,15 +956,15 @@ export class SRSettingTab extends PluginSettingTab { }), ); /* - // Documentation link & GitHub links - containerEl.createEl("hr").insertAdjacentHTML("beforeend"); - - // Copyright notice - const copyright_paragraph = containerEl.createEl("p"); - copyright_paragraph.addClass("sr-small-font"); - copyright_paragraph.insertAdjacentHTML("beforeend", ` - Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. - `); */ + // Documentation link & GitHub links + containerEl.createEl("hr").insertAdjacentHTML("beforeend"); + + // Copyright notice + const copyright_paragraph = containerEl.createEl("p"); + copyright_paragraph.addClass("sr-small-font"); + copyright_paragraph.insertAdjacentHTML("beforeend", ` + Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. + `); */ } private last_position: { From b8cb61afc8701d9d44b7dac38047c670de6b0025 Mon Sep 17 00:00:00 2001 From: 4Source <38220764+4Source@users.noreply.github.com> Date: Sun, 18 Aug 2024 12:47:21 +0200 Subject: [PATCH 2/5] Fix localization --- src/lang/locale/ar.ts | 4 ++-- src/lang/locale/cz.ts | 4 ++-- src/lang/locale/de.ts | 2 +- src/lang/locale/en.ts | 4 ++-- src/lang/locale/es.ts | 4 ++-- src/lang/locale/it.ts | 4 ++-- src/lang/locale/ja.ts | 4 ++-- src/lang/locale/ko.ts | 4 ++-- src/lang/locale/pl.ts | 4 ++-- src/lang/locale/pt-br.ts | 4 ++-- src/lang/locale/ru.ts | 4 ++-- src/lang/locale/zh-cn.ts | 4 ++-- src/lang/locale/zh-tw.ts | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lang/locale/ar.ts b/src/lang/locale/ar.ts index 0fc5de97..6157efc4 100644 --- a/src/lang/locale/ar.ts +++ b/src/lang/locale/ar.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes. : أدخل مسا FLASHCARD_EASY_DESC: '"تخصيص التسمية للزر "سهل', FLASHCARD_GOOD_DESC: '"تخصيص التسمية للزر "جيد', FLASHCARD_HARD_DESC: '"تخصيص التسمية للزر "صعب', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "وُسوم البطاقات", FLASHCARD_TAGS_DESC: "#2أدخل الوُسوم مفصولة بمسافات أو أسطر جديدة ، أي بطاقات# رزمة3# رزمة", CONVERT_FOLDERS_TO_DECKS: "تحويل المجلدات إلى ملفات أصلية و ملفات الفرعية؟", diff --git a/src/lang/locale/cz.ts b/src/lang/locale/cz.ts index 2321dce0..b886e98a 100644 --- a/src/lang/locale/cz.ts +++ b/src/lang/locale/cz.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Tag pro kartičky", FLASHCARD_TAGS_DESC: "Zadete tagy oodělené mezerou nebo odřádkováním například. #kartičky #balíčke2 #balíček3.", diff --git a/src/lang/locale/de.ts b/src/lang/locale/de.ts index a1bf1477..ea9a5591 100644 --- a/src/lang/locale/de.ts +++ b/src/lang/locale/de.ts @@ -86,7 +86,7 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_GOOD_DESC: 'Passe die Beschriftung für "Gut" Knopf an', FLASHCARD_EASY_DESC: 'Passe die Beschriftung für "Einfach" Knopf an', FLASHCARD_HARD_DESC: 'Passe die Beschriftung für "Schwer" Knopf an', - REVIEW_BUTTON_DELAY: "Druckknopfverzögerung", + REVIEW_BUTTON_DELAY: "Druckknopfverzögerung (ms)", REVIEW_BUTTON_DELAY_DESC: "Fügt den Überprüfungsschaltflächen („Einfach“, „Gut“, „Schwer“, „Antwort anzeigen“) eine Verzögerung hinzu, bevor sie erneut gedrückt werden können.", FLASHCARD_TAGS: "Lernkarten Tags", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 4b5fc071..10d0d637 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Flashcard tags", FLASHCARD_TAGS_DESC: "Enter tags separated by spaces or newlines i.e. #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index 13b588b9..672f3e39 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "Personalize la etiqueta para el botón: Fácil", FLASHCARD_GOOD_DESC: "Personalize la etiqueta para el botón: Bien", FLASHCARD_HARD_DESC: "Personalize la etiqueta para el botón: Difícil", - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Etiquetas de las Tarjetas de Memorización", FLASHCARD_TAGS_DESC: "Escriba las etiquetas separadas por espacios o saltos de línea, por ejemplo, #memorizar #mazo2 #mazo3", diff --git a/src/lang/locale/it.ts b/src/lang/locale/it.ts index 764b4831..ef75a8ef 100644 --- a/src/lang/locale/it.ts +++ b/src/lang/locale/it.ts @@ -81,9 +81,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Personalizza il testo per il pulsante "Facile"', FLASHCARD_GOOD_DESC: 'Personalizza il testo per il pulsante "Buono"', FLASHCARD_HARD_DESC: 'Personalizza il testo per il pulsante "Difficile"', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Etichette delle schede", FLASHCARD_TAGS_DESC: "Inserire etichette separate da spazi o a capi, per esempio #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index 025e7e57..2f0c6645 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -81,9 +81,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "フラッシュカードに使用するタグ", FLASHCARD_TAGS_DESC: 'タグをスペースまたは改行で区切って入力してください。例: "#flashcards #deck2 #deck3"', diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index 6a7e79cf..07946003 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button', FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button', FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "플래시카드 태그", FLASHCARD_TAGS_DESC: "태그를 공백 또는 빈 줄로 구분해서 입력해주세요. 예) '#flashcards #deck2 #deck3'", diff --git a/src/lang/locale/pl.ts b/src/lang/locale/pl.ts index ceaa279e..e1b6f8d9 100644 --- a/src/lang/locale/pl.ts +++ b/src/lang/locale/pl.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Dostosuj etykietę dla przycisku "Łatwe"', FLASHCARD_GOOD_DESC: 'Dostosuj etykietę dla przycisku "Średnio trudne"', FLASHCARD_HARD_DESC: 'Dostosuj etykietę dla przycisku "Trudne"', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Tagi fiszek", FLASHCARD_TAGS_DESC: "Wprowadź tagi oddzielone spacją lub nowymi liniami, np. #fiszki #talia2 #talia3.", diff --git a/src/lang/locale/pt-br.ts b/src/lang/locale/pt-br.ts index c4b24fd2..9f22b148 100644 --- a/src/lang/locale/pt-br.ts +++ b/src/lang/locale/pt-br.ts @@ -82,9 +82,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Customize o rótulo para o botão de "Fácil"', FLASHCARD_GOOD_DESC: 'Customize o rótulo para o botão de "OK"', FLASHCARD_HARD_DESC: 'Customize o rótulo para o botão de "Difícil"', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Etiquetas dos Flashcards", FLASHCARD_TAGS_DESC: "Insira etiquetas separadas por espaços ou quebras de linha ex: #flashcards #baralho2 #baralho3.", diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index 901c07c8..7acc51c1 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -89,9 +89,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: 'Настроить ярлык для кнопки "Легко"', FLASHCARD_GOOD_DESC: 'Настроить ярлык для кнопки "Нормально"', FLASHCARD_HARD_DESC: 'Настроить ярлык для кнопки "Сложно"', - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Теги карточек", FLASHCARD_TAGS_DESC: "Укажите теги разделенные Enter-ом или пробелом, например: #flashcards #deck2 #deck3.", diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts index db910792..7ecf389b 100644 --- a/src/lang/locale/zh-cn.ts +++ b/src/lang/locale/zh-cn.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "自定义“简单”按钮的标签", FLASHCARD_GOOD_DESC: "自定义“记得”按钮的标签", FLASHCARD_HARD_DESC: "自定义“较难”按钮的标签", - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "卡片标签", FLASHCARD_TAGS_DESC: "输入标签,用空格或新建行分隔,例如:#flashcards #deck2 #deck3.", CONVERT_FOLDERS_TO_DECKS: "是否将文件夹内容转换为卡片组和子卡片组?", diff --git a/src/lang/locale/zh-tw.ts b/src/lang/locale/zh-tw.ts index adafb61b..4f001082 100644 --- a/src/lang/locale/zh-tw.ts +++ b/src/lang/locale/zh-tw.ts @@ -80,9 +80,9 @@ Note that this setting is common to both Flashcards and Notes.`, FLASHCARD_EASY_DESC: "自訂「簡單」按鈕的標籤", FLASHCARD_GOOD_DESC: "自訂「記得」按鈕的標籤", FLASHCARD_HARD_DESC: "自訂「較難」按鈕的標籤", - REVIEW_BUTTON_DELAY: "Button press delay", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", REVIEW_BUTTON_DELAY_DESC: - "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before there could be pressed again.", + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "卡片標籤", FLASHCARD_TAGS_DESC: "輸入標籤(用空白或換行字元分隔),例如:#flashcards #deck2 #deck3.", CONVERT_FOLDERS_TO_DECKS: "是否將資料夾內容轉換為牌組和子牌組?", From 18906cf8473054a447ac4a52cef03a986c673f9a Mon Sep 17 00:00:00 2001 From: 4Source <38220764+4Source@users.noreply.github.com> Date: Sun, 18 Aug 2024 12:48:34 +0200 Subject: [PATCH 3/5] Revert indentation --- src/settings.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index e4618be3..adcd090d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -956,15 +956,15 @@ export class SRSettingTab extends PluginSettingTab { }), ); /* - // Documentation link & GitHub links - containerEl.createEl("hr").insertAdjacentHTML("beforeend"); - - // Copyright notice - const copyright_paragraph = containerEl.createEl("p"); - copyright_paragraph.addClass("sr-small-font"); - copyright_paragraph.insertAdjacentHTML("beforeend", ` - Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. - `); */ + // Documentation link & GitHub links + containerEl.createEl("hr").insertAdjacentHTML("beforeend"); + + // Copyright notice + const copyright_paragraph = containerEl.createEl("p"); + copyright_paragraph.addClass("sr-small-font"); + copyright_paragraph.insertAdjacentHTML("beforeend", ` + Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. + `); */ } private last_position: { From 3b438aa47ce13e42cd289a6975b66ece7e82572d Mon Sep 17 00:00:00 2001 From: 4Source <38220764+4Source@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:18:15 +0200 Subject: [PATCH 4/5] Fix local fr, tr --- src/lang/locale/fr.ts | 3 +++ src/lang/locale/tr.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/lang/locale/fr.ts b/src/lang/locale/fr.ts index f6f32487..652f45b6 100644 --- a/src/lang/locale/fr.ts +++ b/src/lang/locale/fr.ts @@ -82,6 +82,9 @@ export default { FLASHCARD_EASY_DESC: "Changez le texte du bouton Facile", FLASHCARD_GOOD_DESC: "Changez le texte du bouton Correct", FLASHCARD_HARD_DESC: "Changez le texte du bouton Difficile", + REVIEW_BUTTON_DELAY: "Button press delay (ms)", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Tags des flashcards", FLASHCARD_TAGS_DESC: "Entrez les tags séparés par un espace ou une ligne i.e. #flashcards #paquet2 #paquet3.", diff --git a/src/lang/locale/tr.ts b/src/lang/locale/tr.ts index bd6e75c1..15bed2ea 100644 --- a/src/lang/locale/tr.ts +++ b/src/lang/locale/tr.ts @@ -81,6 +81,9 @@ export default { FLASHCARD_EASY_DESC: '"Kolay" butonunun metnini özelleştirin', FLASHCARD_GOOD_DESC: '"Orta" butonunun metnini özelleştirin', FLASHCARD_HARD_DESC: '"Zor" butonunun metnini özelleştirin', + REVIEW_BUTTON_DELAY: "Button press delay (ms)", + REVIEW_BUTTON_DELAY_DESC: + "Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.", FLASHCARD_TAGS: "Flash Kart Etiketleri", FLASHCARD_TAGS_DESC: "Etiketleri boşluklar veya yeni satırlarla ayırarak girin, örneğin: #flashcards #deck2 #deck3.", From ba41b3f2857659eb12c09b2c02ca1eed3f32ecdc Mon Sep 17 00:00:00 2001 From: 4Source <38220764+4Source@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:38:46 +0200 Subject: [PATCH 5/5] Fix missing reviewButtonDelay --- src/gui/flashcard-review-view.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gui/flashcard-review-view.tsx b/src/gui/flashcard-review-view.tsx index a4f97de6..de4796cb 100644 --- a/src/gui/flashcard-review-view.tsx +++ b/src/gui/flashcard-review-view.tsx @@ -1,3 +1,4 @@ +import { now } from "moment"; import { App, Notice, Platform, setIcon } from "obsidian"; import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info"; @@ -46,6 +47,7 @@ export class FlashcardReviewView { public goodButton: HTMLButtonElement; public easyButton: HTMLButtonElement; public answerButton: HTMLButtonElement; + public lastPressed: number; private chosenDeck: Deck | null; private reviewSequencer: IFlashcardReviewSequencer; @@ -303,6 +305,15 @@ export class FlashcardReviewView { } private _showAnswer(): void { + const timeNow = now(); + if ( + this.lastPressed && + timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay + ) { + return; + } + this.lastPressed = timeNow; + this.mode = FlashcardModalMode.Back; this.resetButton.disabled = false; @@ -357,6 +368,15 @@ export class FlashcardReviewView { } private async _processReview(response: ReviewResponse): Promise { + const timeNow = now(); + if ( + this.lastPressed && + timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay + ) { + return; + } + this.lastPressed = timeNow; + await this.reviewSequencer.processReview(response); await this._handleSkipCard(); }