@@ -782,30 +782,7 @@ function do_test_test_javascript_clickable($wo_record, $solution, $startSec, $en
782782 $ phoneticText = phonetic_reading ($ wo_record ['WoText ' ], $ abbr );
783783 ?>
784784 <script type="text/javascript">
785- const options_phonetic_reading = {
786- "text": word['word_text'],
787- "lang": <?php echo json_encode ((string ) $ abbr ); ?>
788-
789- };
790- $.getJSON(
791- 'api.php/v1/phonetic-reading?' + $.param(options_phonetic_reading)
792- ).done(function (data) {
793- if (data["phonetic_reading"]) {
794- $('.word').on('click', read_word);
795-
796- /**
797- * Read the word aloud
798- */
799- function read_word() {
800- if (('speechSynthesis' in window) &&
801- document.getElementById('utterance-allowed').checked) {
802- const text = data["phonetic_reading"];
803- const lang = <?php echo json_encode ($ abbr ); ?> ;
804- readRawTextAloud(text, lang);
805- }
806- }
807- }
808- });
785+
809786
810787 SOLUTION = <?php echo prepare_textdata_js ($ solution ); ?> ;
811788 WID = <?php echo $ wid ; ?> ;
@@ -939,7 +916,7 @@ function do_test_footer($notyettested, $wrong, $correct)
939916 */
940917function do_test_test_javascript ($ count )
941918{
942-
919+
943920 ?>
944921<script type="text/javascript">
945922 /**
@@ -976,18 +953,43 @@ function prepare_test_frames()
976953 * @param {number} tx_id transaction ID
977954 * @param {number} start_sec starting second
978955 * @param {number} end_sec ending second
956+ * @param {string} word_text word text
957+ * @param {string} word_lg_abbr Word ID
979958 * @param {string} solution Test answer
980959 * @param {string} group
981960 */
982- function insert_new_word(word_id,tx_id,start_sec,end_sec, solution, group) {
983-
961+ function insert_new_word(word_id,tx_id,start_sec,end_sec,word_text,word_lg_abbr, solution, group) {
962+
963+ const options_phonetic_reading = {
964+ "text": word_text,
965+ "lang": word_lg_abbr
966+
967+ };
968+ $.getJSON(
969+ 'api.php/v1/phonetic-reading?' + $.param(options_phonetic_reading)
970+ ).done(function (data) {
971+ if (data["phonetic_reading"]) {
972+ $('.word').on('click', read_word);
973+
974+ /**
975+ * Read the word aloud
976+ */
977+ function read_word() {
978+ if (('speechSynthesis' in window) &&
979+ document.getElementById('utterance-allowed').checked) {
980+ const text = data["phonetic_reading"];
981+ const lang = word_lg_abbr;
982+ readRawTextAloud(text, lang);
983+ }
984+ }
985+ }
986+ });
984987 const options_media_paths = {
985988 "id": tx_id
986989 };
987990 $.getJSON(
988991 'api.php/v1/media-files?' + $.param(options_media_paths)
989992 ).done(function (data) {
990- console.log(data["paths"])
991993 if (data["paths"]) {
992994 var MEDIA = data["paths"]
993995 sentenceaudio.src = MEDIA;
@@ -1051,7 +1053,7 @@ function (tomorrow_test) {
10511053 );
10521054 } else {
10531055 insert_new_word(
1054- current_test.word_id,current_test.txID,current_test.startSec,current_test.endSec,current_test.solution, current_test.group
1056+ current_test.word_id,current_test.txID,current_test.startSec,current_test.endSec,current_test.word_text,current_test.word_lg_abbr,current_test. solution, current_test.group
10551057 );
10561058 }
10571059 }
@@ -1101,7 +1103,7 @@ function do_test_finished(total_tests) {
11011103
11021104/**
11031105 * Do the main content of a test page.
1104- *
1106+ * Replaced by do_test_test_content_ajax()
11051107 * @global int $debug Show debug informations
11061108 *
11071109 * @return void
0 commit comments