add point, fix randomize logic
This commit is contained in:
1 parent
098608ec30
commit
9aef8fa77b
3 files changed
+111
-8
No files matched your search
@@ -14,18 +14,18 @@ import { nextTick, onMounted, ref, useTemplateRef } from "vue";
|
||||
|
||||
const mainEl = useTemplateRef("main");
|
||||
const sentences = ref<number[]>([]);
|
||||
const i_sentences = ref(NaN);
|
||||
const sentences_array_index = ref(NaN);
|
||||
|
||||
function nextSentence() {
|
||||
if (!mainEl.value) return;
|
||||
|
||||
const getShuffle = () => {
|
||||
const getCurrentSentenceIndex = () => {
|
||||
if (sentences.value.length <= 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (++i_sentences.value < sentences.value.length) {
|
||||
return i_sentences.value;
|
||||
if (++sentences_array_index.value < sentences.value.length) {
|
||||
return sentences.value[sentences_array_index.value];
|
||||
}
|
||||
|
||||
sentences.value = sentences.value
|
||||
@@ -33,14 +33,16 @@ function nextSentence() {
|
||||
.sort((a, b) => a.k - b.k)
|
||||
.map((a) => a.s);
|
||||
|
||||
return 0;
|
||||
sentences_array_index.value = 0;
|
||||
|
||||
return sentences.value[sentences_array_index.value];
|
||||
};
|
||||
|
||||
i_sentences.value = getShuffle();
|
||||
const currentSentenceIndex = getCurrentSentenceIndex();
|
||||
|
||||
mainEl.value.querySelectorAll("#sentence-quiz > ul > li").forEach((el, i) => {
|
||||
if (!(el instanceof HTMLElement)) return;
|
||||
el.style.display = i === i_sentences.value ? "" : "none";
|
||||
el.style.display = i === currentSentenceIndex ? "" : "none";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user