smon/static/js/problems.mjs

67 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2024-05-01 20:01:43 +02:00
export class UI {
constructor() {
const showAcked = localStorage.getItem('show_acknowledged')
if (showAcked == 'true') {
document.getElementById('show-acked').checked = true
const list = document.getElementById('acknowledged-list')
list.classList.remove('hidden')
}
2024-07-04 16:29:53 +02:00
this.acknowledgeDisplay(showAcked == 'true')
2024-05-01 20:01:43 +02:00
2024-06-25 11:00:39 +02:00
const display = localStorage.getItem('problems_display')
if (display === null)
this.displayAreas()
else {
switch (display) {
case 'areas':
this.displayAreas()
break
case 'list':
this.displayList()
break
}
}
2024-05-01 20:01:43 +02:00
}
toggleAcknowledged(evt) {
2024-07-04 16:29:53 +02:00
this.acknowledgeDisplay(evt.target.checked)
}
acknowledgeDisplay(show) {
2024-05-01 20:01:43 +02:00
const list = document.getElementById('acknowledged-list')
2024-07-04 16:29:53 +02:00
const areaItems = document.querySelectorAll('.acked')
2024-05-01 20:01:43 +02:00
2024-07-04 16:29:53 +02:00
if (show) {
2024-05-01 20:01:43 +02:00
list.classList.remove('hidden')
2024-07-04 16:29:53 +02:00
areaItems.forEach(item=>item.classList.remove('hidden'))
2024-05-01 20:01:43 +02:00
localStorage.setItem('show_acknowledged', true)
} else {
list.classList.add('hidden')
2024-07-04 16:29:53 +02:00
areaItems.forEach(item=>item.classList.add('hidden'))
2024-05-01 20:01:43 +02:00
localStorage.setItem('show_acknowledged', false)
}
}
2024-05-28 12:56:35 +02:00
2024-07-04 15:14:24 +02:00
selectCurrent() {
location.href = '/problems?selection=current'
}
selectAll() {
location.href = '/problems?selection=all'
}
2024-05-28 12:56:35 +02:00
displayList() {
document.querySelector('.display-list').classList.remove('hidden')
document.querySelector('.display-areas').classList.add('hidden')
2024-06-25 11:00:39 +02:00
localStorage.setItem('problems_display', 'list')
document.getElementById('display-list').setAttribute('checked', 'checked')
2024-05-28 12:56:35 +02:00
}
2024-06-25 11:00:39 +02:00
2024-05-28 12:56:35 +02:00
displayAreas() {
document.querySelector('.display-list').classList.add('hidden')
document.querySelector('.display-areas').classList.remove('hidden')
2024-06-25 11:00:39 +02:00
localStorage.setItem('problems_display', 'areas')
document.getElementById('display-table').setAttribute('checked', 'checked')
2024-05-28 12:56:35 +02:00
}
2024-05-01 20:01:43 +02:00
}