From f5c72c32eb50df603891a3accf053c728b348452 Mon Sep 17 00:00:00 2001 From: ale Date: Tue, 19 Nov 2024 02:17:17 +0100 Subject: [PATCH] api response Signed-off-by: ale --- public/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/main.js b/public/main.js index 5e05590..5486e83 100644 --- a/public/main.js +++ b/public/main.js @@ -37,8 +37,8 @@ document.addEventListener('DOMContentLoaded', function () { if (content && content.length > 0) { loading() fetch('/api/block_count/' + content).then(async function (result) { - var res = await result.text() - if (res?.length > 0) { + var res = await result.text() || '' + if (res.split('\n').length > 0) { document.getElementById('blockcount').innerText = res.split('\n').length document.getElementById('blockinstance').innerText = 'ing ' + content document.getElementById('blocktook').innerText = '' @@ -173,8 +173,8 @@ document.addEventListener('DOMContentLoaded', function () { var li = document.createElement('li') li.innerHTML = r.domain + (r.blocks ? ' - ' + r.blocks + ' blocks' : '') + (r.nodeinfo ? ' ' : '') - + (r.api.title ? '

' + r.api.title + ' - ' + r.api.uri + '
' - + (r.last ? 'Last update: ' + (new Date(r.last)).toLocaleString() + '
' : '') + + (r.last ? '
' + 'Last update: ' + (new Date(r.last)).toLocaleString() : '') + + (r.api?.title ? '

' + r.api.title + ' - ' + r.api.uri + '
' + (r.api.email ? 'Email: ' + r.api.email + '
' : '') + 'Registration: ' + (r.api.registrations ? 'open' : 'closed') + ' - Version: ' + r.api.version + '
' + (r.api.stats ? 'Users: ' + r.api.stats.user_count + ' - Statuses: ' + r.api.stats.status_count + ' - Domains: ' + r.api.stats.domain_count + '
' : '')