Skip to content

Commit

Permalink
Feat/Add two feature toggles (#78)
Browse files Browse the repository at this point in the history
fsrs v5 setting support  `enable_short_term` and `enable_fuzz`.
  • Loading branch information
ishiko732 authored Sep 2, 2024
1 parent abcf81b commit daf7a12
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"moment": "^2.30.1",
"obsidian": "^1.6.6",
"prettier": "^3.3.3",
"ts-fsrs": "^4.1.2",
"ts-fsrs": "^4.1.3",
"ts-jest": "^29.2.5",
"tslib": "2.6.1",
"typescript": "5.1.6",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions src/algorithms/fsrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface FsrsSettings {
maximum_interval: number;
w: number[];
enable_fuzz: boolean;
enable_short_term: boolean;
}

const FsrsOptions: string[] = ["Again", "Hard", "Good", "Easy"]; // Manual =0
Expand Down Expand Up @@ -439,6 +440,58 @@ export class FsrsAlgorithm extends SrsAlgorithm {
<a href= "https://open-spaced-repetition.github.io/anki_fsrs_visualizer"> FSRS w参数可视化 </a> \
以对各参数进行设置.';

new Setting(containerEl)
.setName(t("FUZZING"))
.setDesc(t("FUZZING_DESC"))
.addToggle((toggle) =>
toggle.setValue(this.settings.enable_fuzz).onChange(async (value) => {
applySettingsUpdate(async () => {
this.settings.enable_fuzz = value ?? this.defaultSettings().enable_fuzz;
update(this.settings, true);
this.updateFsrsParams();
});
}),
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
applySettingsUpdate(async () => {
this.settings.enable_fuzz = this.defaultSettings().enable_fuzz;
update(this.settings, true);
this.updateFsrsParams();
});
});
});

new Setting(containerEl)
.setName(t("SWITCH_SHORT_TERM"))
.setDesc(t("SWITCH_SHORT_TERM_DESC"))
.addToggle((toggle) =>
toggle.setValue(this.settings.enable_short_term).onChange(async (value) => {
applySettingsUpdate(async () => {
this.settings.enable_short_term =
value ?? this.defaultSettings().enable_short_term;
update(this.settings, true);
this.updateFsrsParams();
});
}),
)
.addExtraButton((button) => {
button
.setIcon("reset")
.setTooltip(t("RESET_DEFAULT"))
.onClick(async () => {
applySettingsUpdate(async () => {
this.settings.enable_short_term =
this.defaultSettings().enable_short_term;
update(this.settings, true);
this.updateFsrsParams();
});
});
});

