Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply consistent style between current and last cards #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NSBum
Copy link

@NSBum NSBum commented Sep 26, 2022

Creates a more consistent display in the last card pane by recreating the last card stats data table, based on the current card pane’s table format. Also applies the default styling from the first load rather than waiting for the next card to force the last card stats to display, where the links to the system CSS files are found.

Solves two issues:

  1. Previously, on first launch the stats of the current card were displayed with no CSS applied because the links to the system CSS were only available once the Last Card section was loaded. Now, we provide the CSS from the Anki in the <head> section so it's available on first load.
  2. The Current Card and Last Card were displayed differently because they came from two different sources. The Current Card's stats table is created by the add-on whereas the Last Card's stats table is derived from Anki's own stats page. This commit creates a consistent visual style by scraping all of the data from the Anki-provided stats table and building a new table from it, based on the formatting used in the Current Card stats table. Then the original Anki-provided table is removed from the DOM.

In solving issue 2 above, an arbitrary small delay had to added to allow Anki's provided js to make its own modifications to the DOM. It's a little fragile and may need to be adjusted but I couldn't think of any other signal to latch onto. I've only tested it on macOS 11.6, Intel; Anki 2.1.53, Qt6

@NSBum - aka u/OjisanSeiuchi

First load, no CSS

First load showing no CSS applied

After the above issues addressed

Visual style corrected

And night mode is unaffected

Night mode unaffected

Creates a more consistent display in the last card pane by recreating the last card stats data table, based on the current card pane’s table format. Also applies the default styling from the first load rather than waiting for the next card to force the last card stats to display, where the links to the system CSS files are found.
@ijgnd
Copy link
Owner

ijgnd commented Nov 6, 2022

Thanks for sharing this. Sorry for answering so late. On my computer I don't see any difference with or without your commit. So it's still on my todo list to look more into this. I haven't merged this yet because I'm afraid that if something changes in Anki I can't maintain your js code. Maybe I should add an option to optionally enable your code? But I'll be pretty busy until the end of January.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants