-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
157 lines (139 loc) · 5.05 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<html>
<head>
<link rel="stylesheet" type="text/css" href="js/ui/interpreter.css" />
<link rel="stylesheet" type="text/css" href="js/ui/subdialogs.css" />
<link rel="stylesheet" type="text/css" href="js/ui/gutter.css" />
<link rel="stylesheet" type="text/css" href="css/highlighter.css" />
<link rel="stylesheet" type="text/css" href="css/cadence.css" />
<script type="text/javascript" src="js/lib/jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="js/lib/jquery-ui.min.js"></script>
<script src="js/lib/url.js"></script>
<script>Cadence = { };</script>
<script src="./js/language/lang.js"></script>
<script src="./js/core/lex.js"></script>
<script src="./js/core/parser.js"></script>
<script src="./js/core/errors.js"></script>
<script src="./js/core/ast.js"></script>
<script src="./js/core/core.js"></script>
<script src="./js/core/store.js"></script>
<script src="./js/optimised.js"></script>
<script src="./js/state.js"></script>
<script src="./js/ui/interpreter.js"></script>
<script src="./js/ui/gutter.js"></script>
<script src="./js/ui/highlighter.js"></script>
<script src="./js/ui/subdialogs.js"></script>
<script>
Cadence.Storage.loadURL("library/core.js-c");
Cadence.Storage.loadURL("library/boolean.js-c");
Cadence.Storage.loadURL("library/conditional.js-c");
Cadence.Storage.loadURL("library/list.js-c");
Cadence.Storage.loadURL("library/functional.js-c");
Cadence.Storage.loadURL("library/string.js-c");
Cadence.Storage.loadURL("library/math.js-c");
Cadence.Storage.loadURL("library/units.js-c");
Cadence.Storage.loadURL("library/vector.js-c");
Cadence.Storage.loadURL("library/set.js-c");
Cadence.Storage.loadURL("library/html.js-c");
window.onload = function() {
Cadence.Storage.loadURL("library/svg.js-c");
$('#cbrowse').resizable({ handles: 'w'});
$("#button-pause").click(function() {
Cadence.pause = !Cadence.pause;
if (!Cadence.pause) {
$("#button-pause").html("");
Cadence.processQueues();
} else {
$("#button-pause").html("");
}
});
function showProjects() {
Cadence.UI.Dialogs.browseModels(document.body, function(url, title) {
if (url) {
//Cadence.reset();
$.get(url, function(data) {
sbox.setValue(data);
sbox.execute();
$('.titletext').html(title);
});
} else {
//Cadence.reset();
sbox.setValue("");
$('.titletext').html("Untitled");
}
});
}
$('.mainmenu').click(showProjects);
var sbox = Cadence.UI.makeScriptBox($("#cterminal").get(0));
Cadence.onoutput = function(res) {
/*var ele = $("#cout").get(0);
if (res !== undefined) {
ele.innerHTML += "<b>>></b> "+JSON.stringify(res)+"<br/>";
ele.scrollTop = ele.scrollHeight;
} else {
//ele.innerHTML += "";
}*/
}
var file = URLUtil.getParameterByName("file");
if (!file) showProjects();
setInterval(function() {
var value = $("#search").get(0).value;
var paths = Cadence.concretePathStrings(value);
var res = $("#searchresults");
if (Cadence.initial === undefined) {
Cadence.initial = {};
for (var i=0; i<paths.length; i++) {
Cadence.initial[paths[i]] = true;
}
if (file) {
$.get(file, function(data) {
sbox.setValue(data);
sbox.execute();
$('.titletext').html(file);
});
}
return;
}
res.empty();
var count = 0;
for (var i=0; i<paths.length; i++) {
if (Cadence.initial[paths[i]]) continue;
count++;
if (count > 40) break;
var ele = $('<div class="resultitem"></div>');
//console.log(Cadence.parsePath(value + " " + paths[i]));
var path = Cadence.parsePath(value + " " + paths[i]+" to string");
var val = Cadence._search(path);
if (val === undefined) val = Cadence.search(Cadence.parsePath(value + " " + paths[i]));
//if (Array.isArray(val)) val = Cadence.prettyPath(val);
ele.html(paths[i] + " <span class=\"identity\"></span> "+val);
res.append(ele);
}
}, 400);
/*var starttime = Date.now();
setInterval(function() {
var now = Date.now();
Cadence.define(["global","tick"], function() { return (now - starttime) / 1000; }, undefined);
}, 50);*/
}
</script>
</head>
<body>
<div id="menubar" style="position: absolute; top: 0; left: 0; right: 0; height: 50px;">
<div class="mainmenu" title="Browse Projects"></div>
<div class="titletext">JS-Cadence</div>
<div class="tool-buttons">
<button id="button-pause" class="toolbutton iconfont" title="Pause"></button>
<button class="toolbutton" title="Insert Symbols" style="font-weight: bold;">π</button>
<button class="toolbutton iconfont" title="Show/hide Script"></button>
<button class="toolbutton iconfont" title="Show/hide State"></button>
</div>
</div>
<div id="cterminal" style="position: absolute; top: 50px; left: 30px; width: 670px; bottom: 0;">
</div>
<div id="svgout" style="position: absolute; top: 50px; right: 250px; bottom: 0; left: 700px;"></div>
<div id="cbrowse">
<div id="searchouter"><input type="text" id="search" placeholder="Search..."></input></div>
<div id="searchresults"></div>
</div>
</body>
</html>