Merge pull request 'Fix Bug 501. The key fix is the first line in funciton wordTemplate() from word_operation.js, i.e., using double quotes instead of single quotes.' (#183) from Bug501-Hui into Alpha-snapshot20240618

Reviewed-on: #183
Bug478-Hui
mrlan 2024-09-04 15:17:23 +08:00
commit fe1d4c29ff
2 changed files with 17 additions and 13 deletions

View File

@ -1,7 +1,9 @@
function familiar(theWord) {
let username = $("#username").text();
let word = $("#word_" + theWord).text();
let freq = $("#freq_" + theWord).text();
let word = document.getElementById(`word_${theWord}`).innerText;
let freq = document.getElementById(`freq_${theWord}`).innerText;
console.log(theWord);
console.log(word);
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/familiar",
@ -27,8 +29,10 @@ function familiar(theWord) {
function unfamiliar(theWord) {
let username = $("#username").text();
let word = $("#word_" + theWord).text();
let freq = $("#freq_" + theWord).text();
let word = document.getElementById(`word_${theWord}`).innerText;
let freq = document.getElementById(`freq_${theWord}`).innerText;
console.log(theWord);
console.log(word);
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/unfamiliar",
@ -95,14 +99,14 @@ function parseWord(element) {
*/
function wordTemplate(word) {
// 这个模板应当与 templates/userpage_get.html 中的 <p id='p_${word.word}' class="new-word" > ... </p> 保持一致
return `<p id='p_${word.word}' class="new-word" >
return `<p id="p_${word.word}" class="new-word" >
<a id="word_${word.word}" class="btn btn-light" href='http://youdao.com/w/eng/${word.word}/#keyfrom=dict2.index'
role="button">${word.word}</a>
( <a id="freq_${word.word}" title="${word.word}">${word.freq}</a> )
<a class="btn btn-success" onclick="familiar('${word.word}')" role="button">熟悉</a>
<a class="btn btn-warning" onclick="unfamiliar('${word.word}')" role="button">不熟悉</a>
<a class="btn btn-danger" onclick="delete_word('${word.word}')" role="button">删除</a>
<a class="btn btn-info" onclick="read_word('${word.word}')" role="button">朗读</a>
<a class="btn btn-success" onclick=familiar("${word.word}") role="button">熟悉</a>
<a class="btn btn-warning" onclick=unfamiliar("${word.word}") role="button">不熟悉</a>
<a class="btn btn-danger" onclick=delete_word("${word.word}") role="button">删除</a>
<a class="btn btn-info" onclick=read_word("${word.word}") role="button">朗读</a>
<a class="btn btn-primary" onclick="addNote('{{ word }}'); saveNote('{{ word }}')" role="button">笔记</a> <!-- Modify to call addNote and then saveNote -->
<input type="text" id="note_{{ word }}" class="note-input" placeholder="输入笔记内容" style="display:none;" oninput="saveNote('{{ word }}')"> <!-- Added oninput event -->
</p>`;

View File

@ -179,10 +179,10 @@
<a id="word_{{ word }}" class="btn btn-light" href='http://youdao.com/w/eng/{{ word }}/#keyfrom=dict2.index'
role="button">{{ word }}</a>
( <a id="freq_{{ word }}" title="{{ word }}">{{ freq }}</a> )
<a class="btn btn-success" onclick="familiar('{{ word }}')" role="button">熟悉</a>
<a class="btn btn-warning" onclick="unfamiliar('{{ word }}')" role="button">不熟悉</a>
<a class="btn btn-danger" onclick="delete_word('{{ word }}')" role="button">删除</a>
<a class="btn btn-info" onclick="read_word('{{ word }}')" role="button">朗读</a>
<a class="btn btn-success" onclick=familiar("{{ word }}") role="button">熟悉</a>
<a class="btn btn-warning" onclick=unfamiliar("{{ word }}") role="button">不熟悉</a>
<a class="btn btn-danger" onclick=delete_word("{{ word }}") role="button">删除</a>
<a class="btn btn-info" onclick=read_word("{{ word }}") role="button">朗读</a>
<a class="btn btn-primary" onclick="addNote('{{ word }}'); saveNote('{{ word }}')" role="button">笔记</a> <!-- Modify to call addNote and then saveNote -->
<input type="text" id="note_{{ word }}" class="note-input" placeholder="输入笔记内容" style="display:none;" oninput="saveNote('{{ word }}')"> <!-- Added oninput event -->
</p>