Skip to content

Commit

Permalink
refactor: update settings
Browse files Browse the repository at this point in the history
  • Loading branch information
st3v3nmw committed Sep 25, 2024
1 parent a38838d commit 8ef4974
Show file tree
Hide file tree
Showing 22 changed files with 506 additions and 463 deletions.
4 changes: 4 additions & 0 deletions src/algorithms/base/isrs-algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { OsrNoteGraph } from "src/algorithms/osr/osr-note-graph";
import { DueDateHistogram } from "src/due-date-histogram";
import { Note } from "src/note";

export enum Algorithm {
SM_2_OSR = "SM-2-OSR",
}

export interface ISrsAlgorithm {
noteOnLoadedNote(path: string, note: Note, noteEase: number): void;
noteCalcNewSchedule(
Expand Down
4 changes: 4 additions & 0 deletions src/data-stores/base/data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info"
import { RepItemStorageInfo } from "src/data-stores/base/rep-item-storage-info";
import { Question } from "src/question";

export enum DataStoreName {
NOTES = "NOTES",
}

export interface IDataStore {
questionCreateSchedule(
originalQuestionText: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Question } from "src/question";
import { SRSettings } from "src/settings";
import { DateUtil, formatDate_YYYY_MM_DD, globalDateProvider } from "src/utils/dates";

export class StoreInNote implements IDataStore {
export class StoreInNotes implements IDataStore {
private settings: SRSettings;
app: App;
easeByPath: NoteEaseList;
Expand Down
31 changes: 22 additions & 9 deletions src/gui/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
*
* Contact the author (Jarkko Linnanvirta): https://github.com/Taitava/
*/

import { setIcon } from "obsidian";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import h from "vhtml";

export interface Tab {
title: string;
Expand Down Expand Up @@ -63,7 +64,9 @@ export function createTabs(
const tab_buttons: TabButtons = {};
const tab_structure: TabStructure = {
header: tab_header,
active_tab_id: Object.keys(tabs)[0] as string, // Indicate that the first tab is active. This does not affect what tab is active in practise, it just reports the active tab.
// Indicate that the first tab is active.
// This does not affect what tab is active in practise, it just reports the active tab.
active_tab_id: Object.keys(tabs)[0] as string,
buttons: tab_buttons,
contentContainers: tab_content_containers,
contentGeneratorPromises: {},
Expand All @@ -80,7 +83,9 @@ export function createTabs(
},
});
button.onclick = function (event: MouseEvent) {
const tab_button = this as HTMLElement; // Use 'this' instead of event.target because this way we'll always get a button element, not an element inside the button (i.e. an icon).
// Use 'this' instead of event.target because this way we'll always get a button element,
// not an element inside the button (i.e. an icon).
const tab_button = this as HTMLElement;

// Hide all tab contents and get the max dimensions
let max_width = 0;
Expand All @@ -95,15 +100,19 @@ export function createTabs(
"Container element is missing. Did not get a parent from tab header.",
);
}
const tab_contents = container_element.findAll("div.sr-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time.

// Do not get all tab contents that exist,
// because there might be multiple tab systems open at the same time.
const tab_contents = container_element.findAll("div.sr-tab-content");
const is_main_settings_modal = container_element.hasClass("vertical-tab-content");
for (const index in tab_contents) {
const tab_content = tab_contents[index];

// Get the maximum tab dimensions so that all tabs can have the same dimensions.
// But don't do it if this is the main settings modal
if (!is_main_settings_modal) {
tab_content.addClass("sr-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions.
// Need to make the tab visible temporarily in order to get the dimensions.
tab_content.addClass("sr-tab-active");
if (tab_content.offsetHeight > max_height) {
max_height = tab_content.offsetHeight;
}
Expand All @@ -117,7 +126,9 @@ export function createTabs(
}

// Remove active status from all buttons
const adjacent_tab_buttons = tab_header.findAll(".sr-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time.
// Do not get all tab buttons that exist,
// because there might be multiple tab systems open at the same time.
const adjacent_tab_buttons = tab_header.findAll(".sr-tab-header-button");
for (const index in adjacent_tab_buttons) {
const tab_button = adjacent_tab_buttons[index];
tab_button.removeClass("sr-tab-active");
Expand All @@ -142,10 +153,12 @@ export function createTabs(
tab_content.addClass("sr-tab-active");

// Mark the clicked tab as active in TabStructure (just to report which tab is currently active)
tab_structure.active_tab_id = activate_tab_id.replace(/^sr-tab-/, ""); // Remove "sr-tab" prefix.
// Remove "sr-tab" prefix.
tab_structure.active_tab_id = activate_tab_id.replace(/^sr-tab-/, "");

// Focus an element (if a focusable element is present)
tab_content.find(".sr-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing.
// ? = If not found, do nothing.
tab_content.find(".sr-focus-element-on-tab-opening")?.focus();

// Apply the max dimensions to this tab
// But don't do it if this is the main settings modal
Expand All @@ -159,7 +172,7 @@ export function createTabs(
};
if (tab.icon) setIcon(button, tab.icon);

button.insertAdjacentText("beforeend", " " + tab.title);
button.insertAdjacentHTML("beforeend", <span style="padding-left: 5px;">{tab.title}</span>);
tab_buttons[tab_id] = button;

// Create content container
Expand Down
18 changes: 8 additions & 10 deletions src/lang/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export default {
GITHUB_ISSUES:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report.',
GITHUB_SOURCE_CODE:
'Project source code available on <a href="${github_project_url}">GitHub</a>',
'The project\'s source code is available on <a href="${github_project_url}">GitHub</a>.',
CODE_CONTRIBUTION_INFO:
'Information on <a href="${code_contribution_url}">code contributions</a>',
'<a href="${code_contribution_url}">Here\'s</a> how to contribute code to the plugin.',
TRANSLATION_CONTRIBUTION_INFO:
'Information on <a href="${translation_contribution_url}">translating the plugin</a> to your language',
'<a href="${translation_contribution_url}">Here\'s</a> how to translate the plugin to another language.',
PROJECT_CONTRIBUTIONS:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report',
FOLDERS_TO_IGNORE: "مجلدات لتجاهلها",
Expand All @@ -81,7 +81,7 @@ export default {
FLASHCARD_EASY_DESC: '"تخصيص التسمية للزر "سهل',
FLASHCARD_GOOD_DESC: '"تخصيص التسمية للزر "جيد',
FLASHCARD_HARD_DESC: '"تخصيص التسمية للزر "صعب',
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
REVIEW_BUTTON_DELAY: "Button Press Delay (ms)",
REVIEW_BUTTON_DELAY_DESC: "Add a delay to the review buttons before they can be pressed again.",
FLASHCARD_TAGS: "وُسوم البطاقات",
FLASHCARD_TAGS_DESC: "#2أدخل الوُسوم مفصولة بمسافات أو أسطر جديدة ، أي بطاقات# رزمة3# رزمة",
Expand Down Expand Up @@ -137,7 +137,7 @@ export default {
MAX_N_DAYS_REVIEW_QUEUE: "الحد الأقصى لعدد الأيام التي يجب عرضها على اللوحة اليمنى",
MIN_ONE_DAY: "يجب أن يكون عدد الأيام 1 على الأقل",
VALID_NUMBER_WARNING: "يرجى تقديم رقم صالح",
UI_PREFERENCES: "تفضيلات واجهة المستخدم",
UI: "User Interface",
SHOW_STATUS_BAR: "Show status bar",
SHOW_STATUS_BAR_DESC:
"Turn this off to hide the flashcard's review status in Obsidian's status bar",
Expand All @@ -148,8 +148,7 @@ export default {
INITIALLY_EXPAND_SUBDECKS_IN_TREE_DESC:
" عطل هذا الخيار لطي الرُزم المتداخلة في نفس البطاقة , مفيد إذا كان لديك بطاقات تنتمي إلى العديد من الرُزم في نفس الملف",
ALGORITHM: "خوارزمية",
CHECK_ALGORITHM_WIKI:
'<a href="${algo_url}">algorithm implementation</a> :لمزيد من المعلومات تحقق من',
CHECK_ALGORITHM_WIKI: '<a href="${algo_url}">algorithm details</a> :لمزيد من المعلومات تحقق من',
BASE_EASE: "سهولة القاعدة",
BASE_EASE_DESC: "الحد الأدنى = 130 ، ويفضل حوالي 250.",
BASE_EASE_MIN_WARNING: "يجب أن تكون سهولة القاعدة 130 على الأقل.",
Expand All @@ -165,9 +164,8 @@ export default {
MAX_LINK_CONTRIB: "أقصى مساهمة ارتباط",
MAX_LINK_CONTRIB_DESC: "أقصى مساهمة للسهولة المرجحة للملاحظات المرتبطة بالسهولة الأولية.",
LOGGING: "تسجيل",
DISPLAY_DEBUG_INFO: "عرض معلومات التصحيح على وحدة تحكم المطور",
DISPLAY_PARSER_DEBUG_INFO:
"Display debugging information for the parser on the developer console",
DISPLAY_SCHEDULING_DEBUG_INFO: "عرض معلومات التصحيح على وحدة تحكم المطور",
DISPLAY_PARSER_DEBUG_INFO: "Show the parser's debugging information on the developer console",

// sidebar.ts
NOTES_REVIEW_QUEUE: "ملاحظات قائمة المراجعة",
Expand Down
13 changes: 6 additions & 7 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export default {
GITHUB_ISSUES:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report.',
GITHUB_SOURCE_CODE:
'Project source code available on <a href="${github_project_url}">GitHub</a>',
'The project\'s source code is available on <a href="${github_project_url}">GitHub</a>.',
CODE_CONTRIBUTION_INFO:
'Information on <a href="${code_contribution_url}">code contributions</a>',
'<a href="${code_contribution_url}">Here\'s</a> how to contribute code to the plugin.',
TRANSLATION_CONTRIBUTION_INFO:
'Information on <a href="${translation_contribution_url}">translating the plugin</a> to your language',
'<a href="${translation_contribution_url}">Here\'s</a> how to translate the plugin to another language.',
PROJECT_CONTRIBUTIONS:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report',
FOLDERS_TO_IGNORE: "Ignorované složky",
Expand All @@ -81,7 +81,7 @@ export default {
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 (ms)",
REVIEW_BUTTON_DELAY: "Button Press Delay (ms)",
REVIEW_BUTTON_DELAY_DESC: "Add a delay to the review buttons before they can be pressed again.",
FLASHCARD_TAGS: "Tag pro kartičky",
FLASHCARD_TAGS_DESC:
Expand Down Expand Up @@ -169,9 +169,8 @@ export default {
MAX_LINK_CONTRIB_DESC:
"Maximální příspěvek vážené složitosti prolinkovaných poznámek použitý pro určení počáteční složitosti.",
LOGGING: "Zaznamenávám",
DISPLAY_DEBUG_INFO: "Zobrazit informace pro ladění na vývojářské konzoli",
DISPLAY_PARSER_DEBUG_INFO:
"Display debugging information for the parser on the developer console",
DISPLAY_SCHEDULING_DEBUG_INFO: "Zobrazit informace pro ladění na vývojářské konzoli",
DISPLAY_PARSER_DEBUG_INFO: "Show the parser's debugging information on the developer console",

// sidebar.ts
NOTES_REVIEW_QUEUE: "Fronta poznámek k revizi",
Expand Down
10 changes: 5 additions & 5 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export default {
GITHUB_ISSUES:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report.',
GITHUB_SOURCE_CODE:
'Project source code available on <a href="${github_project_url}">GitHub</a>',
'The project\'s source code is available on <a href="${github_project_url}">GitHub</a>.',
CODE_CONTRIBUTION_INFO:
'Information on <a href="${code_contribution_url}">code contributions</a>',
'<a href="${code_contribution_url}">Here\'s</a> how to contribute code to the plugin.',
TRANSLATION_CONTRIBUTION_INFO:
'Information on <a href="${translation_contribution_url}">translating the plugin</a> to your language',
'<a href="${translation_contribution_url}">Here\'s</a> how to translate the plugin to another language.',
PROJECT_CONTRIBUTIONS:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report',
FOLDERS_TO_IGNORE: "Ausgeschlossene Ordner",
Expand Down Expand Up @@ -157,7 +157,7 @@ export default {
"Maximale Anzahl anstehender Notizen, die im rechten Fensterbereich angezeigt werden",
MIN_ONE_DAY: "Anzahl der Tage muss mindestens 1 sein.",
VALID_NUMBER_WARNING: "Bitte eine gültige Zahl eingeben.",
UI_PREFERENCES: "Einstellungen der Benutzeroberfläche",
UI: "User Interface",
SHOW_STATUS_BAR: "Show status bar",
SHOW_STATUS_BAR_DESC:
"Turn this off to hide the flashcard's review status in Obsidian's status bar",
Expand Down Expand Up @@ -188,7 +188,7 @@ export default {
MAX_LINK_CONTRIB_DESC:
"Maximaler Einfluss der Einfachheiten verlinkter Notizen zur gewichteten initialen Einfachheit einer neuen Lernkarte.",
LOGGING: "Protokollierung",
DISPLAY_DEBUG_INFO: "Informationen zum Debugging in der Entwicklerkonsole anzeigen",
DISPLAY_SCHEDULING_DEBUG_INFO: "Informationen zum Debugging in der Entwicklerkonsole anzeigen",
DISPLAY_PARSER_DEBUG_INFO:
"Informationen zum parser Debugging in der Entwicklerkonsole anzeigen",

Expand Down
26 changes: 16 additions & 10 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
GROUP_FLASHCARD_REVIEW: "Flashcard Review",
GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators",
GROUP_DATA_STORAGE: "Storage of Scheduling Data",
GROUP_DATA_STORAGE_DESC: "Choose where to store the scheduling data",
GROUP_FLASHCARDS_NOTES: "Flashcards & Notes",
GROUP_CONTRIBUTING: "Contributing",
CHECK_WIKI: 'For more information, check the <a href="${wiki_url}">wiki</a>.',
Expand All @@ -63,11 +64,11 @@ export default {
GITHUB_ISSUES:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report.',
GITHUB_SOURCE_CODE:
'Project source code available on <a href="${github_project_url}">GitHub</a>',
'The project\'s source code is available on <a href="${github_project_url}">GitHub</a>.',
CODE_CONTRIBUTION_INFO:
'Information on <a href="${code_contribution_url}">code contributions</a>',
'<a href="${code_contribution_url}">Here\'s</a> how to contribute code to the plugin.',
TRANSLATION_CONTRIBUTION_INFO:
'Information on <a href="${translation_contribution_url}">translating the plugin</a> to your language',
'<a href="${translation_contribution_url}">Here\'s</a> how to translate the plugin to another language.',
PROJECT_CONTRIBUTIONS:
'Raise an issue <a href="${issues_url}">here</a> if you have a feature request or a bug report',
FOLDERS_TO_IGNORE: "Folders to ignore",
Expand All @@ -81,7 +82,7 @@ export default {
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 (ms)",
REVIEW_BUTTON_DELAY: "Button Press Delay (ms)",
REVIEW_BUTTON_DELAY_DESC: "Add a delay to the review buttons before they can be pressed again.",
FLASHCARD_TAGS: "Flashcard tags",
FLASHCARD_TAGS_DESC:
Expand Down Expand Up @@ -133,10 +134,10 @@ export default {
OPEN_RANDOM_NOTE: "Open a random note for review",
OPEN_RANDOM_NOTE_DESC: "When you turn this off, notes are ordered by importance (PageRank).",
AUTO_NEXT_NOTE: "Open next note automatically after a review",
MAX_N_DAYS_REVIEW_QUEUE: "Maximum number of days to display on right panel",
MAX_N_DAYS_REVIEW_QUEUE: "Maximum number of days to display on note review panel",
MIN_ONE_DAY: "The number of days must be at least 1.",
VALID_NUMBER_WARNING: "Please provide a valid number.",
UI_PREFERENCES: "UI Preferences",
UI: "User Interface",
SHOW_STATUS_BAR: "Show status bar",
SHOW_STATUS_BAR_DESC:
"Turn this off to hide the flashcard's review status in Obsidian's status bar",
Expand All @@ -151,7 +152,8 @@ export default {
"Turn this off to collapse nested decks in the same card. Useful if you have cards which belong to many decks in the same file.",
ALGORITHM: "Algorithm",
CHECK_ALGORITHM_WIKI:
'For more information, check the <a href="${algo_url}">algorithm implementation</a>.',
'For more information, check the <a href="${algo_url}">algorithm details</a>.',
SM2_OSR_VARIANT: "OSR's variant of SM-2",
BASE_EASE: "Base ease",
BASE_EASE_DESC: "minimum = 130, preferrably approximately 250.",
BASE_EASE_MIN_WARNING: "The base ease must be at least 130.",
Expand All @@ -168,9 +170,13 @@ export default {
MAX_LINK_CONTRIB_DESC:
"Maximum contribution of the weighted ease of linked notes to the initial ease.",
LOGGING: "Logging",
DISPLAY_DEBUG_INFO: "Display debugging information on the developer console",
DISPLAY_PARSER_DEBUG_INFO:
"Display debugging information for the parser on the developer console",
DISPLAY_SCHEDULING_DEBUG_INFO:
"Show the scheduler's debugging information on the developer console",
DISPLAY_PARSER_DEBUG_INFO: "Show the parser's debugging information on the developer console",
SCHEDULING: "Scheduling",
EXPERIMENTAL: "Experimental",
HELP: "Help",
STORE_IN_NOTES: "In the notes",

// sidebar.ts
NOTES_REVIEW_QUEUE: "Notes Review Queue",
Expand Down
Loading

0 comments on commit 8ef4974

Please sign in to comment.