--- trunk/public_html/koha.js 2009/03/28 17:20:35 75
+++ trunk/public_html/koha.js 2009/03/28 17:53:26 76
@@ -6,17 +6,30 @@
var a = data.split('|');
console.info('process', a);
$('#test').html( a[1] );
- if ( a[0] > 0 && ! rfid_selected[ a[0] ] ) {
- $('#koha').append( '
Loading item '+a[0]+' from Koha
' )
- $.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'));
+ 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');
+ } else {
+ $('#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 ) {
+ 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'));
+ }
+
+ rfid_selected[ id ] = data;
});
- } else if ( a[0] < 0 ) {
+ } else if ( id < 0 ) {
console.info("No RFID chips in range");
}
};