summaryrefslogtreecommitdiff
path: root/posts
diff options
context:
space:
mode:
Diffstat (limited to 'posts')
-rw-r--r--posts/spaced-repetition-anywhere.org5
1 files changed, 5 insertions, 0 deletions
diff --git a/posts/spaced-repetition-anywhere.org b/posts/spaced-repetition-anywhere.org
index 3ae66d3..33ff8f1 100644
--- a/posts/spaced-repetition-anywhere.org
+++ b/posts/spaced-repetition-anywhere.org
@@ -16,6 +16,8 @@ Treating the algorithm as a black box, I took Fernando Borretti's implementation
#+END_EXPORT
#+BEGIN_SRC javascript
+// srs-anywhere.js:43
+// https://git.sr.ht/~jakob/srs-anywhere/tree/ad21c2d9cd8ef86a4c557cfe601ea9918a3fa2d4/item/srs-anywhere.js#L43
/***********************************************************************
,* Actual FSRS5 algorithm *
,***********************************************************************/
@@ -119,7 +121,10 @@ With some minor changes, I got it to work on mobile, too.
I'm familiar with IndexedDB and other in-browser storage mechanisms, but I wanted the cards and their scheduling metadata to be portable, and to persist through a browser refresh, so I went with storing cards and metadata in a JSON file. The program loads in the cards initially from a JSON file, conducts the review, and then prompts the user to download a JSON file containing all of the cards and their updated scheduling metadata. I wrote the parsing and review logic by hand, but asked Qwen to come up with this snippet for the final piece of giving the updated cards back to the user. It saved me from having to figure out that the Blob API is what I wanted here, and then reading through the MDN article on figuring out how to use it.
+
#+BEGIN_SRC javascript
+// srs-anywhere.js:282
+// https://git.sr.ht/~jakob/srs-anywhere/tree/ad21c2d9cd8ef86a4c557cfe601ea9918a3fa2d4/item/srs-anywhere.js#L282
function downloadJSON(obj) {
// Convert the object to a JSON string (with default formatting)
const jsonString = JSON.stringify(obj, null, 2); // 'null, 2' adds indentation for readability