-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscript.js
41 lines (40 loc) · 983 Bytes
/
script.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
jQuery(function($, undefined) {
$('#term_demo').terminal(function(command, term) {
if (command !== '') {
try {
$.ajax("/api?query=" + command)
.done(function(msg) {
var content = $('#content');
content.empty();
var table = $('<table class="data">');
var row = $('<tr class="header">');
for (var i = 0; i < msg.headers.length; i++) {
var header = $('<th>');
header.append(msg.headers[i]);
row.append(header);
}
table.append(row);
for (var i = 0; i < msg.data.length; i++) {
row = $('<tr class="row">');
for (j = 0; j < msg.data[i].length; j++) {
var cell = $('<td class="cell">');
cell.append(msg.data[i][j]);
row.append(cell);
}
table.append(row);
}
content.append(table);
});
} catch(e) {
term.error(new String(e));
}
} else {
term.echo('');
}
}, {
greetings: 'KSQL - Kubernetes SQL',
name: 'ksql',
height: 100,
prompt: '> '
});
});