mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 18:33:53 +00:00
feat: operator view (#440)
* feat: operator view * chore: smoke test operator * refactor: small improvements from deepsource --------- Co-authored-by: arihanv <arihanvaranasi@gmail.com> Co-authored-by: arihanv <63890951+arihanv@users.noreply.github.com>
This commit is contained in:
@@ -3,14 +3,18 @@ import { isOntimeEvent, OntimeEvent, OntimeRundown, OntimeRundownEntry } from 'o
|
||||
import { getFirstEvent, getNextEvent, getPreviousEvent } from '../rundown-utils/rundownUtils.js';
|
||||
import { isNumeric } from '../types/types.js';
|
||||
|
||||
// Zero or more non-digit characters at the beginning ((\D*)).
|
||||
// One or more digits ((\d+)).
|
||||
// Optionally, a decimal part starting with a dot ((\.\d+)?).
|
||||
const regex = /^(\D*)(\d+)(\.\d+)?$/;
|
||||
|
||||
/**
|
||||
* Finds if last characters in input are a number and increments
|
||||
* @param input {string}
|
||||
*/
|
||||
export function getIncrement(input: string): string {
|
||||
// Check if the input string contains a number at the end
|
||||
const match = input?.match(/^(\D*)(\d+)(\.\d+)?$/);
|
||||
|
||||
const match = regex.exec(input);
|
||||
if (match) {
|
||||
// If a number is found, extract the non-numeric prefix, integer part, and decimal part
|
||||
let [, prefix, integerPart, decimalPart] = match;
|
||||
|
||||
@@ -26,6 +26,21 @@ export function getFirstEvent(rundown: OntimeRundownEntry[]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getLastEvent(rundown: OntimeRundown): OntimeEvent | null {
|
||||
if (rundown.length < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = rundown.length - 1; i > 0; i--) {
|
||||
const event = rundown.at(i);
|
||||
if (isOntimeEvent(event)) {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next event in rundown, if it exists
|
||||
* @param {OntimeRundownEntry[]} rundown
|
||||
|
||||
Reference in New Issue
Block a user