diff --git a/public/assets/js/mastodon.js b/public/assets/js/mastodon.js index 1c0392c..d4d8874 100644 --- a/public/assets/js/mastodon.js +++ b/public/assets/js/mastodon.js @@ -1,4 +1,4 @@ -async function fetchData() { +async function fetchData(log) { var log = document.getElementById('log'); var server_address = `techhub.social`; @@ -72,12 +72,17 @@ async function fetchData() { async function openInNewTab(url) { window.open(url, '_blank').focus(); } + +async function getLog() { + let log = document.getElementById('log'); + if(log == null) { + setTimeout(getLog, 1000); + } else { + getMastodonPage(); + } +} async function getMastodonPage() { let log = document.getElementById('log'); - if (log == null) { - setTimeout(getMastodonPage, 1000); - return; - } let tplUrl = 'json/mastodon-tpl.html'; let response = await fetch(tplUrl); @@ -105,11 +110,11 @@ async function getMastodonPage() { log.innerHTML = "

2) Ой всё сломалось :(

"; } - fetchData(); + fetchData(log); } let query = window.location.pathname; if (query == "/news" || query == "/mastodon") { - getMastodonPage(); + getLog(); }