diff --git a/www/js/channel/panels/queuePanel/queuePanel.js b/www/js/channel/panels/queuePanel/queuePanel.js index c072f55..436f26f 100644 --- a/www/js/channel/panels/queuePanel/queuePanel.js +++ b/www/js/channel/panels/queuePanel/queuePanel.js @@ -151,7 +151,7 @@ class queuePanel extends panelObj{ //Seems like before we didnt get the message (see 50b1e15a6c -> 05408bbec4) //so just to reiterate: DON'T FUCKING REMOVE THE ARROW FUNCTIONS BELOW, NO MATTER HOW FUGLY YOU FUCKING THINK THEY ARE this.client.queueBroadcastSocket.on("queue", ()=>{this.renderQueue()}); //YEAH ASSHOLE I MEAN THIS ONE - this.client.socket.on("archive", ()=>{this.renderQueue.bind(this)}); //THIS ONE TOO, FOR FUCK SAKES YOU BAKED CUNT + this.client.socket.on("archive", ()=>{this.renderQueue()}); //THIS ONE TOO, FOR FUCK SAKES YOU BAKED CUNT this.client.socket.on("start", this.handleStart.bind(this)); this.client.socket.on("end", this.handleEnd.bind(this)); this.client.socket.on("lock", this.handleScheduleLock.bind(this)); @@ -331,6 +331,9 @@ class queuePanel extends panelObj{ } handleArchiveResults(data){ + //Hand over the data to the client to sort into the queue (why waste a good pile of archived items?) + //client.sortQueue(data.archive); + //Reverse archive order to show newest first, and render as an array of raw entries this.renderResults(data.archive.reverse(), true); } @@ -383,6 +386,22 @@ class queuePanel extends panelObj{ queueEntry.classList.add('bi-play-circle') controlDiv.appendChild(queueEntry); + //Handle button event listeners + goToEntry.addEventListener('click', ()=>{this.goToEntry(entry)}); + + //If this is a live-stream + if(entry.type == "livehls" || entry.type == "webrtc"){ + //Toggle live stream menu open + queueEntry.addEventListener('click', (event)=>{if(!this.goLiveDiv.checkVisibility()){this.toggleGoLive(event)}}) + //Otherwise + }else{ + //Add event listener for play button + queueEntry.addEventListener('click', (event)=>{ + //When clicked, re-queue the selected item at the end of the current schedule + this.client.socket.emit("queue",{url:entry.url, title:entry.title}); + }); + } + //Append control div to entry div entryDiv.appendChild(controlDiv); @@ -1254,7 +1273,7 @@ class queuePanel extends panelObj{ //Get height difference between window and queue layout controller const docDifference = this.ownerDoc.defaultView.innerHeight - this.queueLayoutController.getBoundingClientRect().height; //Calculate scroll target by body difference and marker position - const scrollTarget = (markerPosition - (this.queueLayoutController.getBoundingClientRect().height - docDifference) / 2) + docDifference; + const scrollTarget = (markerPosition - (this.queueLayoutController.getBoundingClientRect().height - docDifference) / 2); //Calculate scroll behavior by distance const scrollBehavior = Math.abs(scrollTarget - this.queueLayoutController.scrollTop) > 10 ? "smooth" : "instant"; @@ -1527,6 +1546,34 @@ class queuePanel extends panelObj{ } } + goToEntry(entry){ + //Calculate the time it would've been smack in the middle of the entry + const middle = new Date(entry.startTime + ((entry.duration * 1000) / 2)); + + //If we're moving to another day + if(!utils.isSameDate(this.day, middle)){ + //If the date controls are hidden + if(!this.queueDateDiv.checkVisibility()){ + //Make em' visible + this.toggleDateControl(); + } + + //Move scheduler to correct day, using a clone of the date object to avoid fucking with it + this.setDay(new Date(middle.getTime())); + } + + //This was shamelessy stolen from our autoscroll functionality, I should probably make it its own function lmao + const docDifference = this.ownerDoc.defaultView.innerHeight - this.queueLayoutController.getBoundingClientRect().height; + const scrollTarget = (this.offsetByDate(middle) - (this.queueLayoutController.getBoundingClientRect().height - docDifference) / 2); + + //Scroll to the selected item + this.queueLayoutController.scroll({ + left: 0, + top: scrollTarget, + behavior: 'smooth' + }); + } + /** * Calculate schedule offset from top or bottom of div from date * @param {Date} date - Date to calculate from, defaults to now