loganconnor44 / anki-templates Goto Github PK
View Code? Open in Web Editor NEWThis codebase is a solution for making Chinese study, through Anki, more enjoyable by making the flashcards beautiful.
License: GNU General Public License v3.0
This codebase is a solution for making Chinese study, through Anki, more enjoyable by making the flashcards beautiful.
License: GNU General Public License v3.0
Hey there,
ir really like your template and the style of the cards. They also have some nice features I'd like to use however I can not get this working...
My template is:
Frontside:
<script>if (!document.querySelector('#import-script')) {var script = document.createElement('script');script.setAttribute('id', 'import-script');script.setAttribute('type', 'module');script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/beautify-chinese-study/beautify-chinese-study.esm.js');document.body.appendChild(script);}</script>
<material-beautify-chinese-study simplified='{{text:simplified}}'
traditional='{{text:traditional}}'
numbered-pinyin='{{text:numberedPinyin}}'
meaning='{{text:meaning}}'
audio='{{sound}}'
card-type='meaning'
card-orientation='question'
preferred-phonic='pinyin' />
Backside:
<script>if (!document.querySelector('#import-script')) {var script = document.createElement('script');script.setAttribute('id', 'import-script');script.setAttribute('type', 'module');script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/beautify-chinese-study/beautify-chinese-study.esm.js');document.body.appendChild(script);}</script>
<material-beautify-chinese-study simplified='{{text:simplified}}'
traditional='{{text:traditional}}'
numbered-pinyin='{{text:numberedPinyin}}'
meaning='{{text:meaning}}'
audio='{{sound}}'
card-type='meaning'
card-orientation='answer'
preferred-phonic='pinyin' />
Style:
<style> /*desktop anki*/body {margin: 0;}/*ankidroid*/#content {margin: 0;}</style>
My fields are:
The card layout is working fine within the template editor but all actual cards (and their preview) remain black....
I'd really appriciate any help on this.
Awesome project!
When using AnkiDroid the character stroke animation is duplicated.
1.1.44
Anki Droid
<!--Styling may be placed in the Styling Anki tab - but for ease of use let's add it here only-->
<style>
/*desktop anki*/
body {
margin: 0;
}
/*ankidroid*/
#content {
margin: 0;
}
</style>
<script>
// if the custom element material-beautify-chinese-study is not a known element
//// manually create the html script to import the module so the browser has
//// the necessary logic to create element
if (!customElements.get('material-beautify-chinese-study')) {
console.log('Custom element does not exist - Creating script to pull it in');
var script = document.createElement('script');
script.setAttribute('id', 'import-script');
script.setAttribute('type', 'module');
script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/beautify-chinese-study/dist/beautify-chinese-study/beautify-chinese-study.esm.js');
document.body.appendChild(script);
} else {
console.log('Custom element exists.');
}
// locate the custom element material-beautify-chinese-study on the DOM
//// if it has data - remove everything
var beautify = document.querySelector('material-beautify-chinese-study');
if (beautify !== null) {
beautify.remove();
}
var beautify = document.createElement('material-beautify-chinese-study');
beautify.setAttribute('id', 'beautify');
beautify.setAttribute('simplified', '{{text:Simplified}}');
beautify.setAttribute('traditional', '{{text:Traditional}}');
beautify.setAttribute('simplified-sentence', '{{text:SentenceSimplified}}');
beautify.setAttribute('traditional-sentence', '{{text:SentenceTraditional}}');
// double quotes intentional do to the value containing a single quote
beautify.setAttribute('meaning', "{{text:Meaning}}");
beautify.setAttribute('card-type', 'writing');
beautify.setAttribute('card-orientation', 'question');
beautify.setAttribute('preferred-phonic', 'zhuyin');
// add the element to the DOM body
document.body.appendChild(beautify);
</script>
<!--Always add audio and keep it invisible-->
<div style="display:none;">{{Audio}}{{SentenceAudio}}</div>
<!--Styling may be placed in the Styling Anki tab - but for ease of use let's add it here only-->
<style>
/*desktop anki*/
body {
margin: 0;
}
/*ankidroid*/
#content {
margin: 0;
}
</style>
<script>
// if the custom element material-beautify-chinese-study is not a known element
//// manually create the html script to import the module so the browser has
//// the necessary logic to create element
if (!customElements.get('material-beautify-chinese-study')) {
var script = document.createElement('script');
script.setAttribute('id', 'import-script');
script.setAttribute('type', 'module');
script.setAttribute('src', 'https://cdn.jsdelivr.net/npm/beautify-chinese-study/dist/beautify-chinese-study/beautify-chinese-study.esm.js');
document.body.appendChild(script);
}
// since we are on the back of the card the custom element from the front of the card
//// may have been retained - in instances of AnkiDroid a new webview is created and
//// the element will need to be recreated from scratch
var beautify = document.querySelector('#beautify');
if (!beautify) {
// probably executing because on AnkiDroid
// recreating element from scratch
var beautify = document.createElement('material-beautify-chinese-study');
beautify.setAttribute('id', 'beautify');
beautify.setAttribute('simplified', '{{text:Simplified}}');
beautify.setAttribute('writing', '{{text:Simplified}}');
beautify.setAttribute('simplified-sentence', '{{text:SentenceSimplified}}');
beautify.setAttribute('traditional-sentence', '{{text:SentenceTraditional}}');
// double quotes intentional do to the value containing a single quote
beautify.setAttribute('meaning', "{{text:Meaning}}");
beautify.setAttribute('card-type', 'writing');
beautify.setAttribute('card-orientation', 'answer');
beautify.setAttribute('preferred-phonic', 'zhuyin');
document.body.appendChild(beautify);
} else {
// element already exist
// redefine the card type just for safe keeping
// redefine the card orientation to display the answer logic
beautify.setAttribute('card-type', 'writing');
beautify.setAttribute('card-orientation', 'answer');
}
</script>
<!--Always add audio and keep it invisible-->
<div style="display:none;">{{Audio}}{{SentenceAudio}}</div>
When using AnkiDroid the application flashes for a moment before each card (front and back) renders.
1.1.48
Anki Droid
Found Here
AnkiDroid handles the WebView different than Desktop Anki. It destroys and recreates it between each and every front and back card.
In Anki's styling section, I've added a completely black background so this will be rendered first. This does not prevent the flash of DOM, but it makes the flash less abrupt compared to a white background.
Storing or caching the web component, similar to how PWA operate. Maybe adding a service worker via StencilJs would be appropriate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.