Skip to content

Commit

Permalink
Updating JS from #185.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoFara committed Jan 7, 2024
1 parent e26d469 commit f477aad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
36 changes: 19 additions & 17 deletions do_test_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,16 @@ function do_test_prepare_ajax_test_area($selector, $selection, $count, $testtype

?>
<script type="text/javascript">
window.onload = (event) => {
var utterancecheckbox = document.getElementById('utterance-allowed')
function saveUtteranceSetting () {
const utterancechecked = JSON.parse(localStorage.getItem('review-utterance-allowed'));
const utterancecheckbox = document.getElementById('utterance-allowed');

var utterancechecked = JSON.parse(localStorage.getItem('utterance-allowed'));
utterancecheckbox.checked = utterancechecked;
utterancecheckbox.addEventListener('change', function () {
localStorage.setItem('utterance-allowed', utterancecheckbox.checked);
localStorage.setItem('review-utterance-allowed', utterancecheckbox.checked);
});
};
}

/**
* Get a new word test.
*/
Expand All @@ -516,6 +517,7 @@ function get_new_word()
}

$(get_new_word);
$(saveUtteranceSetting);
</script>

<p id="term-test" dir="<?php echo($lang['rtlScript'] ? 'rtl' : 'ltr'); ?>"
Expand Down Expand Up @@ -846,21 +848,21 @@ function do_test_footer($notyettested, $wrong, $correct)
title="Correct" alt="Correct" height="10" width="<?php echo $l_correct; ?>" />
</span>
<span style="margin-left: 15px; margin-right: 15px;">
<span title="Total number of tests" id="total_tests"><?php
echo $totaltests;
?></span>
<span title="Total number of tests" id="total_tests">
<?php echo $totaltests; ?>
</span>
=
<span class="todosty" title="Not yet tested" id="not-tested"><?php
echo $notyettested;
?></span>
<span class="todosty" title="Not yet tested" id="not-tested">
<?php echo $notyettested; ?>
</span>
+
<span class="donewrongsty" title="Wrong" id="wrong-tests"><?php
echo $wrong;
?></span>
<span class="donewrongsty" title="Wrong" id="wrong-tests">
<?php echo $wrong; ?>
</span>
+
<span class="doneoksty" title="Correct" id="correct-tests"><?php
echo $correct;
?></span>
<span class="doneoksty" title="Correct" id="correct-tests">
<?php echo $correct; ?>
</span>
</span>
</footer>
<?php
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ settings ([#119](https://github.com/HugoFara/lwt/issues/119)).
[#169](https://github.com/HugoFara/lwt/pull/169), closing discussion
[#141](https://github.com/HugoFara/lwt/discussions/141).
Many thanks to [@ProgramComputer](https://github.com/ProgramComputer)!
* On word review, the "Read words aloud" setting is now saved, PR [#185](https://github.com/HugoFara/lwt/pull/185).

### Changed

Expand Down
1 change: 1 addition & 0 deletions docs/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@ <h4>Added</h4>
<a href="https://github.com/HugoFara/lwt/pull/169">#169</a>, closing discussion
<a href="https://github.com/HugoFara/lwt/discussions/141">#141</a>.
Many thanks to <a href="https://github.com/ProgramComputer">@ProgramComputer</a>!</li>
<li>On word review, the "Read words aloud" setting is now saved, PR <a href="https://github.com/HugoFara/lwt/pull/185">#185</a>.</li>
</ul>
<h4>Changed</h4>
<ul>
Expand Down

0 comments on commit f477aad

Please sign in to comment.