1
0
Fork 0
EnglishPal/app/static/js/word_operation.js

44 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

function familiar(index) {
2022-07-18 12:02:15 +08:00
let username = $("#username").text();
let word = $("#word_" + index).text();
let freq = $("#freq_" + index).text();
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/familiar",
2022-07-18 12:03:39 +08:00
success:function(response){
2022-07-18 12:02:15 +08:00
let new_freq = freq - 1;
if(new_freq <1) {
$("#p_" + index).remove();
} else {
$("#freq_" + index).text(new_freq);
}
}
});
}
function unfamiliar(index) {
2022-07-18 12:02:15 +08:00
let username = $("#username").text();
let word = $("#word_" + index).text();
let freq = $("#freq_" + index).text();
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/unfamiliar",
2022-07-18 12:03:39 +08:00
success:function(response){
2022-07-18 12:02:15 +08:00
let new_freq = parseInt(freq) + 1;
$("#freq_" + index).text(new_freq);
}
});
}
2022-07-18 12:14:31 +08:00
function delete_word(index) {
2022-07-18 12:02:15 +08:00
let username = $("#username").text();
let word = $("#word_" + index).text();
$.ajax({
type:"GET",
url:"/" + username + "/" + word + "/del",
2022-07-18 12:03:39 +08:00
success:function(response){
$("#p_" + index).remove();
}
});
2022-07-18 12:02:15 +08:00
}