Skip to content

Commit

Permalink
Fix for WebKit
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Jul 12, 2024
1 parent ef2ed93 commit 3005a44
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions static/js/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $(document).ready(function () {

function initializeQuestion() {
const currentKey = questionKeys[currentQuestionIndex];
const { source, translation } = questionsData[currentKey];
const translation = questionsData[currentKey] && questionsData[currentKey].translation;

console.log("当前题目索引:", currentQuestionIndex);
console.log("当前键名:", currentKey);
Expand Down Expand Up @@ -60,7 +60,7 @@ $(document).ready(function () {
function updateBoxes() {
const input = $inputBox.val();
const currentKey = questionKeys[currentQuestionIndex];
const { translation } = questionsData[currentKey];
const translation = questionsData[currentKey] && questionsData[currentKey].translation;

const translationSegments = getSegmentedText(translation);
const translationLength = translationSegments.length;
Expand Down Expand Up @@ -96,7 +96,9 @@ $(document).ready(function () {
const $summaryBody = $("#summaryBody").empty();

questionKeys.forEach((key) => {
const { source, translation } = questionsData[key];
const source = questionsData[key] && questionsData[key].source;
const translation = questionsData[key] && questionsData[key].translation;

$("<tr>").append(
$("<td>").text(source),
$("<td>").text(translation)
Expand All @@ -123,7 +125,7 @@ $(document).ready(function () {
const currentIndex = currentQuestionIndex;

const currentKey = questionKeys[currentIndex];
const { translation } = questionsData[currentKey];
const translation = questionsData[currentKey] && questionsData[currentKey].translation;

if (!isComposing) {
const translationLength = getSegmentedText(translation).length;
Expand All @@ -146,7 +148,6 @@ $(document).ready(function () {
}
});


// Initialize first question
initializeQuestion();
});

0 comments on commit 3005a44

Please sign in to comment.