1 |
// Set this to something unique to this client |
// Set this to something unique to this client |
2 |
|
|
3 |
var rfid_visible = {}; |
var rfid_selected = {}; |
4 |
|
|
5 |
function process(data) { |
function process(data) { |
6 |
var a = data.split('|'); |
var a = data.split('|'); |
7 |
console.info('process', a); |
console.info('process', a); |
8 |
$('#test').html( a[1] ); |
$('#test').html( a[1] ); |
9 |
if ( a[0] > 0 && ! rfid_visible[ a[0] ] ) { |
if ( a[0] > 0 && ! rfid_selected[ a[0] ] ) { |
10 |
$('#koha').append( '<div class="item" id="' + a[0] + '">Loading item '+a[0]+' from Koha</div>' ) |
$('#koha').append( '<div class="item" id="' + a[0] + '">Loading item '+a[0]+' from Koha</div>' ) |
11 |
$('#' + a[0]).load( '/koha/' + a[0] ); |
$.get( '/koha/' + a[0], function(data) { |
12 |
rfid_visible[ a[0] ]++; |
$('#'+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 |
} else if ( a[0] < 0 ) { |
} else if ( a[0] < 0 ) { |
20 |
$('#koha').html( 'No RFID chips in range' ); |
console.info("No RFID chips in range"); |
|
rfid_visible = {}; |
|
21 |
} |
} |
22 |
}; |
}; |
23 |
|
|
43 |
// Start streaming! |
// Start streaming! |
44 |
Meteor.connect(); |
Meteor.connect(); |
45 |
|
|
46 |
|
// 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 |
|
|
54 |
}); |
}); |