feat: goto with osc

This commit is contained in:
cv
2021-05-11 15:49:47 +02:00
parent 80ef58426b
commit a4488b6a56
6 changed files with 32 additions and 10 deletions
+16
View File
@@ -424,6 +424,22 @@ class EventTimer extends Timer {
this.broadcastState();
}
loadEventById(eventId) {
let eventIndex = this._eventlist.findIndex((e) => e.id === eventId);
console.log(
eventId,
this.selectedEventId,
eventIndex === this.selectedEventId
);
if (eventIndex === -1) return;
this.pause();
this.loadEvent(eventIndex);
this.broadcastState();
}
// Loads a given event
// load timers
// load selectedEvent
+1
View File
@@ -56,6 +56,7 @@ const initiateOSC = (config) => {
break;
case 'goto':
console.log('calling goto with', args);
global.timer.loadEventById(args.toLowerCase());
break;
default:
+3 -2
View File
@@ -2,7 +2,8 @@
const db = require('../app.js').db;
// utils
const { nanoid } = require('nanoid');
const customAlphabet = require('nanoid').customAlphabet;
const nanoid = customAlphabet('1234567890abcdef', 4);
const eventDefs = require('../data/eventsDefinition.js');
function _getEventsCount() {
@@ -85,7 +86,7 @@ exports.eventsPost = async (req, res) => {
// ensure structure
let newEvent = {};
req.body.id = nanoid(6);
req.body.id = nanoid();
switch (req.body.type) {
case 'event':