From 35f0d814db4765cc27f24baa9e68ba1d0e42a565 Mon Sep 17 00:00:00 2001 From: vexorian Date: Sun, 4 Oct 2020 00:17:28 -0400 Subject: [PATCH] FF/REW channel tools --- web/directives/channel-config.js | 99 +++++++++++++++--------- web/public/templates/channel-config.html | 71 +++++++++++------ 2 files changed, 108 insertions(+), 62 deletions(-) diff --git a/web/directives/channel-config.js b/web/directives/channel-config.js index 8d8789c..0fb429f 100644 --- a/web/directives/channel-config.js +++ b/web/directives/channel-config.js @@ -60,24 +60,7 @@ module.exports = function ($timeout, $location, dizquetv) { scope.showRotatedNote = false; } else { scope.beforeEditChannelNumber = scope.channel.number - let t = Date.now(); - let originalStart = scope.channel.startTime.getTime(); - let n = scope.channel.programs.length; - let totalDuration = scope.channel.duration; - let m = (t - originalStart) % totalDuration; - let x = 0; - let runningProgram = -1; - let offset = 0; - for (let i = 0; i < n; i++) { - let d = scope.channel.programs[i].duration; - if (x + d > m) { - runningProgram = i - offset = m - x; - break; - } else { - x += d; - } - } + if (typeof(scope.channel.fillerRepeatCooldown) === 'undefined') { scope.channel.fillerRepeatCooldown = 30 * 60 * 1000; } @@ -104,13 +87,40 @@ module.exports = function ($timeout, $location, dizquetv) { ) { scope.channel.guideMinimumDurationSeconds = 5 * 60; } - scope.channel.startTime = new Date(t - offset); - // move runningProgram to index 0 - scope.channel.programs = scope.channel.programs.slice(runningProgram, this.length) - .concat(scope.channel.programs.slice(0, runningProgram) ); + + adjustStartTimeToCurrentProgram(); updateChannelDuration(); setTimeout( () => { scope.showRotatedNote = true }, 1, 'funky'); } + + function adjustStartTimeToCurrentProgram() { + let t = Date.now(); + let originalStart = scope.channel.startTime.getTime(); + let n = scope.channel.programs.length; + let totalDuration = scope.channel.duration; + let m = (t - originalStart) % totalDuration; + let x = 0; + let runningProgram = -1; + let offset = 0; + for (let i = 0; i < n; i++) { + let d = scope.channel.programs[i].duration; + if (x + d > m) { + runningProgram = i + offset = m - x; + break; + } else { + x += d; + } + } + // move runningProgram to index 0 + scope.channel.programs = scope.channel.programs.slice(runningProgram) + .concat(scope.channel.programs.slice(0, runningProgram) ); + scope.channel.startTime = new Date(t - offset); + + } + + + let addMinuteVersionsOfFields = () => { //add the minutes versions of the cooldowns: scope.channel.fillerRepeatCooldownMinutes = scope.channel.fillerRepeatCooldown / 1000 / 60; @@ -186,21 +196,6 @@ module.exports = function ($timeout, $location, dizquetv) { return true; } - let fixFillerCollection = (f) => { - return { - id: f.id, - weight: f.weight, - cooldown: f.cooldown * 60000, - }; - } - let unfixFillerCollection = (f) => { - return { - id: f.id, - weight: f.weight, - cooldown: Math.floor(f.cooldown / 60000), - }; - } - scope.finishedOfflineEdit = (program) => { let editedProgram = scope.channel.programs[scope.selectedProgram]; let duration = program.durationSeconds * 1000; @@ -317,6 +312,19 @@ module.exports = function ($timeout, $location, dizquetv) { }); updateChannelDuration() } + scope.slideAllPrograms = (offset) => { + let t0 = scope.channel.startTime.getTime(); + let t1 = t0 - offset; + let t = (new Date()).getTime(); + let total = scope.channel.duration; + while(t1 > t) { + //TODO: Replace with division + t1 -= total; + } + scope.channel.startTime = new Date(t1); + adjustStartTimeToCurrentProgram(); + updateChannelDuration(); + } scope.removeDuplicates = () => { let tmpProgs = {} let progs = scope.channel.programs @@ -1401,6 +1409,23 @@ module.exports = function ($timeout, $location, dizquetv) { } }); + scope.slide = { + value: -1, + options: [ + {id:-1, description: "Time Amount" }, + {id: 1 * 60 * 1000, description: "1 minute" }, + {id: 10 * 60 * 1000, description: "10 minutes" }, + {id: 15 * 60 * 1000, description: "15 minutes" }, + {id: 30 * 60 * 1000, description: "30 minutes" }, + {id: 60 * 60 * 1000, description: "1 hour" }, + {id: 2 * 60 * 60 * 1000, description: "2 hours" }, + {id: 4 * 60 * 60 * 1000, description: "4 hours" }, + {id: 8 * 60 * 60 * 1000, description: "8 hours" }, + {id:12 * 60 * 60 * 1000, description: "12 hours" }, + {id:24 * 60 * 60 * 1000, description: "1 day" }, + {id: 7 * 24 * 60 * 60 * 1000, description: "1 week" }, + ] + } scope.nightStartHours = [ { id: -1, description: "Start" } ]; scope.nightEndHours = [ { id: -1, description: "End" } ]; diff --git a/web/public/templates/channel-config.html b/web/public/templates/channel-config.html index bd3160a..84b6319 100644 --- a/web/public/templates/channel-config.html +++ b/web/public/templates/channel-config.html @@ -218,6 +218,30 @@

Like Random Shuffle, but tries to preserve the sequence of episodes for each TV show. If a TV show has multiple instances of its episodes, they are also cycled appropriately.

+
+
+
+ +
+ +
+

Makes multiple copies of the schedule and plays them in sequence. Normally this isn't necessary, because dizqueTV will always play the schedule back from the beginning when it finishes. But creating replicas is a useful intermediary step sometimes before applying other transformations. Note that because very large channels can be problematic, the number of replicas will be limited to avoid creating really large channels.

+
+ +
+
+
+ +
+ +
+

Like "Replicate", it will make multiple copies of the programming. In addition it will shuffle the programs, but it will make sure not to have too small a distance between two identical programs.

+
+
-
-
-
-
- -
- -
-

Makes multiple copies of the schedule and plays them in sequence. Normally this isn't necessary, because dizqueTV will always play the schedule back from the beginning when it finishes. But creating replicas is a useful intermediary step sometimes before applying other transformations. Note that because very large channels can be problematic, the number of replicas will be limited to avoid creating really large channels.

-
- -
-
-
- -
- -
-

Like "Replicate", it will make multiple copies of the programming. In addition it will shuffle the programs, but it will make sure not to have too small a distance between two identical programs.

-
-
+
+
+
+ +
+ +
+ +
+
+

Slides the whole schedule. The "Fast-Forward" button will advance the stream by the specified amount of time. The "Rewind" button does the opposite.

+
+