forked from mrlan/EnglishPal
Merge pull request '[Refactor]: Remove loop.index0, as it is hard to understand.' (#52) from Bug400-QiuZhonghui-Refactor into master
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/52Hui-EscapeUserInput
commit
028e2f9d56
|
@ -1,43 +1,43 @@
|
|||
function familiar(index) {
|
||||
function familiar(theWord) {
|
||||
let username = $("#username").text();
|
||||
let word = $("#word_" + index).text();
|
||||
let freq = $("#freq_" + index).text();
|
||||
let word = $("#word_" + theWord).text();
|
||||
let freq = $("#freq_" + theWord).text();
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"/" + username + "/" + word + "/familiar",
|
||||
success:function(response){
|
||||
let new_freq = freq - 1;
|
||||
if(new_freq <1) {
|
||||
$("#p_" + index).remove();
|
||||
$("#p_" + theWord).remove();
|
||||
} else {
|
||||
$("#freq_" + index).text(new_freq);
|
||||
$("#freq_" + theWord).text(new_freq);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function unfamiliar(index) {
|
||||
function unfamiliar(theWord) {
|
||||
let username = $("#username").text();
|
||||
let word = $("#word_" + index).text();
|
||||
let freq = $("#freq_" + index).text();
|
||||
let word = $("#word_" + theWord).text();
|
||||
let freq = $("#freq_" + theWord).text();
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"/" + username + "/" + word + "/unfamiliar",
|
||||
success:function(response){
|
||||
let new_freq = parseInt(freq) + 1;
|
||||
$("#freq_" + index).text(new_freq);
|
||||
$("#freq_" + theWord).text(new_freq);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_word(index) {
|
||||
function delete_word(theWord) {
|
||||
let username = $("#username").text();
|
||||
let word = $("#word_" + index).text();
|
||||
let word = $("#word_" + theWord).text();
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
url:"/" + username + "/" + word + "/del",
|
||||
success:function(response){
|
||||
$("#p_" + index).remove();
|
||||
$("#p_" + theWord).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@
|
|||
{% if session.get('thisWord') == x[0] and session.get('time') == 1 %}
|
||||
<a name="aaa"></a>
|
||||
{% endif %}
|
||||
<p id='p_{{ loop.index0 }}' class="new-word" >
|
||||
<a id="word_{{ loop.index0 }}" class="btn btn-light" href='http://youdao.com/w/eng/{{ word }}/#keyfrom=dict2.index'
|
||||
<p id='p_{{ word }}' class="new-word" >
|
||||
<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_{{ loop.index0 }}" title="{{ word }}">{{ freq }}</a> )
|
||||
<a class="btn btn-success" onclick="familiar({{ loop.index0 }})" role="button">熟悉</a>
|
||||
<a class="btn btn-warning" onclick="unfamiliar({{ loop.index0 }})" role="button">不熟悉</a>
|
||||
<a class="btn btn-danger" onclick="delete_word({{ loop.index0 }})" role="button">删除</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>
|
||||
</p>
|
||||
{% endfor %}
|
||||
<input id="selected-words2" type="hidden" value="{{ words }}">
|
||||
|
|
Loading…
Reference in New Issue