mirror of
https://github.com/anthonyaxenov/iptv.git
synced 2024-11-24 22:34:34 +00:00
Мелочи по визуалу
This commit is contained in:
parent
585392b295
commit
ed169220c2
@ -1,49 +0,0 @@
|
|||||||
document.querySelectorAll('tr.pls').forEach((tr) => {
|
|
||||||
const id = tr.attributes['data-playlist-id'].value
|
|
||||||
const xhr = new XMLHttpRequest()
|
|
||||||
xhr.responseType = 'json'
|
|
||||||
xhr.timeout = 60000 // ms = 1 min
|
|
||||||
let el_status = tr.querySelector('span.status')
|
|
||||||
let el_count = tr.querySelector('td.count')
|
|
||||||
xhr.onreadystatechange = () => {
|
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
||||||
console.log('[' + id + '] DONE', xhr.response)
|
|
||||||
el_status.classList.remove('bg-secondary')
|
|
||||||
el_status.innerText = xhr.response.status
|
|
||||||
el_count.innerText = xhr.response.count ?? 0
|
|
||||||
switch (xhr.response.status) {
|
|
||||||
case 'online':
|
|
||||||
el_status.classList.add('bg-success')
|
|
||||||
break
|
|
||||||
case 'timeout':
|
|
||||||
el_status.classList.add('bg-warning')
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
el_status.classList.add('bg-danger')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if (xhr.response.error) {
|
|
||||||
el_status.title = '[' + xhr.response.error.code + '] ' + xhr.response.error.message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.onerror = () => {
|
|
||||||
console.log('[' + id + '] ERROR', xhr.response)
|
|
||||||
el_status.classList.add('bg-danger')
|
|
||||||
el_status.innerText = 'error'
|
|
||||||
el_count.innerText = '-'
|
|
||||||
}
|
|
||||||
xhr.onabort = () => {
|
|
||||||
console.log('[' + id + '] ABORTED', xhr.response)
|
|
||||||
el_status.classList.add('bg-secondary')
|
|
||||||
el_count.innerText = '-'
|
|
||||||
}
|
|
||||||
xhr.ontimeout = () => {
|
|
||||||
console.log('[' + id + '] TIMEOUT', xhr.response)
|
|
||||||
el_status.classList.add('bg-secondary')
|
|
||||||
el_status.innerText = 'timeout'
|
|
||||||
el_count.innerText = '-'
|
|
||||||
}
|
|
||||||
xhr.open('GET', '/' + id + '/json')
|
|
||||||
xhr.send()
|
|
||||||
})
|
|
@ -103,7 +103,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="badge small text-dark bg-success">online</span>
|
<span class="badge small text-dark bg-success">online</span>
|
||||||
Плейлист, возможно, активен.
|
Плейлист, возможно, активен. <i>Если каналов 0, значит, вероятно, источник поставил
|
||||||
|
редирект с плейлиста на куда ему вздумалось. То есть плейлист, наверное, отсутствует
|
||||||
|
и, возможно, больше никогда не появится по текущему адресу.</i>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span class="badge small text-dark bg-warning">timeout</span>
|
<span class="badge small text-dark bg-warning">timeout</span>
|
||||||
|
@ -75,5 +75,55 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
<script src="{{ base_url('js/checker.js') }}"></script>
|
<script>
|
||||||
|
document.querySelectorAll('tr.pls').forEach((tr) => {
|
||||||
|
const id = tr.attributes['data-playlist-id'].value
|
||||||
|
const xhr = new XMLHttpRequest()
|
||||||
|
xhr.responseType = 'json'
|
||||||
|
xhr.timeout = 60000 // ms = 1 min
|
||||||
|
let el_status = tr.querySelector('span.status')
|
||||||
|
let el_count = tr.querySelector('td.count')
|
||||||
|
xhr.onreadystatechange = () => {
|
||||||
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||||
|
console.log('[' + id + '] DONE', xhr.response)
|
||||||
|
el_status.classList.remove('bg-secondary')
|
||||||
|
el_status.innerText = xhr.response.status
|
||||||
|
el_count.innerText = xhr.response?.count ?? 0
|
||||||
|
switch (xhr.response.status) {
|
||||||
|
case 'online':
|
||||||
|
el_status.classList.add('bg-success')
|
||||||
|
break
|
||||||
|
case 'timeout':
|
||||||
|
el_status.classList.add('bg-warning')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
el_status.classList.add('bg-danger')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (xhr.response.error) {
|
||||||
|
el_status.title = '[' + xhr.response.error.code + '] ' + xhr.response.error.message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.onerror = () => {
|
||||||
|
console.log('[' + id + '] ERROR', xhr.response)
|
||||||
|
el_status.classList.add('bg-danger')
|
||||||
|
el_status.innerText = 'error'
|
||||||
|
el_count.innerText = 0
|
||||||
|
}
|
||||||
|
xhr.onabort = () => {
|
||||||
|
console.log('[' + id + '] ABORTED', xhr.response)
|
||||||
|
el_status.classList.add('bg-secondary')
|
||||||
|
el_count.innerText = 0
|
||||||
|
}
|
||||||
|
xhr.ontimeout = () => {
|
||||||
|
console.log('[' + id + '] TIMEOUT', xhr.response)
|
||||||
|
el_status.classList.add('bg-secondary')
|
||||||
|
el_status.innerText = 'timeout'
|
||||||
|
el_count.innerText = 0
|
||||||
|
}
|
||||||
|
xhr.open('GET', '/' + id + '/json')
|
||||||
|
xhr.send()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user