-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (97 loc) · 2.67 KB
/
index.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!doctype html>
<html>
<head>
<script src="lib/knockout-3.1.0.debug.patched.js"></script>
<script src="node_modules/basisjs/src/basis.js" basis-config="devpanel:false"></script>
<style>
body
{
background: #F0F0F0;
font-size: small;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
#demo-container
{
display: flex;
flex-wrap: wrap;
align-items: flex-start;
}
</style>
</head>
<body>
<div id="demo-container"></div>
<script>
var ReadOnlyDataset = basis.require('basis.data').ReadOnlyDataset;
var Flow = basis.require('./node_modules/basisjs/src/devpanel/module/data-flow/index.js');
var UINode = basis.require('basis.ui').Node;
var getSource = basis.require('basis.utils.source').getSource;
var container = document.getElementById('demo-container');
function openFile(filename){
var basisjsTools = typeof basisjsToolsFileSync != 'undefined' ? basisjsToolsFileSync : basis.devtools;
if (basisjsTools && typeof basisjsTools.openFile == 'function')
basisjsTools.openFile(basis.path.resolve(filename.replace(/(:\d+:\d+):\d+:\d+$/, '$1')));
}
var buildTree = Flow.createTreeBuilder({
sandbox: basis,
getInfo: function(target, key){
if (key === 'sourceInfo') {
return ko.$devinfo.get(target);
}
var info = {};
var koInfo = ko.$devinfo.get(target);
var devInfo = $devinfo.get(target);
if (koInfo) {
info.sourceInfo = koInfo;
}
if (devInfo) {
for (var key in devInfo) {
info[key] = devInfo[key];
}
}
return key ? info[key] : info;
},
resolveValue: function(value){
if (value && '_latestValue' in value) {
return value._latestValue;
}
return value;
}
});
var View = UINode.subclass({
template: basis.resource('./template/view.tmpl'),
binding: {
name: 'name',
source: 'source',
flow: 'satellite:'
},
satellite: {
flow: 'flow'
}
});
[
'observable',
'compute',
// 'update',
'1'
].forEach(function(name){
var filename = './cases/' + name + '.js';
var value = basis.require(filename);
var flow = new Flow({
fileAPI: {
openFile: openFile
},
childNodes: buildTree(value)
});
// setInterval(function() {
// flow.setChildNodes(buildTree(value));
// }, 1000);
new View({
container: container,
name: name,
source: getSource(filename),
flow: flow
});
});
</script>
</body>
</html>