Started work on improved channel guide rendering
This commit is contained in:
parent
0291904534
commit
c3483627d8
6 changed files with 125 additions and 54 deletions
56
www/js/channelGuide.js
Normal file
56
www/js/channelGuide.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*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();
|
||||
|
|
@ -1012,6 +1012,18 @@ class canopyAjaxUtils{
|
|||
}
|
||||
|
||||
//Channel
|
||||
async getChannels(){
|
||||
var response = await fetch(`/api/channel/list`,{
|
||||
method: "GET"
|
||||
});
|
||||
|
||||
if(response.ok){
|
||||
return await response.json();
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
async newChannel(name, description, thumbnail, verification){
|
||||
var response = await fetch(`/api/channel/register`,{
|
||||
method: "POST",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue