diff --git a/public/assets/js/script.js b/public/assets/js/script.js
index a037286..09ec8cd 100644
--- a/public/assets/js/script.js
+++ b/public/assets/js/script.js
@@ -9,6 +9,9 @@ function hidePage() {
document.getElementById("body").style.display = "none";
}
+function openInNewTab(url) {
+ window.open(url, '_blank').focus();
+}
function showFullscreenImage(element) {
imageSrc = element.getAttribute('src');
@@ -40,6 +43,29 @@ function ready() {
document.addEventListener("DOMContentLoaded", ready);
+const log = document.getElementById('log');
+log.innerHTML = "";
+
+async function fetchData() {
+
+ var serverAddress = "techhub.social";
+
+ const response = await fetch(`https://${serverAddress}/api/v1/accounts/111518136987654656/statuses`);
+
+ const data = await response.json();
+
+ data.forEach(obj => {
+ Object.entries(obj).forEach(([key, value]) => {
+
+ if (key == "id") {
+ log.innerHTML = log.innerHTML + `` + '
';
+ }
+
+ });
+ log.innerHTML = log.innerHTML + '
';
+ });
+}
+
// Загрузка HTML из файла при загрузке URL
async function bodyFetch(url) {
@@ -55,6 +81,7 @@ async function bodyFetch(url) {
if (response.ok) { // если HTTP-статус в диапазоне 200-299
// получаем тело ответа (см. про этот метод ниже)
let text = await response.text();
+ if (tplUrl == 'news.tpl.html') {fetchData();}
body.innerHTML = text;
} else {
body.innerHTML = "Ой всё сломалось :(";
@@ -63,32 +90,32 @@ async function bodyFetch(url) {
let query = window.location.pathname;
switch (query) {
-case "/news":
- bodyFetch(query);
- break;
+ case "/news":
+ bodyFetch(query);
+ break;
-case "/overview":
- bodyFetch(query);
- break;
+ case "/overview":
+ bodyFetch(query);
+ break;
-case "/download":
- bodyFetch(query);
- break;
+ case "/download":
+ bodyFetch(query);
+ break;
-case "/donate":
- bodyFetch(query);
- break;
+ case "/donate":
+ bodyFetch(query);
+ break;
-case "/cooperation":
- bodyFetch(query);
- break;
+ case "/cooperation":
+ bodyFetch(query);
+ break;
-case "/about":
- bodyFetch(query);
- break;
+ case "/about":
+ bodyFetch(query);
+ break;
-default:
- bodyFetch();
+ default:
+ bodyFetch();
}
@@ -115,6 +142,7 @@ let fetchPage = async function(evt) {
try {
const response = await fetch(tplUrl, { signal });
text = await response.text();
+ if (tplUrl == 'news.tpl.html') {fetchData();}
} catch (error) {
// DOMException: The user aborted a request.
console.log('Error: ', error)
diff --git a/public/assets/js/toot.js b/public/assets/js/toot.js
deleted file mode 100644
index f9e6873..0000000
--- a/public/assets/js/toot.js
+++ /dev/null
@@ -1,28 +0,0 @@
-const log = document.getElementById('log');
-log.innerHTML = "";
-
-async function fetchData() {
-
- var serverAddress = "techhub.social";
-
- const response = await fetch(`https://${serverAddress}/api/v1/accounts/111518136987654656/statuses`);
-
- const data = await response.json();
-
- data.forEach(obj => {
- Object.entries(obj).forEach(([key, value]) => {
-
- if (key == "id") {
- log.innerHTML = log.innerHTML + `` + '
';
- }
-
- });
- log.innerHTML = log.innerHTML + '
';
- });
-}
-
-function openInNewTab(url) {
- window.open(url, '_blank').focus();
-}
-
-document.addEventListener("DOMContentLoaded", fetchData);
diff --git a/public/news.tpl.html b/public/news.tpl.html
index f44742a..bf2b244 100644
--- a/public/news.tpl.html
+++ b/public/news.tpl.html
@@ -173,8 +173,6 @@
-
-