Додана сторінка "Стенд"
Додане повідомлення про оновлення застосунку Оновлен Service Worker Перероблен WebSocket APІ
This commit is contained in:
@@ -1,6 +1,53 @@
|
||||
const Stand_list = {
|
||||
list: [],
|
||||
init: async () => {
|
||||
let html = await fetch('/lib/pages/stand/list/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
|
||||
Stand_list.setHTML();
|
||||
|
||||
if (USER.possibilities.can_add_stand) {
|
||||
document.getElementById("buttons-list").style.display = "flex";
|
||||
document.getElementById("constructorButton").style.display = "";
|
||||
}
|
||||
},
|
||||
loadAPI: async function (url) {
|
||||
const uuid = localStorage.getItem("uuid");
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": uuid
|
||||
}
|
||||
});
|
||||
Stand_list.list = await response.json();
|
||||
return Stand_list.list;
|
||||
},
|
||||
setHTML: async function () {
|
||||
const block_list = document.getElementById('list');
|
||||
|
||||
const url = `${CONFIG.api}stand/list`;
|
||||
let list = this.list.length > 0 ? this.list : await this.loadAPI(url);
|
||||
|
||||
let html = "";
|
||||
for (const element of list) {
|
||||
html += this.renderCard({ element });
|
||||
}
|
||||
|
||||
block_list.innerHTML = html;
|
||||
},
|
||||
renderCard: ({ element }) => {
|
||||
return `
|
||||
<div class="card">
|
||||
<div class="contents">
|
||||
<div class="info">
|
||||
<div>
|
||||
<p>${element.title}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/stand/card/${element.id}" data-route></a>
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user