-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
executable file
·443 lines (375 loc) · 18.7 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>FPGALink-GUI</title>
<!-- powered by at least five blockchains! -->
<meta name="mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/driver.js.iife.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/driver.css" />
<script src="https://cdn.jsdelivr.net/npm/shepherd.js/dist/js/shepherd.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/shepherd.js/dist/css/shepherd.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="./css/aristo/jquery-ui-1.8.16.custom.css" />
<link type="text/css" rel="stylesheet" href="./css/jquery.layout.css" />
<link type="text/css" rel="stylesheet" href="./css/application.css" />
<script src="./lib/jquery.js"></script>
<script src="./lib/jquery-ui.js"></script>
<script src="./lib/jquery.browser.js"></script>
<script src="./lib/jquery.layout.js"></script>
<script src="./lib/draw2d.js"></script>
<script src="./gui/Util.js"></script>
<script src="./gui/Application.js"></script>
<script src="./gui/View.js"></script>
<script src="./gui/Toolbar.js"></script>
<script src="./gui/HoverConnection.js"></script>
<script src="./gui/SelectionMenuPolicy.js"></script>
<script src="./gui/NodeShape.js"></script>
<script src="./gui/SwitchShape.js"></script>
<script src="./gui/Label.js"></script>
<script type="text/javascript">
var app;
document.addEventListener("DOMContentLoaded", function () {
app = new example.Application();
app.view.installEditPolicy(new draw2d.policy.connection.DragConnectionCreatePolicy({
createConnection: function () {
return new HoverConnection();
}
}));
// Enable grid by default.
app.toolbar.installedPolicy = new draw2d.policy.canvas.SnapToGridEditPolicy();
app.view.installEditPolicy(app.toolbar.installedPolicy);
// // unmarshal the JSON document into the canvas (load).
// var jsonDocument = $("#json_input").text();
// var reader = new draw2d.io.json.Reader();
// reader.unmarshal(app.view, jsonDocument);
// // display the JSON document in the preview DIV
// //
// displayJSON(app.view);
// Produce export text into input fields.
app.view.getCommandStack().addEventListener(function (e) {
if (e.isPostChangeEvent()) {
// Workaround to stop this for torus view
if (checkIfTorusView()) return;
// displayJSON(app.view);
// var fpganodes = app.view.getFigures();
// var srun_export = " -N " + fpganodes.getSize();
var srun_export = "";
var connections = app.view.getLines();
for (let i = 0; i < connections.getSize(); i++) {
var connection = connections.get(i);
// Ignore in case this is a config connection
if (!connection.sourcePort.name.includes("config_port")) {
// Parent is ChannelShape.
let source_channel = connection.getSource().getParent();
let target_channel = connection.getTarget().getParent();
let source_fpgalink_text = generate_fpgalink_output(source_channel);
let target_fpgalink_text = generate_fpgalink_output(target_channel);
srun_export += " --fpgalink=" + source_fpgalink_text + "-" + target_fpgalink_text + "";
}
}
// Export --fpgalink.
app.toolbar.srunExportInput.val(srun_export);
// Export URL.
var importURL = "https://pc2.github.io/fpgalink-gui/index.html?import=";
importURL += encodeURIComponent(srun_export);
app.toolbar.urlExportInput.val(importURL);
}
});
// Read srun command from $_GET request.
var srun_cmd = "";
try {
var get_decoded = decodeURI(window.location.search);
const urlParams = new URLSearchParams(get_decoded);
if (urlParams.has('import')) {
srun_cmd = urlParams.get('import');
// Special case to replace eth with eth00
srun_cmd = srun_cmd.replace(/eth(?!\d{2})/g, 'eth00')
var get_node_type = "";
if (urlParams.has('node-type') &&
(urlParams.get('node-type') == NodeTypeEnum.intel ||
urlParams.get('node-type') == NodeTypeEnum.xilinx)) {
get_node_type = urlParams.get('node-type');
} else {
// Apply minor heuristic if command is for Xilinx or Intel.
// Idea: If command has
// * acl2, it has to be Xilinx
// * chX, where X >= 2, it has to be Intel
if (srun_cmd.indexOf("acl2") > -1) {
get_node_type = NodeTypeEnum.xilinx;
}
if (srun_cmd.indexOf("ch2") > -1 || srun_cmd.indexOf("ch3") > -1) {
get_node_type = NodeTypeEnum.intel;
}
// If heuristic does not catch, ask user.
if (get_node_type == "") {
document.getElementById("prompt-node-type").showModal();
}
}
if (get_node_type != "") {
app.toolbar.srunApply(srun_cmd, get_node_type);
}
}
} catch (e) { // catches a malformed URI
console.log(e);
alert("error parsing srun command from GET request.");
}
// Read srun command from $_GET request, if node type unclear.
$("#prompt-node-type-intel").click(function () {
document.getElementById("prompt-node-type").close();
app.toolbar.srunApply(srun_cmd, NodeTypeEnum.intel);
});
$("#prompt-node-type-xilinx").click(function () {
document.getElementById("prompt-node-type").close();
app.toolbar.srunApply(srun_cmd, NodeTypeEnum.xilinx);
});
// Tutorial Buttons
let tutorialButtons = $(".tutorial-btn");
tutorialButtons.button().click($.proxy(function (ev) {
let btn = ev.target.parentElement;
let type = btn.dataset.type;
let currentUrl = new URL(window.location.href);
currentUrl.searchParams.set('tutorial', type);
window.open(currentUrl.toString(), '_blank');
}, this)).button("option", "enabled", true);
// Navigation.
// Grid toggle.
app.toolbar.toggleGridButton = $('#toggleGridButton');
app.toolbar.toggleGridButton.button().click($.proxy(function () {
if (!app.toolbar.installedPolicy) {
app.toolbar.installedPolicy = new draw2d.policy.canvas.SnapToGridEditPolicy();
app.view.installEditPolicy(app.toolbar.installedPolicy);
} else {
app.view.uninstallEditPolicy(app.toolbar.installedPolicy);
app.toolbar.installedPolicy = null;
}
}, app.toolbar)).button("option", "enabled", true);
// Change router.
app.toolbar.changeRouterSelect = $("#connection_router");
app.toolbar.changeRouterSelect.on('change', function () {
var selectedRouterClassName = this.value;
app.setDefaultRouterClassName(selectedRouterClassName);
// here: insecure use of eval
var router = eval("new " + selectedRouterClassName + "()");
let command = new draw2d.command.CommandCollection();
app.view.getLines().each(function (i, line) {
let lineCommand = new draw2d.command.CommandAttr(line, {router: router});
command.add(lineCommand);
});
app.view.getCommandStack().execute(command);
});
// Custom topology
let topologyButtons = $(".topology-btn");
topologyButtons.button().click($.proxy(function (ev) {
let btn = ev.target.parentElement;
let type = btn.dataset.type;
document.getElementById(type + "-topology-modal").showModal();
}, this)).button("option", "enabled", true);
$(".topology-modal i").click(function (ev) {
$(this).closest("dialog")[0].close();
});
$(".topology-modal .button.cancel").click(function (ev) {
$(this).closest("dialog")[0].close();
});
$(".topology-modal .button.submit").click(function (ev) {
let dialog = $(this).closest("dialog");
});
});
function displayJSON(canvas) {
var writer = new draw2d.io.json.Writer();
writer.marshal(canvas, function (json) {
$("#json_output").text(JSON.stringify(json, null, 2));
});
}
// If the tutorial param is set, start the tutorial
const params = new URLSearchParams(window.location.search);
if (params.has('tutorial')) {
setTimeout(() => {
let script = document.createElement("script");
script.src = "./gui/Tutorial.js";
document.head.appendChild(script);
}, 200);
}
</script>
</head>
<body id="container">
<div id="content">
<div id="toolbar"></div>
<div id="canvas" class="" style="width:3000px; height:3000px;">
</div>
</div>
<!-- Menu for config options for 2 nodes -->
<ul class='custom-menu mult'>
<li data-action="one-by-one">1:1 Mapping</li>
<li class="intel-only" data-action="clique">Clique</li>
</ul>
<!-- Menu for config options for single nodes -->
<div class='custom-menu single'>
<div class="title">Configure Connection:</div>
<ul>
<li data-action="loopback">Loopback</li>
<li class="intel-only" data-action="pair">Pair</li>
<li data-action="channel">Channel i to i + 1</li>
</ul>
<ul>
<li class="clear" data-action="clear">Clear all connections</li>
</ul>
</div>
<!-- Menu for config options for labels -->
<div class='custom-menu label'>
<div class="title">Change background color:</div>
<ul>
<li data-action="bg-black">Black</li>
<li data-action="bg-white">White</li>
<li data-action="bg-#5b5b5b">Grey</li>
<li data-action="bg-red">Red</li>
<li data-action="bg-yellow">Yellow</li>
<li data-action="bg-green">Green</li>
<li data-action="bg-blue">Blue</li>
</ul>
<div class="intel-only title">Change text color:</div>
<ul>
<li data-action="t-black">Black</li>
<li data-action="t-white">White</li>
<li data-action="t-#5b5b5b">Grey</li>
<li data-action="t-red">Red</li>
<li data-action="t-yellow">Yellow</li>
<li data-action="t-green">Green</li>
<li data-action="t-blue">Blue</li>
</ul>
</div>
<div id="navigation" class="">
<p style="font-size:22px;"><strong><a href="index.html" style="color:#18b0e2;">FPGALink-GUI</a></strong></p>
<div class="menu nodes">
<p class="menu-header" style="color:#fff;">
<i class="fa fa-chevron-down open"></i>
<strong>Elements</strong>
</p>
<div class="elements">
<div data-type="node-intel" id="intel-node" data-shape="east"
class="palette_node_element draw2d_droppable">
Intel Stratix 10
Node</div>
<div data-type="node-xilinx" id="xilinx-node" data-shape="east"
class="palette_node_element draw2d_droppable">
Xilinx Alveo U280
Nodes</div>
<div data-type="node-ethernet-switch" id="ethernet-switch" data-shape="north"
class="palette_node_element draw2d_droppable">Ethernet
Switch</div>
<div data-type="label" data-shape="label" id="label" class="palette_node_element draw2d_droppable">Label
</div>
</div>
</div>
<div class="menu topologies">
<p class="menu-header" style="color:#fff;">
<i class="fa fa-chevron-right"></i>
<strong>Custom Topologies</strong>
</p>
<div class="elements" style="display: none;">
<button class="topology-btn" data-type="ring">Ring</button>
<button class="topology-btn" data-type="torus">Torus</button>
</div>
</div>
<div class="menu tutorials">
<p class="menu-header" style="color:#fff;">
<i class="fa fa-chevron-right"></i>
<strong>Tutorials</strong>
</p>
<div class="elements" style="display: none;">
<button data-type="basic" class="tutorial-btn">Basic Tutorial</button>
<button data-type="advanced" class="tutorial-btn">Advanced Tutorial</button>
<button data-type="switch" class="tutorial-btn">Switch Tutorial</button>
<button data-type="actions" class="tutorial-btn">Actions Tutorial</button>
</div>
</div>
<div class="menu settings">
<p class="menu-header" style="color:#fff;">
<i class="fa fa-chevron-right"></i>
<strong>Settings</strong>
</p>
<div class="elements" style="display: none;">
<button id="toggleGridButton">Toggle Grid</button>
<p style="color:#fff;">Change Router</p>
<select id="connection_router">
<option value="draw2d.layout.connection.ManhattanConnectionRouter">Manhattan</option>
<option value="draw2d.layout.connection.ManhattanBridgedConnectionRouter">Manhattan Bridged</option>
<option value="draw2d.layout.connection.InteractiveManhattanConnectionRouter">Manhattan Interactive
</option>
<option value="draw2d.layout.connection.CircuitConnectionRouter">Circuit</option>
<option value="draw2d.layout.connection.DirectRouter">Direct</option>
<option value="draw2d.layout.connection.SplineConnectionRouter" selected="selected">Spline</option>
<option value="draw2d.layout.connection.MazeConnectionRouter">Maze</option>
<option value="draw2d.layout.connection.SketchConnectionRouter">Sketch</option>
</select>
</div>
</div>
</div>
<dialog id="prompt-node-type" role="dialog" aria-labelledby="prompt-dialog-heading">
Node type (intel or xilinx) unclear. Select<br />
<p>
<button id="prompt-node-type-intel" name="intel">intel</button>
<button id="prompt-node-type-xilinx" name="xilinx">xilinx</button>
</p>
</dialog>
<!-- Custom Topologies Modals -->
<dialog id="ring-topology-modal" class="topology-modal" role="dialog" aria-labelledby="prompt-dialog-heading">
<div class="header">
<div class="title">Ring Topology Modal</div>
<i class="fa fa-close"></i>
</div>
<form onsubmit="event.preventDefault(); createCustomTopology(event, 'ring')">
<div class="body">
<label for="ringType">
Select the ring type
<select name="ringType">
<option value="ringO">RingO</option>
<option value="ringZ">RingZ</option>
<option value="ringN">RingN</option>
</select>
</label>
<label for="nodesNb">
Enter the number of nodes
<input type="number" name="nodesNb" placeholder="Number of nodes" required>
</label>
</div>
<div class="buttons">
<div class="button cancel">Cancel</div>
<button class="button submit" type="submit">Submit</button>
</div>
</form>
</dialog>
<dialog id="torus-topology-modal" class="topology-modal" role="dialog" aria-labelledby="prompt-dialog-heading">
<div class="header">
<div class="title">Torus Topology Modal</div>
<i class="fa fa-close"></i>
</div>
<form onsubmit="event.preventDefault(); createCustomTopology(event, 'torus')">
<div class="body">
<label for="torusType">
Select the torus type
<select name="torusType">
<option value="torus2">torus2</option>
<option value="torus3">torus3</option>
<option value="torus4">torus4</option>
<option value="torus5">torus5</option>
<option value="torus6">torus6</option>
</select>
</label>
<label for="nodesNb">
Enter the number of nodes
<input type="number" name="nodesNb" placeholder="Number of nodes" required>
</label>
<label for="viewMode">
<input type="checkbox" name="viewMode" id="viewMode">
FPGA view?
</label>
</div>
<div class="buttons">
<div class="button cancel">Cancel</div>
<button class="button submit" type="submit">Submit</button>
</div>
</form>
</dialog>
</body>
</html>