return;
}
}
6 changes: 6 additions & 0 deletions src/lang/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_INTERVAL_MIN_WARNING: "يجب أن يكون الحد الأقصى للفاصل الزمني لمدة يوم واحد على الأقل.",
MAX_LINK_CONTRIB: "أقصى مساهمة ارتباط",
MAX_LINK_CONTRIB_DESC: "أقصى مساهمة للسهولة المرجحة للملاحظات المرتبطة بالسهولة الأولية.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "تسجيل",
DISPLAY_DEBUG_INFO: "عرض معلومات التصحيح على وحدة تحكم المطور",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Maximální příspěvěk prolinkování",
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.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Zaznamenávám",
DISPLAY_DEBUG_INFO: "Zobrazit informace pro ladění na vývojářské konzoli",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Maximaler Einfluss von Links",
MAX_LINK_CONTRIB_DESC:
"Maximaler Einfluss der Einfachheiten verlinkter Notizen zur gewichteten initialen Einfachheit einer neuen Lernkarte.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Protokollierung",
DISPLAY_DEBUG_INFO: "Informationen zum Debugging in der Entwicklerkonsole anzeigen",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Maximum link contribution",
MAX_LINK_CONTRIB_DESC:
"Maximum contribution of the weighted ease of linked notes to the initial ease.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Logging",
DISPLAY_DEBUG_INFO: "Display debugging information on the developer console",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Contribución máxima de las notas vinculadas.",
MAX_LINK_CONTRIB_DESC:
"Contribución máxima de la facilidad ponderada de las notas vinculadas a la facilidad inicial.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Registro",
DISPLAY_DEBUG_INFO: "¿Mostrar información de depuración en la consola de desarrollador",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Contributo massimo delle note collegate",
MAX_LINK_CONTRIB_DESC:
"Contributo massimo della difficoltà pasata delle note collegate alla difficoltà iniziale.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Registrando",
DISPLAY_DEBUG_INFO: "Visualizza informazione di debug sulla console per sviluppatori",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "リンクコントリビューションの最大値",
MAX_LINK_CONTRIB_DESC:
"最初の易しさに対して、リンクされたノートの重み付けされた易しさが寄与する最大値を指定してください。",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "ログ管理",
DISPLAY_DEBUG_INFO: "デベロッパーコンソールにてデバッグ情報を表示しますか",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "최대 연결 기여도",
MAX_LINK_CONTRIB_DESC:
"링크된 노트의 초기 ease에 대한 가중치가 적용된 ease의 최대 기여도입니다.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "로깅",
DISPLAY_DEBUG_INFO: "디버깅 정보를 개발자 콘솔에 표시하시겠습니까",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Maksymalny wkład łącza",
MAX_LINK_CONTRIB_DESC:
"Maksymalny wkład ważonej łatwości połączonych notatek do początkowej łatwości.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Logowanie",
DISPLAY_DEBUG_INFO: "Wyświetl informacje debugowania w konsoli deweloperskiej", // sidebar.ts
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Contribuição Máxima de Links",
MAX_LINK_CONTRIB_DESC:
"Contribuição máxima da facilidade ponderada das notas linkadas à facilidade inicial.",
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Logging",
DISPLAY_DEBUG_INFO: "Mostrar informação de debugging no console de desenvolvimento",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_LINK_CONTRIB: "Максимальный вклад связи (ссылки)",
MAX_LINK_CONTRIB_DESC:
'Максимальный вклад среднего значения "Лёгкости" связанных заметок в начальную "Лёгкость".',
FUZZING: "Fuzzing",
FUZZING_DESC:
"When enabled, this adds a small random delay to the new interval time to prevent cards from sticking together and always being reviewed on the same day.",
SWITCH_SHORT_TERM: "Switch to Short-term Scheduler",
SWITCH_SHORT_TERM_DESC:
"When disabled, this allow user to skip the short-term scheduler and directly switch to the long-term scheduler.",
LOGGING: "Журналирование",
DISPLAY_DEBUG_INFO: "Отображать отладочную информацию в консоли разработчика",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
5 changes: 5 additions & 0 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_INTERVAL_MIN_WARNING: "最大间隔至少为1天",
MAX_LINK_CONTRIB: "最大链接收益",
MAX_LINK_CONTRIB_DESC: "链接笔记的加权掌握程度对原始掌握程度的最大贡献。",
FUZZING: "均衡",
FUZZING_DESC: "启用时, 会给新间隔添加个较小的随机延迟,以免卡片总被堆积在同一天复习。",
SWITCH_SHORT_TERM: "短期排程",
SWITCH_SHORT_TERM_DESC:
"禁用时,可让用户跳过短期排程(如5分钟、10分钟),直接切换到长期排程(如3天、5天)。",
LOGGING: "记录中",
DISPLAY_DEBUG_INFO: "在开发者控制台中显示调试信息",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down
5 changes: 5 additions & 0 deletions src/lang/locale/zh-tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ Note that this setting is common to both Flashcards and Notes.`,
MAX_INTERVAL_MIN_WARNING: "最大間隔至少為1天",
MAX_LINK_CONTRIB: "最大鏈接貢獻",
MAX_LINK_CONTRIB_DESC: "鏈接筆記的加權掌握程度對原始掌握程度的最大貢獻。",
FUZZING: "均衡",
FUZZING_DESC: "啟用時, 會給新間隔添加個較小的隨機延遲,以免卡片總被堆積在同一天復習。",
SWITCH_SHORT_TERM: "短期排程",
SWITCH_SHORT_TERM_DESC:
"禁用時,可讓用戶跳過短期排程(如5分鐘、10分鐘),直接切換到長期排程(如3天、5天)。",
LOGGING: "記錄中",
DISPLAY_DEBUG_INFO: "在開發者控制台中顯示除錯資訊",
DISPLAY_PARSER_DEBUG_INFO:
Expand Down

0 comments on commit daf7a12

Please sign in to comment.