const Stand_list = { list: [], renderIndex: 0, init: async () => { let html = await fetch('/lib/pages/stand/list/index.html').then((response) => response.text()); app.innerHTML = html; Stand_list.renderIndex = 0; 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 = document.getElementById('list'); const null_list = document.getElementById('null-list'); const load_list = document.getElementById('load-list'); null_list.setAttribute("data-visible", "false"); load_list.setAttribute("data-visible", "true"); const url = `${CONFIG.api}stand/list`; let list = this.list.length > 0 ? this.list : await this.loadAPI(url); if (list.length == 0) { null_list.setAttribute("data-visible", "true"); load_list.setAttribute("data-visible", "false"); return; } else { null_list.setAttribute("data-visible", "false"); load_list.setAttribute("data-visible", "false"); let html = ""; for (const element of list) { html += this.renderCard({ element }); } block.innerHTML = html; } }, renderCard: ({ element }) => { const imagesList = ['1.png', '5.png', '8.png', '7.png', '2.png', '3.png', '4.png', '6.png']; // const randomImage = images[Math.floor(Math.random() * images.length)]; const image = imagesList[Stand_list.renderIndex % imagesList.length]; Stand_list.renderIndex++; const editor = USER.possibilities.can_add_stand ? `` : ``; return `
`; } }