Closed hssm closed 1 year ago
So, this works on Anki Desktop, right?
The problem is that the JavaScript is executed two times, I guess?
I think I remember an option to not refresh WebView... not sure whether it applies
to the current problem though.
Reported by nicolas.raoul
on 2014-02-28 07:41:01
Accepted
Also seeing the same (Android 5.0.1, ankidroid 2.3.2), but worth noting that this is
related to issue #1484
Reported by brownie.brown
on 2015-01-04 14:04:30
I am still experiencing this issue 3 years later it is quite annoying. I'd really like to use decks such as the popular "DoJG Core Random" both in ankidroid and anki desktop. Is there any workaround?
I've found someone who seems to have found a workaround but I can't seem to make it work (I'm not experienced with javascript) Workaround in question: https://yingtongli.me/blog/2015/03/15/random-question-generator-on-anki-using.html
There was another issue recently which led to the discovery (possible not for the first time) that AnkiDroid does not share the WebView between the front and the back during a flip - it loads a new one. The other issue used an HTML+javascript local storage workaround in order to persist / load state between the two webviews, and it was sufficient for that problem.
Which is just to say that there are workarounds even with the limitation of not maintaining WebView state across the note flip from front to back, but other than that no one has yet proposed a pull request that shares the webview between the two
Well that's a real bummer, it doesn't looks like it's gonna be fixed any time soon even though it seems like a basic feature ankidroid should have implemented long ago.
I guess I'm stuck with fields getting randomized two times, feels bad.
while I understand the frustration, just remember "ankidroid" is "us", I only started working on it myself a few months ago. I found a reference to the other person who overcame this limitation - has re-usable code and everything over on his github... https://github.com/ankidroid/Anki-Android/issues/4868#issuecomment-399002892
Don't get me wrong I genuinely admire the work being done here, I just get obsessed over things I can't solve and my poor coding skill surely is not helping.
@timrae I've read #493 and #4868 I'm not fully understanding the technical terms being used but does it mean that anki-canvas is preserving state between front and back?
Also here is the Anki deck I've been talking about if anyone is interested: https://drive.google.com/open?id=1FhJBal0-NBhQ85wsvWWocRnnSJZhPkMF
@epistularum that's exactly it - there are ways to preserve state even though AnkiDroid doesn't use the same WebView.
The anki-canvas repo linked in #4868 is a great piece of work but uses a lot of technology to get the job done and has a specific use case (an embeddable drawing object - no small thing, justifying all the ancillary technology).
The technique of state storage is the important thing here though - and that's in these lines if I'm reading correctly (the store declaration, and load + save methods): https://github.com/pigoz/anki-canvas/blob/master/src/touch.ts#L43
@mikehardy That's quite the particular use case indeed. If I were to use anki-canvas would it solve the issue of cards being randomized two times? Because I might switch to for a while anki-canvas if it's capable of doing so (assuming I know how to even install it).
The technique of state storage was also mentioned on the link with the workaround I posted up there (even though I'm too much of a monkey to even make it work on my own deck).
I'm sure the piece of code you just linked is quite remarkable but to be honest I have no understanding of its meaning.
For DoJG, you can use this template.
(Surprise: me)
@hssm I'd like to keep the current formatting of my cards, is that possible to achieve? https://drive.google.com/open?id=1FhJBal0-NBhQ85wsvWWocRnnSJZhPkMF
@epistularum
You just need to apply the formatting parts from your template to the one Houssam has given you. I hope you're not expecting someone to do all the work for you.
It's probably easier for you to pluck out the small portion of javascript that decides the random number (which is clearly delineated) and use that in your existing template. But yeah, you're on your own with that one.
@timrae Of course I'm not.
@timrae @hssm I'm really sorry, I have no knowledge whatsoever of coding. I managed to modify the code to only have one example phrase. I am now struggling on adding the corresponding example translation to the example phrase.
This is what I currently have: https://imgur.com/a/UUUxEVz
Ok I've found a workaround, I'll post the result here.
Here's what I managed to Frankenstein: https://drive.google.com/open?id=1bypaH2_JbWYnYQkIcplv5NAItpQki07q
Thanks a lot! Sorry to have bothered you.
Just a quick note on this one as I was in the area yesterday. We do re-use the WebView across card flips (and card reviews), so this is more possible than I thought. The state is still obliterated across card flips because we do a "loadDataFromBaseURL" (or similar, I might have the API call name not exact). In order to preserve state across card-flips I'd suppose we'd need to rewrite the DOM for the answer or somehow do the HTML differently. Or you could use cookies perhaps (its the same WebView). The solutions that work so far are using HTML5 local storage which is effective but maybe not fully necessary in other words.
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically
Closing in favor of #14302
Hi! A thumbs up for this (although seems it will be solved with the previously linked issue?) I need the persistence of an audiocontext for not having clicks and pops in a deck that contains musical loops.
Hi @Asmatzaile
Thanks!
In future, could you follow the link to the relevant issue and add a +1 emoji on the main post:
We don't have much free time as maintainers. Commenting 'this affects me too' without any additional information is a context switch for everyone watching the project
Thanks for taking an interest, the new reviewer will be in the dev settings in 2.19
Originally reported on Google Code with ID 1966
Reported by
Taoluo93
on 2014-01-15 13:14:25