--- trunk/public_html/koha.js 2009/03/28 20:53:20 77 +++ trunk/public_html/koha.js 2009/03/28 20:53:45 78 @@ -9,28 +9,38 @@ var id = a[0]; - console.debug( id, rfid_selected[id] === undefined ); - - if ( id > 0 && rfid_selected[ id ] === undefined ) { - if ( $('#'+id).length > 0 ) { - console.error('element', id, 'allready exists'); + if ( id > 0 ) { + var item = $('#item'+id); + if ( item.length > 0 ) { + console.error('element', id, 'allready exists', item); } else { - $('#koha').append( '
Loading item '+id+' from Koha
' ) + $('#koha').append( '
Loading item '+id+' from Koha
' ) console.debug('created element', id); - } - $.get( '/koha/' + id, function(data) { - $('#'+id).html( data ); - if ( rfid_selected[id] === undefined ) { + $.get( '/koha/' + id, function(data) { + item.html( data ); + var e = $('#clear_selection'); e.attr( 'value', parseInt( e.attr('value') ) + 1 ); - console.info('loaded item:', id, ' times:', rfid_selected[ id ], 'total selected:', e.attr('value')); - } + console.info('loaded item:', id, 'total selected:', e.attr('value')); - rfid_selected[ id ] = data; - }); + rfid_selected[ id ] = data; + $('#clear_selection').click( function() { + rfid_selected[id] = undefined; + item.remove(); + }); + }); + } + item.addClass('in_range'); } else if ( id < 0 ) { - console.info("No RFID chips in range"); + id = Math.abs( parseInt( id )); + var item = $('#item'+id); + if ( item.length > 0 ) { + console.info('item', item, 'out of range'); + item.removeClass('in_range'); + } else { + console.error('item', item, 'not found on page'); + } } };