1 |
// Set this to something unique to this client |
2 |
|
3 |
var rfid_visible = {}; |
4 |
|
5 |
function process(data) { |
6 |
var a = data.split('|'); |
7 |
console.info('process', a); |
8 |
$('#test').html( a[1] ); |
9 |
if ( a[0] > 0 && ! rfid_visible[ a[0] ] ) { |
10 |
$('#koha').append( '<div class="item" id="' + a[0] + '">Loading item '+a[0]+' from Koha</div>' ) |
11 |
$('#' + a[0]).load( '/koha/' + a[0] ); |
12 |
rfid_visible[ a[0] ]++; |
13 |
} else if ( a[0] < 0 ) { |
14 |
$('#koha').html( 'No RFID chips in range' ); |
15 |
rfid_visible = {}; |
16 |
} |
17 |
}; |
18 |
|
19 |
$(document).ready( function() { |
20 |
|
21 |
var channel = 'test'; |
22 |
|
23 |
Meteor.hostid = '409897502705'; |
24 |
|
25 |
// Our Meteor server is on the data. subdomain |
26 |
Meteor.host = 'data.' + location.hostname; |
27 |
Meteor.port = 4670; |
28 |
|
29 |
// Call the test() function when data arrives |
30 |
Meteor.registerEventCallback("process", process ); |
31 |
|
32 |
console.info('Meteor connect', channel, Meteor.status ); |
33 |
|
34 |
// Join the demo channel and get last five events, then stream |
35 |
Meteor.joinChannel( channel, 5 ); |
36 |
Meteor.mode = 'stream'; |
37 |
|
38 |
// Start streaming! |
39 |
Meteor.connect(); |
40 |
|
41 |
|
42 |
}); |