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