Добавил фильтр
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> <body>
<h1>Warframe Market Gaps</h1> <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> <table>
<thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Parts price</th> <th>Parts price</th>
<th>Set price</th> <th>Set price</th>
<th>Difference</th> <th>Difference</th>
</tr> </tr>
</thead>
<tbody id="items">
{{#each items}} {{#each items}}
<tr> <tr data-difference="{{this.difference}}">
<td class="name"> <td class="name">
<a href="{{this.link}}" target="_blank"> <a href="{{this.link}}" target="_blank">
{{this.name}} {{this.name}}
@@ -29,10 +36,13 @@
<td>{{this.difference}}</td> <td>{{this.difference}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody>
</table> </table>
<div class="timestamp"> <div class="timestamp">
Generated at {{timestamp}} Generated at {{timestamp}}
</div> </div>
<script src="index.js"></script>
</body> </body>
</html> </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; text-align: left;
} }
tr:nth-child(even) {
background: rgb(240, 242, 243);
}
td { td {
padding: 2px 16px; padding: 2px 16px;
} }