forked from cloudstitch/processing-experiment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
60 lines (54 loc) · 1.73 KB
/
scripts.js
File metadata and controls
60 lines (54 loc) · 1.73 KB
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
/* Constructs the widget.
* Args:
* ctsTarget - the CTS Node the widget is being constructed in.
* ctsSource - the CTS Node that represents the widget being copied
* ctsRelation - the CTS Relation that caused this invocation
*
*/
function processingWidget_Init(ctsTarget, ctsSource, ctsRelation) {
console.log("processingWidget :: Init");
var widgetContainerNode = ctsTarget.value;
var tryIt = function() {
if (processingWidget_DependenciesLoaded()) {
processingWidget_ConstructUI(widgetContainerNode);
} else {
setTimeout(tryIt, 100);
}
}
tryIt();
}
function processingWidget_DependenciesLoaded() {
return (
true
)
}
function processingWidget_ConstructUI(node) {
var data = processingWidget_GrabData();
console.log("Got Data", data);
console.log("Constructing widget with settings", data.settings);
for (var i = 0; i < data.data.length; i++) {
var point = data.data[i];
for (var j = 0; j < data.transformations.length; j++) {
var transformation = data.transformations[j];
console.log("Data", point, "Transformation", transformation);
}
}
}
/*
* Assumptions:
* Spreadsheet label is: processingDatasource
* Spreadsheet has worksheets: data, transformations, settings
*/
function processingWidget_GrabData() {
// data: an array of objects
var data = CTS('processingDatasource|data!rows').nodes[0].toJson();
// settings: a single object
var settings = CTS('processingDatasource|data!rows').nodes[0].toJson()[0];
// transformations: an array of arrays
var transformations = CTS('processingDatasource|transformations!rows').nodes[0].parentNode.cellFeedNode.getCsv();
return {
data: data,
settings: settings,
transformations: transformations
};
}