v0.0.1
This commit is contained in:
95
web/lib/pages/home/script.js
Normal file
95
web/lib/pages/home/script.js
Normal file
@@ -0,0 +1,95 @@
|
||||
const Home = {
|
||||
init: async () => {
|
||||
let html = await fetch('/lib/pages/home/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
|
||||
Home.house.setHTML();
|
||||
Home.homestead.setHTML();
|
||||
},
|
||||
house: {
|
||||
loadAPI: async function () {
|
||||
let uuid = localStorage.getItem("uuid");
|
||||
|
||||
const URL = `${CONFIG.api}houses/list?mode=sheep`;
|
||||
return await fetch(URL, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": uuid
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
},
|
||||
setHTML: async function () {
|
||||
let list = await Home.house.loadAPI();
|
||||
|
||||
list.sort((a, b) => b.id - a.id);
|
||||
|
||||
console.log(list);
|
||||
let block_house = document.getElementById('home-personal-territory-list')
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const element = list[i];
|
||||
|
||||
block_house.innerHTML += `
|
||||
<div class="card">
|
||||
<i style="background-image: url(https://sheep-service.com/cards/house/T${element.id}.webp);"></i>
|
||||
<div class="contents">
|
||||
<div class="group" style="background: ${colorGroup(element.group_id)}">
|
||||
<span>Група №${element.group_id}</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div>
|
||||
<p>${element.title} ${element.number}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/territory/card/house/${element.id}" data-route></a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
},
|
||||
homestead: {
|
||||
loadAPI: async function () {
|
||||
let uuid = localStorage.getItem("uuid");
|
||||
|
||||
const URL = `${CONFIG.api}homestead/list?mode=sheep`;
|
||||
return await fetch(URL, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": uuid
|
||||
}
|
||||
}).then((response) => response.json());
|
||||
},
|
||||
setHTML: async function () {
|
||||
let list = await Home.homestead.loadAPI();
|
||||
|
||||
list.sort((a, b) => b.id - a.id);
|
||||
|
||||
console.log(list);
|
||||
let block_homestead = document.getElementById('home-personal-territory-list')
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const element = list[i];
|
||||
|
||||
block_homestead.innerHTML += `
|
||||
<div class="card">
|
||||
<i style="background-image: url(https://sheep-service.com/cards/homestead/H${element.id}.webp);"></i>
|
||||
<div class="contents">
|
||||
<div class="group" style="background: ${colorGroup(element.group_id)}">
|
||||
<span>Група №${element.group_id}</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div>
|
||||
<p>${element.title} ${element.number}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/territory/card/homestead/${element.id}" data-route></a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user