Skip to content

Commit fb6cb1f

Browse files
committed
1.2.3
1 parent f303495 commit fb6cb1f

15 files changed

Lines changed: 99 additions & 115 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The update logic is dependent on the user keeping these tag intact and updates w
105105
- Loop iteration once you reach the first/last (otherwise you will stop): `loop`
106106
- Always start iteration from the top (otherwise iteration will "continue" from the last clicked item): `top`
107107
- `show` cloze initial display behavior:
108-
- `inactive`: inactive clozes (setting to `true`will make FC2 behave similar to core Anki clozes).
108+
- `inactive`: inactive clozes. Setting to `true` will make FC2 behave similar to core Anki clozes. Setting to `'preceding'` will show inactive clozes that come before the first active cloze (document order) and hide all other inactive clozes (if your note builds on access to preceding clozes to answer the current one(s)).
109109
- `addtional`: Additional fields.
110110
- `fields`: customizations of the interface
111111
- `title`: (only relevant for the min version) Wether to show the note "title field" (will parse out first `<h1>` or deck name if not found).
@@ -209,7 +209,7 @@ var config = {
209209
toggle_all: 'k' // Toggle all clozes and fields
210210
},
211211
show: { // `false` means initially collapsed/hidden
212-
inactive: true, // Inactive clozes
212+
inactive: true, // Inactive clozes (`false`, `true` or `'preceding'`)
213213
additional: false, // Additional fields (Note, Mnemonics etc.)
214214
},
215215
fields: {
@@ -255,3 +255,4 @@ There is effectively no add-on, it's all JavaScript (and HTML/CSS) and runs 100%
255255
- 2023-03-26: Restructure code, add `context-top` and `context-bottom`, add note specific config through tags, add log option/info, add search function, add `Flexible Cloze 2 (min)` template which only has `Text` and `Back Extra` fields. Improve styling, esp. for night mode.
256256
- 2023-05-03: Fix update bug thanks to [comienzo2093](https://github.com/comienzo2093).
257257
- 2023-05-29: Fix hint bug.
258+
- 2023-05-30: Fix search bug, add `show.inactive: 'preceding'` option.

bin/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The update logic is dependent on the user keeping these tag intact and updates w
105105
- Loop iteration once you reach the first/last (otherwise you will stop): `loop`
106106
- Always start iteration from the top (otherwise iteration will "continue" from the last clicked item): `top`
107107
- `show` cloze initial display behavior:
108-
- `inactive`: inactive clozes (setting to `true`will make FC2 behave similar to core Anki clozes).
108+
- `inactive`: inactive clozes. Setting to `true` will make FC2 behave similar to core Anki clozes. Setting to `'preceding'` will show inactive clozes that come before the first active cloze (document order) and hide all other inactive clozes (if your note builds on access to preceding clozes to answer the current one(s)).
109109
- `addtional`: Additional fields.
110110
- `fields`: customizations of the interface
111111
- `title`: (only relevant for the min version) Wether to show the note "title field" (will parse out first `<h1>` or deck name if not found).
@@ -209,7 +209,7 @@ var config = {
209209
toggle_all: 'k' // Toggle all clozes and fields
210210
},
211211
show: { // `false` means initially collapsed/hidden
212-
inactive: true, // Inactive clozes
212+
inactive: true, // Inactive clozes (`false`, `true` or `'preceding'`)
213213
additional: false, // Additional fields (Note, Mnemonics etc.)
214214
},
215215
fields: {
@@ -255,3 +255,4 @@ There is effectively no add-on, it's all JavaScript (and HTML/CSS) and runs 100%
255255
- 2023-03-26: Restructure code, add `context-top` and `context-bottom`, add note specific config through tags, add log option/info, add search function, add `Flexible Cloze 2 (min)` template which only has `Text` and `Back Extra` fields. Improve styling, esp. for night mode.
256256
- 2023-05-03: Fix update bug thanks to [comienzo2093](https://github.com/comienzo2093).
257257
- 2023-05-29: Fix hint bug.
258+
- 2023-05-30: Fix search bug, add `show.inactive: 'preceding'` option.

bin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
TAG_CSS_FUNC = "/*-- FC2 FUNCTIONALITY END --*/"
2222

2323
CVER = get_version()
24-
NVER = "1.2.2"
24+
NVER = "1.2.3"
2525

2626
#######################################################################
2727
# Current code base
2 Bytes
Binary file not shown.
2.68 KB
Binary file not shown.

bin/fc2-back.html

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
toggle_all: 'k' // Toggle all clozes and fields
2525
},
2626
show: { // `false` means initially collapsed/hidden
27-
inactive: false, // Inactive clozes
28-
additional: true // Additional fields (Note, Mnemonics etc.)
27+
inactive: false, // Inactive clozes (`true`, `false` or `'preceding'`)
28+
additional: true // Additional fields (Note, Mnemonics etc.)
2929
},
3030
fields: {
3131
title: true, // Title area
3232
legends: [ // Configurable legends at bottom
3333
[
34-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES</div>',
35-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8658;</span> LEADS TO</div>',
36-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10521;</span> EXCITE/ACTIVATE</div>',
37-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10979;</span> INHIBIT/DEACTIVATE</div>'
34+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES/LEADS TO</div>',
35+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8702;</span> EXCITE/ACTIVATE</div>',
36+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8867;</span> INHIBIT/DEACTIVATE</div>'
3837
], [
3938
'<div style="background-color: #FD7C6E; color: #020202; font-weight: bold;">INCORRECT</div>',
4039
'<div style="background-color: #FAA76C; color: #020202; font-weight: bold;">DUPLICATE</div>',
@@ -212,7 +211,7 @@
212211
rng.setStart(res.value, match.index - index);
213212
}
214213
if (match.index + sstr.length >= index &&
215-
match.index + sstr.length < index + res.value.length &&
214+
match.index + sstr.length <= index + res.value.length &&
216215
rng) {
217216
rng.setEnd(res.value, match.index + sstr.length - index);
218217
sel.addRange(rng);
@@ -317,24 +316,20 @@
317316
this.viewport.insertAdjacentElement('beforebegin', title);
318317
}
319318
}
320-
let active_found = false;
319+
let active_seen = false;
321320
this.content.querySelectorAll('.cloze-inactive, .cloze').forEach(((cloze) => {
322-
const active = cloze.classList.contains('.cloze');
323-
active_found || (active_found = active);
321+
const active = cloze.classList.contains('cloze');
322+
active_seen || (active_seen = active);
324323
if (this.expose(cloze) || !active && cloze.querySelector('.cloze')) {
325-
cloze.classList.remove('cloze-inactive');
324+
cloze.classList.remove('cloze', 'cloze-inactive');
326325
return;
327326
}
328-
if (active && this.cfg.front) {
329-
cloze.dataset.hint = cloze.innerHTML === '[...]'
330-
? this.cfg.prompt
331-
: this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || "";
332-
this.hide(cloze);
333-
}
334-
else
335-
cloze.dataset.hint = this.cfg.prompt;
336-
if (!active && (!this.cfg.show.inactive ||
337-
active_found && this.cfg.show.inactive === 'preceding'))
327+
cloze.dataset.hint = this.cfg.front && active && cloze.innerHTML !== '[...]'
328+
? this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || ""
329+
: this.cfg.prompt;
330+
if (active && this.cfg.front ||
331+
!active && (!this.cfg.show.inactive ||
332+
this.cfg.show.inactive === 'preceding' && active_seen))
338333
this.hide(cloze);
339334
}));
340335
if (!this.cfg.show.additional)

bin/fc2-front.html

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
toggle_all: 'k' // Toggle all clozes and fields
2525
},
2626
show: { // `false` means initially collapsed/hidden
27-
inactive: false, // Inactive clozes
27+
inactive: false, // Inactive clozes (`true`, `false` or `'preceding'`)
2828
additional: false // Additional fields (Note, Mnemonics etc.)
2929
},
3030
fields: {
3131
title: true, // Title area
3232
legends: [ // Configurable legends at bottom
3333
[
34-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES</div>',
35-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8658;</span> LEADS TO</div>',
36-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10521;</span> EXCITE/ACTIVATE</div>',
37-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10979;</span> INHIBIT/DEACTIVATE</div>'
34+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES/LEADS TO</div>',
35+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8702;</span> EXCITE/ACTIVATE</div>',
36+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8867;</span> INHIBIT/DEACTIVATE</div>'
3837
], [
3938
'<div style="background-color: #FD7C6E; color: #020202; font-weight: bold;">INCORRECT</div>',
4039
'<div style="background-color: #FAA76C; color: #020202; font-weight: bold;">DUPLICATE</div>',
@@ -212,7 +211,7 @@
212211
rng.setStart(res.value, match.index - index);
213212
}
214213
if (match.index + sstr.length >= index &&
215-
match.index + sstr.length < index + res.value.length &&
214+
match.index + sstr.length <= index + res.value.length &&
216215
rng) {
217216
rng.setEnd(res.value, match.index + sstr.length - index);
218217
sel.addRange(rng);
@@ -317,24 +316,20 @@
317316
this.viewport.insertAdjacentElement('beforebegin', title);
318317
}
319318
}
320-
let active_found = false;
319+
let active_seen = false;
321320
this.content.querySelectorAll('.cloze-inactive, .cloze').forEach(((cloze) => {
322-
const active = cloze.classList.contains('.cloze');
323-
active_found || (active_found = active);
321+
const active = cloze.classList.contains('cloze');
322+
active_seen || (active_seen = active);
324323
if (this.expose(cloze) || !active && cloze.querySelector('.cloze')) {
325-
cloze.classList.remove('cloze-inactive');
324+
cloze.classList.remove('cloze', 'cloze-inactive');
326325
return;
327326
}
328-
if (active && this.cfg.front) {
329-
cloze.dataset.hint = cloze.innerHTML === '[...]'
330-
? this.cfg.prompt
331-
: this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || "";
332-
this.hide(cloze);
333-
}
334-
else
335-
cloze.dataset.hint = this.cfg.prompt;
336-
if (!active && (!this.cfg.show.inactive ||
337-
active_found && this.cfg.show.inactive === 'preceding'))
327+
cloze.dataset.hint = this.cfg.front && active && cloze.innerHTML !== '[...]'
328+
? this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || ""
329+
: this.cfg.prompt;
330+
if (active && this.cfg.front ||
331+
!active && (!this.cfg.show.inactive ||
332+
this.cfg.show.inactive === 'preceding' && active_seen))
338333
this.hide(cloze);
339334
}));
340335
if (!this.cfg.show.additional)

bin/fc2m-back.html

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
toggle_all: 'k' // Toggle all clozes and fields
2525
},
2626
show: { // `false` means initially collapsed/hidden
27-
inactive: false, // Inactive clozes
28-
additional: true // Additional fields (Note, Mnemonics etc.)
27+
inactive: false, // Inactive clozes (`true`, `false` or `'preceding'`)
28+
additional: true // Additional fields (Note, Mnemonics etc.)
2929
},
3030
fields: {
3131
title: true, // Title area
3232
legends: [ // Configurable legends at bottom
3333
[
34-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES</div>',
35-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8658;</span> LEADS TO</div>',
36-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10521;</span> EXCITE/ACTIVATE</div>',
37-
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#10979;</span> INHIBIT/DEACTIVATE</div>'
34+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8594;</span> BECOMES/LEADS TO</div>',
35+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8702;</span> EXCITE/ACTIVATE</div>',
36+
'<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">&#8867;</span> INHIBIT/DEACTIVATE</div>'
3837
], [
3938
'<div style="background-color: #FD7C6E; color: #020202; font-weight: bold;">INCORRECT</div>',
4039
'<div style="background-color: #FAA76C; color: #020202; font-weight: bold;">DUPLICATE</div>',
@@ -197,7 +196,7 @@
197196
rng.setStart(res.value, match.index - index);
198197
}
199198
if (match.index + sstr.length >= index &&
200-
match.index + sstr.length < index + res.value.length &&
199+
match.index + sstr.length <= index + res.value.length &&
201200
rng) {
202201
rng.setEnd(res.value, match.index + sstr.length - index);
203202
sel.addRange(rng);
@@ -302,24 +301,20 @@
302301
this.viewport.insertAdjacentElement('beforebegin', title);
303302
}
304303
}
305-
let active_found = false;
304+
let active_seen = false;
306305
this.content.querySelectorAll('.cloze-inactive, .cloze').forEach(((cloze) => {
307-
const active = cloze.classList.contains('.cloze');
308-
active_found || (active_found = active);
306+
const active = cloze.classList.contains('cloze');
307+
active_seen || (active_seen = active);
309308
if (this.expose(cloze) || !active && cloze.querySelector('.cloze')) {
310-
cloze.classList.remove('cloze-inactive');
309+
cloze.classList.remove('cloze', 'cloze-inactive');
311310
return;
312311
}
313-
if (active && this.cfg.front) {
314-
cloze.dataset.hint = cloze.innerHTML === '[...]'
315-
? this.cfg.prompt
316-
: this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || "";
317-
this.hide(cloze);
318-
}
319-
else
320-
cloze.dataset.hint = this.cfg.prompt;
321-
if (!active && (!this.cfg.show.inactive ||
322-
active_found && this.cfg.show.inactive === 'preceding'))
312+
cloze.dataset.hint = this.cfg.front && active && cloze.innerHTML !== '[...]'
313+
? this.cfg.hint.replace('%h', cloze.innerHTML.slice(1, cloze.innerHTML.length - 1)) || ""
314+
: this.cfg.prompt;
315+
if (active && this.cfg.front ||
316+
!active && (!this.cfg.show.inactive ||
317+
this.cfg.show.inactive === 'preceding' && active_seen))
323318
this.hide(cloze);
324319
}));
325320
if (!this.cfg.show.additional)

0 commit comments

Comments
 (0)