mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-11 00:59:35 +00:00
de9a7a87fd
* refactor(project structure): UI * refactor(project structure): extract utilities * refactor(project structure): remove unused * refactor(project structure): electron * refactor(project structure): server refactor: migrate to vitest refactor: monorepo config * refactor: extract application menu * refactor: exit process * refactor: extract tray menu * chore: electron build * Added Seconds in studio clock #282 --------- Co-authored-by: Fabian Posenau <fabian@fphome.de> --------- Co-authored-by: Fabian Posenau <fabian.p99@gmx.de> Co-authored-by: Fabian Posenau <fabian@fphome.de>
26 lines
555 B
JavaScript
26 lines
555 B
JavaScript
/**
|
|
* @description calculates delay to a given event
|
|
* @param {array} events
|
|
* @param {number} eventIndex
|
|
* @return {number} - delay value of given event
|
|
*/
|
|
export default function getDelayTo(events, eventIndex) {
|
|
let delay = 0;
|
|
let index = 0;
|
|
if (eventIndex >= 0) {
|
|
for (const event of events) {
|
|
if (eventIndex === index) {
|
|
return delay;
|
|
}
|
|
|
|
if (event.type === 'delay') {
|
|
delay += event.duration;
|
|
} else if (event.type === 'block') {
|
|
delay = 0;
|
|
}
|
|
index++;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|