Добавил фильтр
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,29 +10,39 @@
<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>
<tr> <thead>
<th>Name</th> <tr>
<th>Parts price</th> <th>Name</th>
<th>Set price</th> <th>Parts price</th>
<th>Difference</th> <th>Set price</th>
</tr> <th>Difference</th>
{{#each items}} </tr>
<tr> </thead>
<td class="name"> <tbody id="items">
<a href="{{this.link}}" target="_blank"> {{#each items}}
{{this.name}} <tr data-difference="{{this.difference}}">
</a> <td class="name">
</td> <a href="{{this.link}}" target="_blank">
<td>{{this.parts}}</td> {{this.name}}
<td>{{this.set}}</td> </a>
<td>{{this.difference}}</td> </td>
</tr> <td>{{this.parts}}</td>
{{/each}} <td>{{this.set}}</td>
<td>{{this.difference}}</td>
</tr>
{{/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;
} }