|
24 | 24 | toggle_all: 'k' // Toggle all clozes and fields |
25 | 25 | }, |
26 | 26 | 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.) |
29 | 29 | }, |
30 | 30 | fields: { |
31 | 31 | title: true, // Title area |
32 | 32 | legends: [ // Configurable legends at bottom |
33 | 33 | [ |
34 | | - '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">→</span> BECOMES</div>', |
35 | | - '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">⇒</span> LEADS TO</div>', |
36 | | - '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">⤙</span> EXCITE/ACTIVATE</div>', |
37 | | - '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">⫣</span> INHIBIT/DEACTIVATE</div>' |
| 34 | + '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">→</span> BECOMES/LEADS TO</div>', |
| 35 | + '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">⇾</span> EXCITE/ACTIVATE</div>', |
| 36 | + '<div style="background-color: #465A65; color: #d4d4d4; font-weight: bold;"><span style="font-size: 150%;">⊣</span> INHIBIT/DEACTIVATE</div>' |
38 | 37 | ], [ |
39 | 38 | '<div style="background-color: #FD7C6E; color: #020202; font-weight: bold;">INCORRECT</div>', |
40 | 39 | '<div style="background-color: #FAA76C; color: #020202; font-weight: bold;">DUPLICATE</div>', |
|
212 | 211 | rng.setStart(res.value, match.index - index); |
213 | 212 | } |
214 | 213 | if (match.index + sstr.length >= index && |
215 | | - match.index + sstr.length < index + res.value.length && |
| 214 | + match.index + sstr.length <= index + res.value.length && |
216 | 215 | rng) { |
217 | 216 | rng.setEnd(res.value, match.index + sstr.length - index); |
218 | 217 | sel.addRange(rng); |
|
317 | 316 | this.viewport.insertAdjacentElement('beforebegin', title); |
318 | 317 | } |
319 | 318 | } |
320 | | - let active_found = false; |
| 319 | + let active_seen = false; |
321 | 320 | 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); |
324 | 323 | if (this.expose(cloze) || !active && cloze.querySelector('.cloze')) { |
325 | | - cloze.classList.remove('cloze-inactive'); |
| 324 | + cloze.classList.remove('cloze', 'cloze-inactive'); |
326 | 325 | return; |
327 | 326 | } |
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)) |
338 | 333 | this.hide(cloze); |
339 | 334 | })); |
340 | 335 | if (!this.cfg.show.additional) |
|
0 commit comments