This repository has been archived by the owner on May 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
78 lines (68 loc) · 1.54 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Client main js script
*/
// Fill in to get ES6:ish environment
require('babel-polyfill');
// Riot + tags
var riot = require('riot');
var liveview = require('./tags/liveview.tag');
var statusview = require('./tags/statusview.tag');
var modeselector = require('./tags/modeselector.tag');
var modeeditor = require('./tags/modeeditor.tag');
var scripteditor = require('./tags/scripteditor.tag');
var setup = require('./tags/setup.tag');
// Get socket from the window global
var socket = window.socket;
// Mount all tags..
riot.mount('liveview, statusview, modeselector, modeeditor, setup', socket);
riot.mount('#dsp-scripteditor', {
"socket": socket,
"title": "Display scripts",
"events": {
"update": "scriptschanged",
"set": "setscript",
"delete": "deletescript"
},
"template":
`"use strict";
var code = class {
onSetup(configuration, dataSource){
// set properties of this animation script
// pull data from data source
// set up animation
}
onFrame(oldFrame, timePassedInSeconds){
// calculate one frame of animation,
// update oldFrame
// and return ms to next callback.
// Return 0 to end the script.
//
// oldFrame.fill(0);
// return 1000;
}
};
`
});
riot.mount('#data-scripteditor', {
"socket": socket,
"title": "Data scripts",
"events": {
"update": "datascriptschanged",
"set": "setdatascript",
"delete": "deletedatascript",
"result": "data"
},
"template":
`"use strict";
var code = class {
constructor(){
// set up stuff
}
onUpdate(){
// get fresh data
// ...
// return data object
}
};
`
});