mirror of
https://github.com/arcan1s/ffxivbis.git
synced 2025-07-15 06:45:49 +00:00
small static cleanup
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
<title>Best in slot</title>
|
||||
|
||||
<link href="{{ static('styles.css') }}" rel="stylesheet" type="text/css">
|
||||
<link href=""
|
||||
</head>
|
||||
<body>
|
||||
<h2>best in slot</h2>
|
||||
@ -67,6 +68,6 @@
|
||||
|
||||
{% include "export_to_csv.jinja2" %}
|
||||
{% include "root.jinja2" %}
|
||||
{% include "search.jinja2" %}
|
||||
<script src="/static/table_search.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,35 +1,2 @@
|
||||
<button onclick="exportTableToCsv('result.csv')">Export to csv</button>
|
||||
|
||||
<script type="application/javascript">
|
||||
function downloadCsv(csv, filename) {
|
||||
var csvFile = new Blob([csv], {"type": "text/csv"});
|
||||
|
||||
var downloadLink = document.createElement("a");
|
||||
downloadLink.download = filename;
|
||||
downloadLink.href = window.URL.createObjectURL(csvFile);
|
||||
downloadLink.style.display = "none";
|
||||
|
||||
document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
}
|
||||
|
||||
function exportTableToCsv(filename) {
|
||||
var table = document.getElementById("result");
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
|
||||
var csv = [];
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (rows[i].style.display === "none")
|
||||
continue
|
||||
var cols = rows[i].querySelectorAll("td, th");
|
||||
|
||||
var row = [];
|
||||
for (var j = 0; j < cols.length; j++)
|
||||
row.push(cols[j].innerText);
|
||||
|
||||
csv.push(row.join(","));
|
||||
}
|
||||
|
||||
downloadCsv(csv.join("\n"), filename);
|
||||
}
|
||||
</script>
|
||||
<script src="/static/table_export.js" type="text/javascript"></script>
|
||||
|
@ -55,6 +55,6 @@
|
||||
|
||||
{% include "export_to_csv.jinja2" %}
|
||||
{% include "root.jinja2" %}
|
||||
{% include "search.jinja2" %}
|
||||
<script src="/static/table_search.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -53,6 +53,6 @@
|
||||
|
||||
{% include "export_to_csv.jinja2" %}
|
||||
{% include "root.jinja2" %}
|
||||
{% include "search.jinja2" %}
|
||||
<script src="/static/table_search.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -55,6 +55,6 @@
|
||||
|
||||
{% include "export_to_csv.jinja2" %}
|
||||
{% include "root.jinja2" %}
|
||||
{% include "search.jinja2" %}
|
||||
<script src="/static/table_search.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,23 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
function searchTable() {
|
||||
var input = document.getElementById("search");
|
||||
var filter = input.value.toLowerCase();
|
||||
var table = document.getElementById("result");
|
||||
var tr = table.getElementsByTagName("tr");
|
||||
|
||||
// from 1 coz of header
|
||||
for (var i = 1; i < tr.length; i++) {
|
||||
var td = tr[i].getElementsByClassName("include_search");
|
||||
var display = "none";
|
||||
for (var j = 0; j < td.length; j++) {
|
||||
if (td[j].tagName.toLowerCase() === "td") {
|
||||
if (td[j].innerHTML.toLowerCase().indexOf(filter) > -1) {
|
||||
display = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tr[i].style.display = display;
|
||||
}
|
||||
}
|
||||
</script>
|
31
templates/static/table_export.js
Normal file
31
templates/static/table_export.js
Normal file
@ -0,0 +1,31 @@
|
||||
function downloadCsv(csv, filename) {
|
||||
var csvFile = new Blob([csv], {"type": "text/csv"});
|
||||
|
||||
var downloadLink = document.createElement("a");
|
||||
downloadLink.download = filename;
|
||||
downloadLink.href = window.URL.createObjectURL(csvFile);
|
||||
downloadLink.style.display = "none";
|
||||
|
||||
document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
}
|
||||
|
||||
function exportTableToCsv(filename) {
|
||||
var table = document.getElementById("result");
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
|
||||
var csv = [];
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (rows[i].style.display === "none")
|
||||
continue
|
||||
var cols = rows[i].querySelectorAll("td, th");
|
||||
|
||||
var row = [];
|
||||
for (var j = 0; j < cols.length; j++)
|
||||
row.push(cols[j].innerText);
|
||||
|
||||
csv.push(row.join(","));
|
||||
}
|
||||
|
||||
downloadCsv(csv.join("\n"), filename);
|
||||
}
|
21
templates/static/table_search.js
Normal file
21
templates/static/table_search.js
Normal file
@ -0,0 +1,21 @@
|
||||
function searchTable() {
|
||||
var input = document.getElementById("search");
|
||||
var filter = input.value.toLowerCase();
|
||||
var table = document.getElementById("result");
|
||||
var tr = table.getElementsByTagName("tr");
|
||||
|
||||
// from 1 coz of header
|
||||
for (var i = 1; i < tr.length; i++) {
|
||||
var td = tr[i].getElementsByClassName("include_search");
|
||||
var display = "none";
|
||||
for (var j = 0; j < td.length; j++) {
|
||||
if (td[j].tagName.toLowerCase() === "td") {
|
||||
if (td[j].innerHTML.toLowerCase().indexOf(filter) > -1) {
|
||||
display = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tr[i].style.display = display;
|
||||
}
|
||||
}
|
@ -46,6 +46,6 @@
|
||||
|
||||
{% include "export_to_csv.jinja2" %}
|
||||
{% include "root.jinja2" %}
|
||||
{% include "search.jinja2" %}
|
||||
<script src="/static/table_search.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user