56 lines
No EOL
2.1 KiB
JavaScript
56 lines
No EOL
2.1 KiB
JavaScript
/*Canopy - The next generation of stoner streaming software
|
|
Copyright (C) 2024-2026 Rainbownapkin and the TTN Community
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|
|
|
class ChannelGuide{
|
|
constructor(){
|
|
this.scheduleIndex = document.querySelector('#channel-guide-schedule-index');
|
|
this.channelList = document.querySelector('#channel-guide-channel-list');
|
|
this.scheduledMediaDiv = document.querySelector('#channel-guide-scheduled-media');
|
|
|
|
//Refresh the schedule
|
|
this.refreshList();
|
|
}
|
|
|
|
async refreshList(){
|
|
//Fetch latest channel list and render it to the schedule page
|
|
this.renderList(await utils.ajax.getChannels());
|
|
}
|
|
|
|
renderList(schedule, now = new Date()){
|
|
this.renderIndex(now);
|
|
}
|
|
|
|
renderIndex(now = new Date()){
|
|
//DO EM 3 TEIMS!
|
|
for(let slot = 0; slot < 3; slot++){
|
|
//Clone passed date object to prevent over-writing
|
|
const setDate = new Date(now.getTime());
|
|
|
|
//Up timeslot by 30 minutes for each timeslot in the loop
|
|
setDate.setMinutes(setDate.getMinutes() + (slot * 30));
|
|
|
|
//Generate timeslot label
|
|
const timeslotLabel = document.createElement('h3');
|
|
timeslotLabel.classList.add('channel-guide-timeslot-label');
|
|
timeslotLabel.textContent = utils.ux.timeStringFromDate(setDate, false);
|
|
|
|
//Append timeslot label to schedule index
|
|
this.scheduleIndex.appendChild(timeslotLabel);
|
|
}
|
|
}
|
|
}
|
|
|
|
const channelGuide = new ChannelGuide(); |