Add data download
This commit is contained in:
parent
2ac903553c
commit
9d3ce85cb4
10
kanken_online/static/data.js
Normal file
10
kanken_online/static/data.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const kanjiTSVButton = document.getElementById("kanji-tsv-download-button");
|
||||||
|
const kotobaTSVButton = document.getElementById("kotoba-tsv-download-button");
|
||||||
|
const databaseButton = document.getElementById("database-download-button");
|
||||||
|
|
||||||
|
for (const button of [kanjiTSVButton, kotobaTSVButton, databaseButton]) {
|
||||||
|
button.addEventListener("click", () => {
|
||||||
|
const fileName = button.getAttribute("data-filename");
|
||||||
|
location.assign(`/static/download/${fileName}`);
|
||||||
|
});
|
||||||
|
}
|
@ -1,12 +1,16 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="/static/data.js" defer></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<h1>{% block title %}{{ localize("data") }}{% endblock %}</h1>
|
<h1>{% block title %}{{ localize("data") }}{% endblock %}</h1>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<button id="kanji-tsv-download-button"> {{ localize("kanji_tsv_download") }}</button>
|
<button id="kanji-tsv-download-button" data-filename="kanji.tsv"> {{ localize("kanji_tsv_download") }}</button>
|
||||||
<button id="kotoba-tsv-download-button"> {{ localize("kotoba_tsv_download") }}</button>
|
<button id="kotoba-tsv-download-button" data-filename="kotoba.tsv"> {{ localize("kotoba_tsv_download") }}</button>
|
||||||
<button id="ankipkg-download-button"> {{ localize("ankipkg_download") }}</button>
|
<button id="ankipkg-download-button"> {{ localize("ankipkg_download") }}</button>
|
||||||
<button id="database-download-button"> {{ localize("database_download") }}</button>
|
<button id="database-download-button" data-filename="kanken.db"> {{ localize("database_download") }}</button>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user