v1.0.0
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const Stand = {
|
||||
schedule: [],
|
||||
init: async () => {
|
||||
let html = await fetch('/lib/pages/stand/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
@@ -33,6 +34,90 @@ const Stand = {
|
||||
});
|
||||
}
|
||||
|
||||
generateAvailableDates();
|
||||
// generateAvailableDates();
|
||||
Stand.generator();
|
||||
},
|
||||
generator: () => {
|
||||
let block_schedule = document.getElementById('stand-schedule');
|
||||
|
||||
let html = "";
|
||||
|
||||
let stand = {
|
||||
id: 1,
|
||||
title: "Універсам",
|
||||
geo: { lat: 0, lng: 0 },
|
||||
hour_start: 9,
|
||||
hour_end: 14,
|
||||
quantity_sheep: 4,
|
||||
week_days: [0, 2, 4, 6],
|
||||
processing_time: 0.5,
|
||||
updated_at: null
|
||||
}
|
||||
|
||||
Stand.schedule = [];
|
||||
|
||||
// Кількість годин служіння
|
||||
let stand_length = (stand.hour_end - stand.hour_start) / stand.processing_time;
|
||||
|
||||
for (let z = 0; z < stand.week_days.length; z++) {
|
||||
Stand.schedule.push([]);
|
||||
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() + stand.week_days[z]);
|
||||
let dayName = date.toLocaleDateString('uk-UA', { weekday: 'long' });
|
||||
|
||||
html += `
|
||||
<div class="block-day" id="day-${z}">
|
||||
<h3>${date.toLocaleDateString()} • ${dayName}</h3>
|
||||
`;
|
||||
|
||||
let stand_date = 1 + stand.week_days[z];
|
||||
|
||||
for (let i = 0; i < stand_length; i++) {
|
||||
let time_now = stand.hour_start + (stand.processing_time * i);
|
||||
let timeFormat = (a) => a > 9 ? a : `0${a}`;
|
||||
|
||||
function formatTime(hours) {
|
||||
let h = Math.floor(hours);
|
||||
let m = (hours % 1 === 0.5) ? "30" : "00";
|
||||
let hh = h.toString().padStart(2, "0");
|
||||
return `${hh}:${m}`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<div id="hour-${z}-${i}">
|
||||
<span class="time">${formatTime(time_now)}-${formatTime(time_now + stand.processing_time)}</span>
|
||||
`;
|
||||
|
||||
for (let q = 0; q < stand.quantity_sheep; q++) {
|
||||
html += `
|
||||
<select id="name">
|
||||
<option value=""></option>
|
||||
<option value="Test">Test</option>
|
||||
</select>
|
||||
`;
|
||||
|
||||
Stand.schedule[z].push({
|
||||
id: (i + z) * stand.quantity_sheep + q,
|
||||
hour: stand.hour_start + (stand.processing_time * i),
|
||||
number_sheep: q,
|
||||
date: stand_date,
|
||||
sheep_id: null,
|
||||
stand_id: stand.id,
|
||||
updated_at: Date.now()
|
||||
});
|
||||
}
|
||||
|
||||
html += `</div>`; // закриваємо hour
|
||||
}
|
||||
|
||||
html += `</div>`; // закриваємо day
|
||||
}
|
||||
|
||||
document.getElementById('stand-info-title').innerText = stand.title;
|
||||
document.getElementById('stand-info-geo').innerHTML = '';
|
||||
document.getElementById('stand-info-image').setAttribute('src', '');
|
||||
|
||||
block_schedule.innerHTML = html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user