-
Notifications
You must be signed in to change notification settings - Fork 6
/
feeder.js
27 lines (23 loc) · 898 Bytes
/
feeder.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
(function (global, $, undefined) {
function main() {
var $input = $('#textInput'),
$results = $('#results');
var ws = new WebSocket("ws://localhost:8080/ws");
$input.keyup(function(ev) {
var msg = { term: ev.target.value };
ws.send(JSON.stringify(msg));
});
ws.onmessage = function(msg) {
var value = JSON.parse(msg.data);
if (value === "clear") {$results.empty(); return;}
// Append the results
$('<li><h3><a tabindex="-1" href="' + value.link +
'">' + value.name +'</a></h3> <p> Description : ' + value.description +
'</p><p> Language : ' + value.language +
'</p><p> Stars : ' + value.stars + '</p></li>'
).appendTo($results);
$results.show();
}
}
main();
}(window, jQuery));