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_selected[ a[0] ] ) { |
|
10 |
$('#koha').append( '<div class="item" id="' + a[0] + '">Loading item '+a[0]+' from Koha</div>' ) |
var id = a[0]; |
11 |
$.get( '/koha/' + a[0], function(data) { |
|
12 |
$('#'+a[0]).html( data ); |
if ( id > 0 ) { |
13 |
|
var item = $('#item'+id); |
14 |
rfid_selected[ a[0] ]++; |
if ( item.length > 0 ) { |
15 |
var e = $('#clear_selection'); |
console.error('element', id, 'allready exists', item); |
16 |
e.attr( 'value', parseInt( e.attr('value') ) + 1 ); |
} else { |
17 |
console.info('loaded item', a[0], data, 'selected', e.attr('value')); |
$('#koha').append( '<div class="item" id="item'+id+'">Loading item '+id+' from Koha</div>' ) |
18 |
}); |
console.debug('created element', id); |
19 |
} else if ( a[0] < 0 ) { |
|
20 |
console.info("No RFID chips in range"); |
$.get( '/koha/' + id, function(data) { |
21 |
|
item.html( data ); |
22 |
|
|
23 |
|
var e = $('#clear_selection'); |
24 |
|
e.attr( 'value', parseInt( e.attr('value') ) + 1 ); |
25 |
|
console.info('loaded item:', id, 'total selected:', e.attr('value')); |
26 |
|
|
27 |
|
rfid_selected[ id ] = data; |
28 |
|
$('#clear_selection').click( function() { |
29 |
|
rfid_selected[id] = undefined; |
30 |
|
item.remove(); |
31 |
|
}); |
32 |
|
}); |
33 |
|
} |
34 |
|
item.addClass('in_range'); |
35 |
|
} else if ( id < 0 ) { |
36 |
|
id = Math.abs( parseInt( id )); |
37 |
|
var item = $('#item'+id); |
38 |
|
if ( item.length > 0 ) { |
39 |
|
console.info('item', item, 'out of range'); |
40 |
|
item.removeClass('in_range'); |
41 |
|
} else { |
42 |
|
console.error('item', item, 'not found on page'); |
43 |
|
} |
44 |
} |
} |
45 |
}; |
}; |
46 |
|
|