Add data download

This commit is contained in:
Kiril Kovachev 2024-10-16 12:09:03 +01:00
parent 2ac903553c
commit 9d3ce85cb4
2 changed files with 17 additions and 3 deletions

View 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}`);
});
}

View File

@ -1,12 +1,16 @@
{% extends 'base.html' %}
{% block scripts %}
<script src="/static/data.js" defer></script>
{% endblock %}
{% block header %}
<h1>{% block title %}{{ localize("data") }}{% endblock %}</h1>
{% endblock %}
{% block content %}
<button id="kanji-tsv-download-button"> {{ localize("kanji_tsv_download") }}</button>
<button id="kotoba-tsv-download-button"> {{ localize("kotoba_tsv_download") }}</button>
<button id="kanji-tsv-download-button" data-filename="kanji.tsv"> {{ localize("kanji_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="database-download-button"> {{ localize("database_download") }}</button>
<button id="database-download-button" data-filename="kanken.db"> {{ localize("database_download") }}</button>
{% endblock %}