Merge pull request 'Bug578-ChenChen' (#167) from Bug578-ChenChen into Alpha-snapshot20240618

Reviewed-on: #167
Bug578-ChenChen2
mrlan 2024-08-27 07:53:20 +08:00
commit 09beaff831
3 changed files with 25 additions and 1 deletions

View File

@ -171,4 +171,25 @@ function compareWord(first, second) {
return first.word < second.word ? -1 : 1;
}
return 0;
}
/* 生词csv导出 */
function exportToCSV() {
let csvContent = "data:text/csv;charset=utf-8,Word,Frequency\n";
let rows = document.querySelectorAll(".new-word");
rows.forEach(row => {
let word = row.querySelector("a.btn-light").innerText;
let freq = row.querySelector("a[title]").innerText;
csvContent += word + "," + freq + "\n";
});
let encodedUri = encodeURI(csvContent);
let link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "word_list.csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

BIN
app/static/wordfreqapp.db Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
@ -152,6 +152,8 @@
允许动态调整顺序
</label>
</p>
<!--添加导出按钮-->
<button class="btn btn-primary" onclick="exportToCSV()">导出</button>
<a name="aaa"></a>
<div class="word-container">
{% for x in lst3 %}
@ -171,6 +173,7 @@
{% endfor %}
</div>
<input id="selected-words2" type="hidden" value="{{ words }}">
{% endif %}
</div>
{{ yml['footer'] | safe }}