genanki-js 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/License.md +22 -22
- package/README.md +179 -89
- package/dist/genanki.cjs +1277 -0
- package/dist/genanki.js +1270 -536
- package/dist/genanki.mjs +1277 -0
- package/genanki/anki_hash.js +31 -28
- package/genanki/apkg_col.js +107 -0
- package/genanki/apkg_schema.js +83 -83
- package/genanki/deck.js +12 -12
- package/genanki/default.js +135 -135
- package/genanki/license.js +15 -15
- package/genanki/model.js +61 -58
- package/genanki/note.js +62 -59
- package/genanki/package.js +239 -134
- package/genanki/sha256.js +518 -0
- package/package.json +55 -36
- package/Changelog.md +0 -13
- package/dist/genanki-min.js +0 -1
- package/genanki/import.js +0 -4
- package/gulpfile.js +0 -28
package/genanki/anki_hash.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
const BASE91_TABLE = [
|
|
2
|
-
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
|
3
|
-
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
|
4
|
-
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4',
|
|
5
|
-
'5', '6', '7', '8', '9', '!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':',
|
|
6
|
-
';', '<', '=', '>', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~']
|
|
7
|
-
|
|
8
|
-
function ankiHash(fields) {
|
|
9
|
-
const str = fields.join('__')
|
|
10
|
-
const h = sha256.create();
|
|
11
|
-
h.update(str)
|
|
12
|
-
const hex = h.digest()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
1
|
+
const BASE91_TABLE = [
|
|
2
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
|
3
|
+
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
|
4
|
+
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4',
|
|
5
|
+
'5', '6', '7', '8', '9', '!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':',
|
|
6
|
+
';', '<', '=', '>', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~']
|
|
7
|
+
|
|
8
|
+
function ankiHash(fields) {
|
|
9
|
+
const str = fields.join('__')
|
|
10
|
+
const h = sha256.create();
|
|
11
|
+
h.update(str)
|
|
12
|
+
const hex = h.digest()
|
|
13
|
+
|
|
14
|
+
// The first 8 bytes of the digest form a big-endian unsigned 64-bit integer,
|
|
15
|
+
// which is converted to the weird base91 format that Anki uses.
|
|
16
|
+
// Long division over the byte array is used instead of BigInt, because
|
|
17
|
+
// BigInt (and the `0n` literal syntax) is not supported on older Safari / iOS.
|
|
18
|
+
const digits = hex.slice(0, 8)
|
|
19
|
+
let rv_reversed = []
|
|
20
|
+
while (digits.some(d => d !== 0)) {
|
|
21
|
+
let remainder = 0
|
|
22
|
+
for (let i = 0; i < digits.length; i++) {
|
|
23
|
+
const acc = remainder * 256 + digits[i]
|
|
24
|
+
digits[i] = Math.floor(acc / 91)
|
|
25
|
+
remainder = acc % 91
|
|
26
|
+
}
|
|
27
|
+
rv_reversed.push(BASE91_TABLE[remainder])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return rv_reversed.reverse().join('')
|
|
31
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var APKG_COL = `
|
|
2
|
+
INSERT INTO col VALUES(
|
|
3
|
+
null,
|
|
4
|
+
1411124400,
|
|
5
|
+
1425279151694,
|
|
6
|
+
1425279151690,
|
|
7
|
+
11,
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
'{
|
|
12
|
+
"activeDecks": [
|
|
13
|
+
1
|
|
14
|
+
],
|
|
15
|
+
"addToCur": true,
|
|
16
|
+
"collapseTime": 1200,
|
|
17
|
+
"curDeck": 1,
|
|
18
|
+
"curModel": "1425279151691",
|
|
19
|
+
"dueCounts": true,
|
|
20
|
+
"estTimes": true,
|
|
21
|
+
"newBury": true,
|
|
22
|
+
"newSpread": 0,
|
|
23
|
+
"nextPos": 1,
|
|
24
|
+
"sortBackwards": false,
|
|
25
|
+
"sortType": "noteFld",
|
|
26
|
+
"timeLim": 0
|
|
27
|
+
}',
|
|
28
|
+
'{}',
|
|
29
|
+
'{
|
|
30
|
+
"1": {
|
|
31
|
+
"collapsed": false,
|
|
32
|
+
"conf": 1,
|
|
33
|
+
"desc": "",
|
|
34
|
+
"dyn": 0,
|
|
35
|
+
"extendNew": 10,
|
|
36
|
+
"extendRev": 50,
|
|
37
|
+
"id": 1,
|
|
38
|
+
"lrnToday": [
|
|
39
|
+
0,
|
|
40
|
+
0
|
|
41
|
+
],
|
|
42
|
+
"mod": 1425279151,
|
|
43
|
+
"name": "Default",
|
|
44
|
+
"newToday": [
|
|
45
|
+
0,
|
|
46
|
+
0
|
|
47
|
+
],
|
|
48
|
+
"revToday": [
|
|
49
|
+
0,
|
|
50
|
+
0
|
|
51
|
+
],
|
|
52
|
+
"timeToday": [
|
|
53
|
+
0,
|
|
54
|
+
0
|
|
55
|
+
],
|
|
56
|
+
"usn": 0
|
|
57
|
+
}
|
|
58
|
+
}',
|
|
59
|
+
'{
|
|
60
|
+
"1": {
|
|
61
|
+
"autoplay": true,
|
|
62
|
+
"id": 1,
|
|
63
|
+
"lapse": {
|
|
64
|
+
"delays": [
|
|
65
|
+
10
|
|
66
|
+
],
|
|
67
|
+
"leechAction": 0,
|
|
68
|
+
"leechFails": 8,
|
|
69
|
+
"minInt": 1,
|
|
70
|
+
"mult": 0
|
|
71
|
+
},
|
|
72
|
+
"maxTaken": 60,
|
|
73
|
+
"mod": 0,
|
|
74
|
+
"name": "Default",
|
|
75
|
+
"new": {
|
|
76
|
+
"bury": true,
|
|
77
|
+
"delays": [
|
|
78
|
+
1,
|
|
79
|
+
10
|
|
80
|
+
],
|
|
81
|
+
"initialFactor": 2500,
|
|
82
|
+
"ints": [
|
|
83
|
+
1,
|
|
84
|
+
4,
|
|
85
|
+
7
|
|
86
|
+
],
|
|
87
|
+
"order": 1,
|
|
88
|
+
"perDay": 20,
|
|
89
|
+
"separate": true
|
|
90
|
+
},
|
|
91
|
+
"replayq": true,
|
|
92
|
+
"rev": {
|
|
93
|
+
"bury": true,
|
|
94
|
+
"ease4": 1.3,
|
|
95
|
+
"fuzz": 0.05,
|
|
96
|
+
"ivlFct": 1,
|
|
97
|
+
"maxIvl": 36500,
|
|
98
|
+
"minSpace": 1,
|
|
99
|
+
"perDay": 100
|
|
100
|
+
},
|
|
101
|
+
"timer": 0,
|
|
102
|
+
"usn": 0
|
|
103
|
+
}
|
|
104
|
+
}',
|
|
105
|
+
'{}'
|
|
106
|
+
);
|
|
107
|
+
`;
|
package/genanki/apkg_schema.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* [genanki]{@link https://github.com/kerrickstaley/genanki}
|
|
3
|
-
* @copyright Copyright (c) Kerrick Staley 2021
|
|
4
|
-
* @license The MIT License
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
PRAGMA foreign_keys=OFF;
|
|
9
|
-
BEGIN TRANSACTION;
|
|
10
|
-
|
|
11
|
-
CREATE TABLE col (
|
|
12
|
-
id integer primary key,
|
|
13
|
-
crt integer not null,
|
|
14
|
-
mod integer not null,
|
|
15
|
-
scm integer not null,
|
|
16
|
-
ver integer not null,
|
|
17
|
-
dty integer not null,
|
|
18
|
-
usn integer not null,
|
|
19
|
-
ls integer not null,
|
|
20
|
-
conf text not null,
|
|
21
|
-
models text not null,
|
|
22
|
-
decks text not null,
|
|
23
|
-
dconf text not null,
|
|
24
|
-
tags text not null
|
|
25
|
-
);
|
|
26
|
-
CREATE TABLE notes (
|
|
27
|
-
id integer primary key, /* 0 */
|
|
28
|
-
guid text not null, /* 1 */
|
|
29
|
-
mid integer not null, /* 2 */
|
|
30
|
-
mod integer not null, /* 3 */
|
|
31
|
-
usn integer not null, /* 4 */
|
|
32
|
-
tags text not null, /* 5 */
|
|
33
|
-
flds text not null, /* 6 */
|
|
34
|
-
sfld integer not null, /* 7 */
|
|
35
|
-
csum integer not null, /* 8 */
|
|
36
|
-
flags integer not null, /* 9 */
|
|
37
|
-
data text not null /* 10 */
|
|
38
|
-
);
|
|
39
|
-
CREATE TABLE cards (
|
|
40
|
-
id integer primary key, /* 0 */
|
|
41
|
-
nid integer not null, /* 1 */
|
|
42
|
-
did integer not null, /* 2 */
|
|
43
|
-
ord integer not null, /* 3 */
|
|
44
|
-
mod integer not null, /* 4 */
|
|
45
|
-
usn integer not null, /* 5 */
|
|
46
|
-
type integer not null, /* 6 */
|
|
47
|
-
queue integer not null, /* 7 */
|
|
48
|
-
due integer not null, /* 8 */
|
|
49
|
-
ivl integer not null, /* 9 */
|
|
50
|
-
factor integer not null, /* 10 */
|
|
51
|
-
reps integer not null, /* 11 */
|
|
52
|
-
lapses integer not null, /* 12 */
|
|
53
|
-
left integer not null, /* 13 */
|
|
54
|
-
odue integer not null, /* 14 */
|
|
55
|
-
odid integer not null, /* 15 */
|
|
56
|
-
flags integer not null, /* 16 */
|
|
57
|
-
data text not null /* 17 */
|
|
58
|
-
);
|
|
59
|
-
CREATE TABLE revlog (
|
|
60
|
-
id integer primary key,
|
|
61
|
-
cid integer not null,
|
|
62
|
-
usn integer not null,
|
|
63
|
-
ease integer not null,
|
|
64
|
-
ivl integer not null,
|
|
65
|
-
lastIvl integer not null,
|
|
66
|
-
factor integer not null,
|
|
67
|
-
time integer not null,
|
|
68
|
-
type integer not null
|
|
69
|
-
);
|
|
70
|
-
CREATE TABLE graves (
|
|
71
|
-
usn integer not null,
|
|
72
|
-
oid integer not null,
|
|
73
|
-
type integer not null
|
|
74
|
-
);
|
|
75
|
-
CREATE INDEX ix_notes_usn on notes (usn);
|
|
76
|
-
CREATE INDEX ix_cards_usn on cards (usn);
|
|
77
|
-
CREATE INDEX ix_revlog_usn on revlog (usn);
|
|
78
|
-
CREATE INDEX ix_cards_nid on cards (nid);
|
|
79
|
-
CREATE INDEX ix_cards_sched on cards (did, queue, due);
|
|
80
|
-
CREATE INDEX ix_revlog_cid on revlog (cid);
|
|
81
|
-
CREATE INDEX ix_notes_csum on notes (csum);
|
|
82
|
-
COMMIT;
|
|
83
|
-
`;
|
|
1
|
+
/*
|
|
2
|
+
* [genanki]{@link https://github.com/kerrickstaley/genanki}
|
|
3
|
+
* @copyright Copyright (c) Kerrick Staley 2021
|
|
4
|
+
* @license The MIT License
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const APKG_SCHEMA = `
|
|
8
|
+
PRAGMA foreign_keys=OFF;
|
|
9
|
+
BEGIN TRANSACTION;
|
|
10
|
+
|
|
11
|
+
CREATE TABLE col (
|
|
12
|
+
id integer primary key,
|
|
13
|
+
crt integer not null,
|
|
14
|
+
mod integer not null,
|
|
15
|
+
scm integer not null,
|
|
16
|
+
ver integer not null,
|
|
17
|
+
dty integer not null,
|
|
18
|
+
usn integer not null,
|
|
19
|
+
ls integer not null,
|
|
20
|
+
conf text not null,
|
|
21
|
+
models text not null,
|
|
22
|
+
decks text not null,
|
|
23
|
+
dconf text not null,
|
|
24
|
+
tags text not null
|
|
25
|
+
);
|
|
26
|
+
CREATE TABLE notes (
|
|
27
|
+
id integer primary key, /* 0 */
|
|
28
|
+
guid text not null, /* 1 */
|
|
29
|
+
mid integer not null, /* 2 */
|
|
30
|
+
mod integer not null, /* 3 */
|
|
31
|
+
usn integer not null, /* 4 */
|
|
32
|
+
tags text not null, /* 5 */
|
|
33
|
+
flds text not null, /* 6 */
|
|
34
|
+
sfld integer not null, /* 7 */
|
|
35
|
+
csum integer not null, /* 8 */
|
|
36
|
+
flags integer not null, /* 9 */
|
|
37
|
+
data text not null /* 10 */
|
|
38
|
+
);
|
|
39
|
+
CREATE TABLE cards (
|
|
40
|
+
id integer primary key, /* 0 */
|
|
41
|
+
nid integer not null, /* 1 */
|
|
42
|
+
did integer not null, /* 2 */
|
|
43
|
+
ord integer not null, /* 3 */
|
|
44
|
+
mod integer not null, /* 4 */
|
|
45
|
+
usn integer not null, /* 5 */
|
|
46
|
+
type integer not null, /* 6 */
|
|
47
|
+
queue integer not null, /* 7 */
|
|
48
|
+
due integer not null, /* 8 */
|
|
49
|
+
ivl integer not null, /* 9 */
|
|
50
|
+
factor integer not null, /* 10 */
|
|
51
|
+
reps integer not null, /* 11 */
|
|
52
|
+
lapses integer not null, /* 12 */
|
|
53
|
+
left integer not null, /* 13 */
|
|
54
|
+
odue integer not null, /* 14 */
|
|
55
|
+
odid integer not null, /* 15 */
|
|
56
|
+
flags integer not null, /* 16 */
|
|
57
|
+
data text not null /* 17 */
|
|
58
|
+
);
|
|
59
|
+
CREATE TABLE revlog (
|
|
60
|
+
id integer primary key,
|
|
61
|
+
cid integer not null,
|
|
62
|
+
usn integer not null,
|
|
63
|
+
ease integer not null,
|
|
64
|
+
ivl integer not null,
|
|
65
|
+
lastIvl integer not null,
|
|
66
|
+
factor integer not null,
|
|
67
|
+
time integer not null,
|
|
68
|
+
type integer not null
|
|
69
|
+
);
|
|
70
|
+
CREATE TABLE graves (
|
|
71
|
+
usn integer not null,
|
|
72
|
+
oid integer not null,
|
|
73
|
+
type integer not null
|
|
74
|
+
);
|
|
75
|
+
CREATE INDEX ix_notes_usn on notes (usn);
|
|
76
|
+
CREATE INDEX ix_cards_usn on cards (usn);
|
|
77
|
+
CREATE INDEX ix_revlog_usn on revlog (usn);
|
|
78
|
+
CREATE INDEX ix_cards_nid on cards (nid);
|
|
79
|
+
CREATE INDEX ix_cards_sched on cards (did, queue, due);
|
|
80
|
+
CREATE INDEX ix_revlog_cid on revlog (cid);
|
|
81
|
+
CREATE INDEX ix_notes_csum on notes (csum);
|
|
82
|
+
COMMIT;
|
|
83
|
+
`;
|
package/genanki/deck.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(id, name, desc="") {
|
|
3
|
-
this.id = id
|
|
4
|
-
this.name = name
|
|
5
|
-
this.desc = desc
|
|
6
|
-
this.notes = []
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
addNote(note) {
|
|
10
|
-
this.notes.push(note)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
class Deck {
|
|
2
|
+
constructor(id, name, desc="") {
|
|
3
|
+
this.id = id
|
|
4
|
+
this.name = name
|
|
5
|
+
this.desc = desc
|
|
6
|
+
this.notes = []
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
addNote(note) {
|
|
10
|
+
this.notes.push(note)
|
|
11
|
+
}
|
|
12
|
+
}
|
package/genanki/default.js
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
sortf: 0, // sort field
|
|
3
|
-
did: 1, // deck id
|
|
4
|
-
latexPre: `\\documentclass[12pt]{article}
|
|
5
|
-
\\special{papersize=3in,5in}
|
|
6
|
-
\\usepackage[utf8]{inputenc}
|
|
7
|
-
\\usepackage{amssymb,amsmath}
|
|
8
|
-
\\pagestyle{empty}
|
|
9
|
-
\\setlength{\\parindent}{0in}
|
|
10
|
-
\\begin{document}`,
|
|
11
|
-
latexPost: "\\end{document}",
|
|
12
|
-
mod: 0, // modification time
|
|
13
|
-
usn: 0, // unsure, something to do with sync?
|
|
14
|
-
vers: [], // seems to be unused
|
|
15
|
-
type: MODEL_STD,
|
|
16
|
-
css: `.card {
|
|
17
|
-
font-family: arial;
|
|
18
|
-
font-size: 20px;
|
|
19
|
-
text-align: center;
|
|
20
|
-
color: black;
|
|
21
|
-
background-color: white;
|
|
22
|
-
}`,
|
|
23
|
-
/* also:
|
|
24
|
-
name: string,
|
|
25
|
-
flds: [Field],
|
|
26
|
-
tmpls: [Template],
|
|
27
|
-
tags: [??],
|
|
28
|
-
id: string
|
|
29
|
-
*/
|
|
30
|
-
tags: [],
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
name: "",
|
|
35
|
-
ord: null,
|
|
36
|
-
sticky: false,
|
|
37
|
-
rtl: false,
|
|
38
|
-
font: "Arial",
|
|
39
|
-
size: 20,
|
|
40
|
-
media: [],
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: "",
|
|
45
|
-
ord: null,
|
|
46
|
-
qfmt: "",
|
|
47
|
-
afmt: "",
|
|
48
|
-
did: null,
|
|
49
|
-
bqfmt: "",
|
|
50
|
-
bafmt: "",
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// whether new cards should be mixed with reviews, or shown first or last
|
|
54
|
-
const NEW_CARDS_DISTRIBUTE = 0
|
|
55
|
-
const NEW_CARDS_LAST = 1
|
|
56
|
-
const NEW_CARDS_FIRST = 2
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// review options
|
|
60
|
-
'activeDecks': [1],
|
|
61
|
-
'curDeck': 1,
|
|
62
|
-
'newSpread': NEW_CARDS_DISTRIBUTE,
|
|
63
|
-
'collapseTime': 1200,
|
|
64
|
-
'timeLim': 0,
|
|
65
|
-
'estTimes': true,
|
|
66
|
-
'dueCounts': true,
|
|
67
|
-
// other config
|
|
68
|
-
'curModel': null,
|
|
69
|
-
'nextPos': 1,
|
|
70
|
-
'sortType': "noteFld",
|
|
71
|
-
'sortBackwards': false,
|
|
72
|
-
'addToCur': true, // add new to currently selected deck?
|
|
73
|
-
'dayLearnFirst': false,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// new card insertion order
|
|
78
|
-
const NEW_CARDS_RANDOM = 0
|
|
79
|
-
const NEW_CARDS_DUE = 1
|
|
80
|
-
|
|
81
|
-
const STARTING_FACTOR = 2500
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'name': "Default",
|
|
85
|
-
'new': {
|
|
86
|
-
'delays': [1, 10],
|
|
87
|
-
'ints': [1, 4, 7], // 7 is not currently used
|
|
88
|
-
'initialFactor': STARTING_FACTOR,
|
|
89
|
-
'separate': true,
|
|
90
|
-
'order': NEW_CARDS_DUE,
|
|
91
|
-
'perDay': 20,
|
|
92
|
-
// may not be set on old decks
|
|
93
|
-
'bury': false,
|
|
94
|
-
},
|
|
95
|
-
'lapse': {
|
|
96
|
-
'delays': [10],
|
|
97
|
-
'mult': 0,
|
|
98
|
-
'minInt': 1,
|
|
99
|
-
'leechFails': 8,
|
|
100
|
-
// type 0=suspend, 1=tagonly
|
|
101
|
-
'leechAction': 0,
|
|
102
|
-
},
|
|
103
|
-
'rev': {
|
|
104
|
-
'perDay': 200,
|
|
105
|
-
'ease4': 1.3,
|
|
106
|
-
'fuzz': 0.05,
|
|
107
|
-
'minSpace': 1, // not currently used
|
|
108
|
-
'ivlFct': 1,
|
|
109
|
-
'maxIvl': 36500,
|
|
110
|
-
// may not be set on old decks
|
|
111
|
-
'bury': false,
|
|
112
|
-
'hardFactor': 1.2,
|
|
113
|
-
},
|
|
114
|
-
'maxTaken': 60,
|
|
115
|
-
'timer': 0,
|
|
116
|
-
'autoplay': true,
|
|
117
|
-
'replayq': true,
|
|
118
|
-
'mod': 0,
|
|
119
|
-
'usn': 0,
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
newToday: [0, 0], // currentDay, count
|
|
124
|
-
revToday: [0, 0],
|
|
125
|
-
lrnToday: [0, 0],
|
|
126
|
-
timeToday: [0, 0], // time in ms
|
|
127
|
-
conf: 1,
|
|
128
|
-
usn: 0,
|
|
129
|
-
desc: "",
|
|
130
|
-
dyn: 0, // anki uses int/bool interchangably here
|
|
131
|
-
collapsed: false,
|
|
132
|
-
// added in beta11
|
|
133
|
-
extendNew: 10,
|
|
134
|
-
extendRev: 50,
|
|
135
|
-
}
|
|
1
|
+
const defaultModel = {
|
|
2
|
+
sortf: 0, // sort field
|
|
3
|
+
did: 1, // deck id
|
|
4
|
+
latexPre: `\\documentclass[12pt]{article}
|
|
5
|
+
\\special{papersize=3in,5in}
|
|
6
|
+
\\usepackage[utf8]{inputenc}
|
|
7
|
+
\\usepackage{amssymb,amsmath}
|
|
8
|
+
\\pagestyle{empty}
|
|
9
|
+
\\setlength{\\parindent}{0in}
|
|
10
|
+
\\begin{document}`,
|
|
11
|
+
latexPost: "\\end{document}",
|
|
12
|
+
mod: 0, // modification time
|
|
13
|
+
usn: 0, // unsure, something to do with sync?
|
|
14
|
+
vers: [], // seems to be unused
|
|
15
|
+
type: MODEL_STD,
|
|
16
|
+
css: `.card {
|
|
17
|
+
font-family: arial;
|
|
18
|
+
font-size: 20px;
|
|
19
|
+
text-align: center;
|
|
20
|
+
color: black;
|
|
21
|
+
background-color: white;
|
|
22
|
+
}`,
|
|
23
|
+
/* also:
|
|
24
|
+
name: string,
|
|
25
|
+
flds: [Field],
|
|
26
|
+
tmpls: [Template],
|
|
27
|
+
tags: [??],
|
|
28
|
+
id: string
|
|
29
|
+
*/
|
|
30
|
+
tags: [],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const defaultField = {
|
|
34
|
+
name: "",
|
|
35
|
+
ord: null,
|
|
36
|
+
sticky: false,
|
|
37
|
+
rtl: false,
|
|
38
|
+
font: "Arial",
|
|
39
|
+
size: 20,
|
|
40
|
+
media: [],
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const defaultTemplate = {
|
|
44
|
+
name: "",
|
|
45
|
+
ord: null,
|
|
46
|
+
qfmt: "",
|
|
47
|
+
afmt: "",
|
|
48
|
+
did: null,
|
|
49
|
+
bqfmt: "",
|
|
50
|
+
bafmt: "",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// whether new cards should be mixed with reviews, or shown first or last
|
|
54
|
+
const NEW_CARDS_DISTRIBUTE = 0
|
|
55
|
+
const NEW_CARDS_LAST = 1
|
|
56
|
+
const NEW_CARDS_FIRST = 2
|
|
57
|
+
|
|
58
|
+
const defaultConf = {
|
|
59
|
+
// review options
|
|
60
|
+
'activeDecks': [1],
|
|
61
|
+
'curDeck': 1,
|
|
62
|
+
'newSpread': NEW_CARDS_DISTRIBUTE,
|
|
63
|
+
'collapseTime': 1200,
|
|
64
|
+
'timeLim': 0,
|
|
65
|
+
'estTimes': true,
|
|
66
|
+
'dueCounts': true,
|
|
67
|
+
// other config
|
|
68
|
+
'curModel': null,
|
|
69
|
+
'nextPos': 1,
|
|
70
|
+
'sortType': "noteFld",
|
|
71
|
+
'sortBackwards': false,
|
|
72
|
+
'addToCur': true, // add new to currently selected deck?
|
|
73
|
+
'dayLearnFirst': false,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
// new card insertion order
|
|
78
|
+
const NEW_CARDS_RANDOM = 0
|
|
79
|
+
const NEW_CARDS_DUE = 1
|
|
80
|
+
|
|
81
|
+
const STARTING_FACTOR = 2500
|
|
82
|
+
|
|
83
|
+
const defaultDeckConf = {
|
|
84
|
+
'name': "Default",
|
|
85
|
+
'new': {
|
|
86
|
+
'delays': [1, 10],
|
|
87
|
+
'ints': [1, 4, 7], // 7 is not currently used
|
|
88
|
+
'initialFactor': STARTING_FACTOR,
|
|
89
|
+
'separate': true,
|
|
90
|
+
'order': NEW_CARDS_DUE,
|
|
91
|
+
'perDay': 20,
|
|
92
|
+
// may not be set on old decks
|
|
93
|
+
'bury': false,
|
|
94
|
+
},
|
|
95
|
+
'lapse': {
|
|
96
|
+
'delays': [10],
|
|
97
|
+
'mult': 0,
|
|
98
|
+
'minInt': 1,
|
|
99
|
+
'leechFails': 8,
|
|
100
|
+
// type 0=suspend, 1=tagonly
|
|
101
|
+
'leechAction': 0,
|
|
102
|
+
},
|
|
103
|
+
'rev': {
|
|
104
|
+
'perDay': 200,
|
|
105
|
+
'ease4': 1.3,
|
|
106
|
+
'fuzz': 0.05,
|
|
107
|
+
'minSpace': 1, // not currently used
|
|
108
|
+
'ivlFct': 1,
|
|
109
|
+
'maxIvl': 36500,
|
|
110
|
+
// may not be set on old decks
|
|
111
|
+
'bury': false,
|
|
112
|
+
'hardFactor': 1.2,
|
|
113
|
+
},
|
|
114
|
+
'maxTaken': 60,
|
|
115
|
+
'timer': 0,
|
|
116
|
+
'autoplay': true,
|
|
117
|
+
'replayq': true,
|
|
118
|
+
'mod': 0,
|
|
119
|
+
'usn': 0,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const defaultDeck = {
|
|
123
|
+
newToday: [0, 0], // currentDay, count
|
|
124
|
+
revToday: [0, 0],
|
|
125
|
+
lrnToday: [0, 0],
|
|
126
|
+
timeToday: [0, 0], // time in ms
|
|
127
|
+
conf: 1,
|
|
128
|
+
usn: 0,
|
|
129
|
+
desc: "",
|
|
130
|
+
dyn: 0, // anki uses int/bool interchangably here
|
|
131
|
+
collapsed: false,
|
|
132
|
+
// added in beta11
|
|
133
|
+
extendNew: 10,
|
|
134
|
+
extendRev: 50,
|
|
135
|
+
}
|
package/genanki/license.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* [mkanki]{@link https://github.com/nornagon/mkanki}
|
|
3
|
-
* @copyright Copyright (c) 2018 Jeremy Apthorp
|
|
4
|
-
* @license AGPL-3.0 License
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* [genanki]{@link https://github.com/kerrickstaley/genanki}
|
|
8
|
-
* @copyright Copyright (c) Kerrick Staley 2021
|
|
9
|
-
* @license The MIT License
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* [genanki-js]{@link https://github.com/krmanik/genanki-js}
|
|
13
|
-
* @copyright Copyright (c) 2021 Mani
|
|
14
|
-
* @license AGPL-3.0 License
|
|
15
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* [mkanki]{@link https://github.com/nornagon/mkanki}
|
|
3
|
+
* @copyright Copyright (c) 2018 Jeremy Apthorp
|
|
4
|
+
* @license AGPL-3.0 License
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* [genanki]{@link https://github.com/kerrickstaley/genanki}
|
|
8
|
+
* @copyright Copyright (c) Kerrick Staley 2021
|
|
9
|
+
* @license The MIT License
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* [genanki-js]{@link https://github.com/krmanik/genanki-js}
|
|
13
|
+
* @copyright Copyright (c) 2021 Mani
|
|
14
|
+
* @license AGPL-3.0 License
|
|
15
|
+
*/
|