Добавил фильтр
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-19 21:36:42 +03:00
parent 619459fedd
commit 59aa29833c
3 changed files with 42 additions and 22 deletions

View File

@@ -10,15 +10,22 @@
<body>
<h1>Warframe Market Gaps</h1>
<label for="minDifference">Filter by difference</label>
<input type="range" min="1" max="60" value="1" id="minDifference">
<span id="filterValue">1</span>
<table>
<thead>
<tr>
<th>Name</th>
<th>Parts price</th>
<th>Set price</th>
<th>Difference</th>
</tr>
</thead>
<tbody id="items">
{{#each items}}
<tr>
<tr data-difference="{{this.difference}}">
<td class="name">
<a href="{{this.link}}" target="_blank">
{{this.name}}
@@ -29,10 +36,13 @@
<td>{{this.difference}}</td>
</tr>
{{/each}}
</tbody>
</table>
<div class="timestamp">
Generated at {{timestamp}}
</div>
<script src="index.js"></script>
</body>
</html>

14
public/index.js Normal file
View File

@@ -0,0 +1,14 @@
const slider = document.getElementById('minDifference')
slider.addEventListener('input', function (event) {
const table = document.getElementById('items')
Array.from(table.children).forEach(row => {
if (row.dataset.difference < Number(event.target.value)) {
row.style.display = 'none'
} else {
row.style.display = 'table-row'
}
})
document.getElementById('filterValue').innerText = event.target.value
})

View File

@@ -16,10 +16,6 @@ tr {
text-align: left;
}
tr:nth-child(even) {
background: rgb(240, 242, 243);
}
td {
padding: 2px 16px;
}