我很久以前从网上获得的这段代码适用于具有多个{{cloze}}的预制卡。它适用于Mac(台式机版)和AnkiDroid。但是无法在Anki(Ipad / Iphone)版本上使用。尝试了所有内容,但似乎无法使其正常工作。 ps我不是程序员。该代码是从在线站点复制而来的,我不记得从哪里来了。
试图通过一些JS编辑器运行它,我唯一得到的是 语法错误:未知令牌“>” 不知道那是什么意思。
前模板
<div id="kard">
<div class="tags">{{Tags}}</div>
<br>
<div id="mafld" style="display:none;">{{Text}}</div>
<div id="maclz">{{cloze:Text}}</div>
<br>
<style>
.clozure {
color: MediumSeaGreen;
}
</style>
<script>
var d = document;
clz = d.getElementById("maclz")
.innerHTML.split('');
fld = d.getElementById("mafld")
.innerHTML.split('');
tmp = '';
found = true;
cmn = [''];
c = -1; //
rez = [''];
z = 0;
j = 0;
for(var i = 0; i < clz.length; i++) {
if(clz[i] != fld[j]) {
if(clz[i] == '<') {
while(clz[i] != '>') {
rez[z] += clz[i++];
}
}
rez[z] += clz[i];
if(found) {
c++;
cmn[c] = '';
found = false;
} else {}
} else {
if(clz[i] == '<') {
while(clz[i] != '>') {
cmn[c] += clz[i++];
j++;
}
}
if(c < 0) {
c = 0;
}
cmn[c] += clz[i];
if(!found) {
z++;
rez[z] = '';
found = true;
} else {}
j++;
}
}
zax = (typeof(rez[i]) != "undefined" ? rez[i] : '')
.substr(0, 1) == '<';
if(clz[0] != fld[1]) {
for(i = 0; i < cmn.length; i++) {
tmp += (zax ? "" : '<span class="clozure">') +
(typeof(rez[i]) != "undefined" ? rez[i] : '') +
(zax ? "" : '</span>') + (typeof(cmn[i]) != "undefined" ? cmn[i] : '');
}
} else {
for(i = 0; i < cmn.length; i++) {
tmp += (typeof(cmn[i]) != "undefined" ? cmn[i] : '') +
(zax ? "" : '<span class="clozure">') +
(typeof(rez[i]) != "undefined" ? rez[i] : '') + (zax ? "" : "</span>");
}
}
document.getElementById("maclz").innerHTML = tmp;
</script>
</div>
样式模板
html { overflow: scroll; overflow-x: hidden; }
/* CONTAINER FOR YOUR CARDS */
#kard {
padding: 0px;
max-width: 900px; /* CHANGE CARD SIZE HERE */
margin: 0 auto; /* CENTERS THE CARD IN THE MIDDLE OF THE WINDOW */
word-wrap: break-word; /* BREAKS UP LONG WORKS */
}
/* APPLIES TO THE WHOLE CARD */
.card {
font-family: Menlo, baskerville, sans;
font-size: 16px; /* FONT SIZE */
text-align: center; /* ALIGN TEXT */
color: #D7DEE9; /* FONT COLOR */
line-height: 1.2em;
background-color: #333B45; /* BACKGROUND COLOR */
}
/* STYLE FOR CLOZE DELETIONS */
.cloze, .cloze b, .cloze u, .cloze i { text-align:left; font-weight: bold; color: MediumSeaGreen !important;}
/* STYLE FOR EXTRA PORTION ON BACK OF CARD */
#extra, #extra i { font-size: 15px; color:#D7DEE9; font-style: italic; text-align: left;}
/* STYLE TAGS TO APPEAR WHEN HOVERING OVER TOP OF CARD */
.tags {
color: #A6ABB9;
opacity: 1;
font-size: 10px;
width: 100%;
text-align: center;
text-transform: uppercase;
position: fixed;
padding: 0;
top:0;
right: 0;}
.tags:hover { opacity: 1; position: fixed;}
/* IMAGE STYLE */
img { display: block; max-width: 50%; max-height: none; margin-left: auto; margin: 10px auto 10px auto;}
img:active { width: 100%; }
tr {font-size: 12px; }
/* COLOR ACCENTS FOR BOLD-ITALICS-UNDERLINE */
b { color: #C695C6 !important; } /* BOLD STYLE */
u { text-decoration: none; color: #5EB3B3;} /* UNDERLINE STYLE */
i { color: IndianRed; } /* ITALICS STYLE */
a { color: LightGray !important; text-decoration: none; font-size: 10px; font-style: normal; } /* LINK STYLE */
/* ADJUSTMENT FOR MOBILE DEVICES */
.mobile .tags:hover { opacity: 1; position: relative;}
.mobile .card img:active { width: inherit; max-height: none;}
.card ul {
list-style-position:inside
margin-left: 0px;
padding: 0px;
}
.card ol {
list-style-position:inside
margin-left: 0px;
padding: 0px;
}
后模板
<div id="kard">
<div class="tags" id='tags'>{{Tags}}</div> <br>
<div id="wrapper" style="text-align: justify-center;">
<div id="centered" style="display: inline-block;">
{{cloze:Text}}</div></div>
<br><br><div id='extra'>{{Extra}}</div>
</div></div></div>
希望此功能可在ipad / iphone anki版本上使用。它会检测前面卡上的第二个或更多Cloze文本,并突出显示为绿色。
This is how the edit car looks like. It has 2 {{cloze}} texts.
This is what the Anki(ipad version) does. ←This is what I don't want