viikonpäivät milloin haetaan
This commit is contained in:
+36
-1
@@ -132,7 +132,22 @@
|
||||
document.getElementById('tila-badge').className = "badge bg-success";
|
||||
|
||||
const lista = document.getElementById('hakukohteet-lista');
|
||||
lista.innerHTML = data.hakukohteet.map((k, i) => `<tr><td>${k.jackett_haku}</td><td>${k.kohdekansio}</td><td class="text-end"><button onclick="poistaKohde(${i})" class="btn btn-link text-danger btn-sm p-0">Poista</button></td></tr>`).join('');
|
||||
lista.innerHTML = data.hakukohteet.map((k, i) => {
|
||||
const paivaNimet = ['Ma', 'Ti', 'Ke', 'To', 'Pe', 'La', 'Su'];
|
||||
const paivatTeksti = [0, 1, 2, 3, 4, 5, 6].map(p =>
|
||||
k.paivat.includes(p) ? `<span class="badge bg-info text-dark">${paivaNimet[p]}</span>` : `<span class="badge bg-light text-muted">${paivaNimet[p]}</span>`
|
||||
).join(' ');
|
||||
|
||||
return `<tr>
|
||||
<td>${k.jackett_haku}</td>
|
||||
<td>${k.kohdekansio}</td>
|
||||
<td>${paivatTeksti}</td>
|
||||
<td class="text-end">
|
||||
<button onclick="muokkaaKohdetta(${i})" class="btn btn-link btn-sm p-0 me-2 text-warning">Muokkaa</button>
|
||||
<button onclick="poistaKohde(${i})" class="btn btn-link text-danger btn-sm p-0">Poista</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
|
||||
const hakuTermi = document.getElementById('historia-haku').value.toLowerCase();
|
||||
const lokiDiv = document.getElementById('loki-sisalto');
|
||||
@@ -199,6 +214,26 @@
|
||||
document.getElementById('tyhjenna-loki-btn').addEventListener('click', () => fetch('/tyhjenna_loki', {method:'POST'}).then(() => paivitaNakyma()));
|
||||
|
||||
paivitaNakyma(); setInterval(paivitaNakyma, 5000);
|
||||
function muokkaaKohdetta(i) {
|
||||
fetch('/status')
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const kohde = data.hakukohteet[i];
|
||||
// Täytetään lomake hakukohteen tiedoilla
|
||||
document.getElementById('haku-sana').value = kohde.jackett_haku;
|
||||
document.getElementById('haku-kansio').value = kohde.kohdekansio;
|
||||
|
||||
// Päivitetään checkboxit
|
||||
[0, 1, 2, 3, 4, 5, 6].forEach(p => {
|
||||
const cb = document.getElementById('pv-' + p);
|
||||
if (cb) cb.checked = kohde.paivat.includes(p);
|
||||
});
|
||||
|
||||
// Vieritetään sivu takaisin ylös lomakkeeseen
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user