Re-scheduling currently playing item now stops currnet playback, and re-schedules a clone. Allowing for DB-Friendly schedule2scrub functionality.

This commit is contained in:
rainbow napkin 2025-09-09 08:19:46 -04:00
parent 92659929b9
commit 9eeed591ad
4 changed files with 112 additions and 58 deletions

View file

@ -956,16 +956,25 @@ class queuePanel extends panelObj{
//Get current start time
const start = this.dateByOffset(target.offsetTop);
const end = new Date(start.getTime() + (target.dataset['duration'] * 1000));
//Position timetip
timetip.moveToMouse(event);
//Inject timetip label
//Normally wouldn't do innerHTML but these values are calculated serverside and it saves us making a <br> element
timetip.tooltip.innerHTML = [
//Normally wouldn't do innerHTML but these values are calculated serverside and it saves us making a <br> dom node
let timetipContents = [
`Start Time: ${utils.ux.timeStringFromDate(start, true)}`,
`End Time: ${utils.ux.timeStringFromDate(new Date(start.getTime() + (target.dataset['duration'] * 1000)), true)}`
].join('<br>');
`End Time: ${utils.ux.timeStringFromDate(end, true)}`
];
//If the current time is after the start date, but before the end (we're scheduling to start now)
if(start.getTime() < date.getTime() && end.getTime() > date.getTime()){
//Add start timestamp to item
timetipContents.push(`Start Timestamp: ${utils.ux.humieFriendlyDuration((date.getTime() - start.getTime()) / 1000, true)}`);
}
//Inject timetip label
timetip.tooltip.innerHTML = timetipContents.join('<br>')
//Calculate offset from rest of window
const windowOffset = this.queueContainer.offsetTop + this.ownerDoc.defaultView.scrollY;

View file

@ -99,7 +99,7 @@ class canopyUXUtils{
return outString;
}
humieFriendlyDuration(seconds){
humieFriendlyDuration(seconds, compact = false){
//If we have an invalid duration
if(seconds <= 0){
//bitch, moan, and complain!
@ -119,41 +119,62 @@ class canopyUXUtils{
//Remove recorded minutes
seconds -= minutes * 60;
//If we have an hour
if(hours == 1){
//Add the string
timeStrings.push('1 Hour');
//If we have hours
}else if(hours > 0){
//Add the string
timeStrings.push(`${hours} Hours`);
//If we're rendering compact, alarm-clock style duration
if(compact){
if(hours > 0){
//Push hours, pad start with 0
timeStrings.push(String(hours).padStart(2, '0'));
}
if(hours > 0 || minutes > 0){
//Push minutes, pad start with 0
timeStrings.push(String(minutes).padStart(2, '0'));
}
if(hours > 0 || minutes > 0 || seconds > 0){
//Push seconds, pre-fix a 00: if hours and minutes are empty, round to nearest int and pad start with 0
timeStrings.push(`${(hours == 0 && minutes == 0) ? '00:' : ''}${String(Math.round(seconds)).padStart(2, '0')}`);
}
return timeStrings.join(':');
//If we're rendering out using our words
}else{
//If we have an hour
if(hours == 1){
//Add the string
timeStrings.push('1 Hour');
//If we have hours
}else if(hours > 0){
//Add the string
timeStrings.push(`${hours} Hours`);
}
//If we have a minute
if(minutes == 1){
//Add the string
timeStrings.push('1 Minute');
//If we have minutes
}else if(minutes > 0){
//Add the string
timeStrings.push(`${minutes} Minutes`);
}
//Add the 'and ' if we need it
const secondsPrefix = timeStrings.length > 0 ? 'and ' : '';
//If we have a second
if(seconds == 1){
//Add the string
timeStrings.push(`${secondsPrefix}1 Second`);
//If we have more than a second
}else if(seconds > 1){
//Add the string
timeStrings.push(`${secondsPrefix}${Math.round(seconds)} Seconds`);
}
//Join the time strings together
return timeStrings.join(', ');
}
//If we have a minute
if(minutes == 1){
//Add the string
timeStrings.push('1 Minute');
//If we have minutes
}else if(minutes > 0){
//Add the string
timeStrings.push(`${minutes} Minutes`);
}
//Add the 'and ' if we need it
const secondsPrefix = timeStrings.length > 0 ? 'and ' : '';
//If we have a second
if(seconds == 1){
//Add the string
timeStrings.push(`${secondsPrefix}1 Second`);
//If we have more than a second
}else if(seconds > 1){
//Add the string
timeStrings.push(`${secondsPrefix}${Math.round(seconds)} Seconds`);
}
//Join the time strings together
return timeStrings.join(', ');
}
//Update this and popup class to use nodes