--- trunk/public_html/koha.js 2009/03/28 14:21:21 72 +++ trunk/public_html/koha.js 2009/03/28 15:49:36 73 @@ -1,18 +1,23 @@ // Set this to something unique to this client -var rfid_visible = {}; +var rfid_selected = {}; function process(data) { var a = data.split('|'); console.info('process', a); $('#test').html( a[1] ); - if ( a[0] > 0 && ! rfid_visible[ a[0] ] ) { + if ( a[0] > 0 && ! rfid_selected[ a[0] ] ) { $('#koha').append( '
Loading item '+a[0]+' from Koha
' ) - $('#' + a[0]).load( '/koha/' + a[0] ); - rfid_visible[ a[0] ]++; + $.get( '/koha/' + a[0], function(data) { + $('#'+a[0]).html( data ); + + rfid_selected[ a[0] ]++; + var e = $('#clear_selection'); + e.attr( 'value', parseInt( e.attr('value') ) + 1 ); + console.info('loaded item', a[0], data, 'selected', e.attr('value')); + }); } else if ( a[0] < 0 ) { - $('#koha').html( 'No RFID chips in range' ); - rfid_visible = {}; + console.info("No RFID chips in range"); } }; @@ -38,5 +43,12 @@ // Start streaming! Meteor.connect(); + // clear selection + $('#clear_selection').click( function() { + $('#koha').html('No items selected'); + $('#clear_selection').attr('value', '0'); + rfid_selected = {}; + console.debug('clear selection'); + }); });