Skip to content

Commit

Permalink
serve card at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueGreenMagick committed Jun 27, 2022
1 parent 53c476a commit d5ea569
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/addon/reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from anki.buildinfo import version as ankiversion
from anki.template import TemplateRenderContext
from anki.notes import Note
from anki.cards import Card
import aqt
from aqt import mw, gui_hooks
from aqt.editor import Editor
Expand Down Expand Up @@ -62,10 +63,13 @@ def edit_filter(txt: str, field: str, filt: str, ctx: TemplateRenderContext) ->
txt,
conf["tag"],
)
txt += "<script>EFDRC.serveCard('{}')</script>".format(field)
return txt


def serve_card(txt: str, card: Card, kind: str) -> str:
return txt + "<script>EFDRC.serveCard()</script>"


def saveField(note: Note, fld: str, val: str) -> None:
if fld == "Tags":
# aqt.editor.Editor.saveTags
Expand Down Expand Up @@ -210,6 +214,5 @@ def on_webview(web_content: aqt.webview.WebContent, context: Optional[Any]) -> N
mw.addonManager.setWebExports(__name__, r"web/.*")
gui_hooks.webview_will_set_content.append(on_webview)
gui_hooks.webview_did_receive_js_message.append(handle_pycmd_message)
gui_hooks.card_will_show.append(serve_card)
anki.hooks.field_filter.append(edit_filter)

# gui_hooks.card_will_show.append(lambda t, c, k: print(t))
4 changes: 2 additions & 2 deletions src/addon/web/global_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
['onkeypress', 'handleKeyPress']
]

EFDRC.serveCard = function (fld) { // fld: string
const els = document.querySelectorAll("[data-EFDRCfield='" + fld + "']")
EFDRC.serveCard = function () { // fld: string
const els = document.querySelectorAll('[data-EFDRCfield]')
for (const el of els) {
if (EFDRC.CONF.ctrl_click) {
const fldName = b64DecodeUnicode(el.getAttribute('data-EFDRCfield'))
Expand Down

0 comments on commit d5ea569

Please sign in to comment.