Update
This commit is contained in:
parent
33d5d598a1
commit
efbb43cfad
|
@ -1,36 +1,4 @@
|
|||
let query = window.location.pathname;
|
||||
|
||||
if (query == "/news" || query == "/mastodon") {
|
||||
let tplUrl = 'json/mastodon-tpl.html';
|
||||
let response = await fetch(tplUrl);
|
||||
var tpl = "";
|
||||
let log = document.getElementById('log');
|
||||
log.innerHTML = "";
|
||||
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
|
||||
// Cancel the fetch request in 500ms
|
||||
setTimeout(() => controller.abort(), 500);
|
||||
|
||||
try {
|
||||
const response = await fetch(tplUrl, {signal});
|
||||
tpl = await response.text();
|
||||
|
||||
} catch(error) {
|
||||
// DOMException: The user aborted a request.
|
||||
console.log('Error: ', error);
|
||||
log.innerHTML = "<p>1) Ой всё сломалось :(</p>";
|
||||
}
|
||||
|
||||
if(!tpl) {
|
||||
log.innerHTML = "<p>2) Ой всё сломалось :(</p>";
|
||||
}
|
||||
// else {
|
||||
// log.innerHTML = tpl;
|
||||
// }
|
||||
|
||||
async function fetchData() {
|
||||
async function fetchData() {
|
||||
var log = document.getElementById('log');
|
||||
|
||||
var server_address = `techhub.social`;
|
||||
|
@ -100,11 +68,49 @@ if (query == "/news" || query == "/mastodon") {
|
|||
});
|
||||
log.innerHTML += `${post_tpl}<br>`;
|
||||
});
|
||||
}
|
||||
|
||||
async function openInNewTab(url) {
|
||||
window.open(url, '_blank').focus();
|
||||
}
|
||||
|
||||
async function getMastodonPage() {
|
||||
let tplUrl = 'json/mastodon-tpl.html';
|
||||
let response = await fetch(tplUrl);
|
||||
var tpl = "";
|
||||
let log = document.getElementById('log');
|
||||
|
||||
if (!log) {
|
||||
setTimeout(getMastodonPage, 1000);
|
||||
}
|
||||
|
||||
async function openInNewTab(url) {
|
||||
window.open(url, '_blank').focus();
|
||||
log.innerHTML = "";
|
||||
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
|
||||
// Cancel the fetch request in 500ms
|
||||
setTimeout(() => controller.abort(), 500);
|
||||
|
||||
try {
|
||||
const response = await fetch(tplUrl, {signal});
|
||||
tpl = await response.text();
|
||||
|
||||
} catch(error) {
|
||||
// DOMException: The user aborted a request.
|
||||
console.log('Error: ', error);
|
||||
log.innerHTML = "<p>1) Ой всё сломалось :(</p>";
|
||||
}
|
||||
|
||||
if(!tpl) {
|
||||
log.innerHTML = "<p>2) Ой всё сломалось :(</p>";
|
||||
}
|
||||
|
||||
fetchData();
|
||||
}
|
||||
|
||||
let query = window.location.pathname;
|
||||
|
||||
if (query == "/news" || query == "/mastodon") {
|
||||
getMastodonPage();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue