// configure timeouts
var end_timeout = 3000; // ms from end page to start page
var error_timeout = 5000; // ms from error page to start page
+var tag_rescan = 200; // ms rescan tags every 0.2s
// mock console
if(!window.console) {
new_state = 'circulation'; // page has different name
$('.checkout').hide();
$('.checkin').show();
+ circulation_type = 'checkin';
+ borrower_cardnumber = 0; // fake
} else if ( new_state == 'checkout' ) {
new_state = 'circulation'; // page has different name
$('.checkout').show();
$('.checkin').hide();
+ circulation_type = 'checkout';
}
state = new_state;
console.info('change_page', state);
if ( state == 'start' ) {
- start_scan();
+ circulation_type = 'checkout';
+ book_barcodes = {};
+ $('ul#books').html(''); // clear book list
+ scan_tags();
}
+
if ( state == 'end' ) {
window.setTimeout(function(){
change_page('start');
}
console.debug( 'calling', state, content );
- window[state]( content ); // call function with barcode
+ window[state]( content, tag.sid ); // call function with barcode
}
});
$('#tags').html( html );
scan_timeout = window.setTimeout(function(){
scan_tags();
- },200); // re-scan every 200ms
+ },tag_rescan); // re-scan every 200ms
};
function scan_tags() {
- if ( $('input#pull-reader').attr('checked') ) {
- console.info('scan_tags');
- $.getJSON("/scan?callback=?", got_visible_tags);
- }
-}
-
-function start_scan() {
- $('input#pull-reader').attr('checked', true);
- scan_tags();
-}
-
-function stop_scan() {
- $('input#pull-reader').attr('checked', '');
+ console.info('scan_tags');
+ $.getJSON("/scan?callback=?", got_visible_tags);
}
$(document).ready(function() {
- $('input#pull-reader').click( function() {
+ $('div#tags').click( function() {
scan_tags();
});
- $('div#tags').click( function() {
- $('input#pull-reader').attr('checked', false);
- } );
-
change_page('start');
});
}
borrower_cardnumber = cardnumber;
- circulation_type = 'checkout';
- book_barcodes = {};
change_page('borrower_check');
}
function borrower_check() {
- stop_scan();
-
fill_in( 'borrower_number', borrower_cardnumber );
$.getJSON('/sip2/patron_info/'+borrower_cardnumber)
// nop
}
-function circulation( barcode ) {
+function circulation( barcode, sid ) {
if ( barcode
&& barcode.length == 10
&& barcode.substr(0,3) == 130
- && typeof book_barcodes[barcode] !== undefined
+ && book_barcodes[barcode] != 1
) { // book, not seen yet
- $.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode , function( data ) {
+ $.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+sid , function( data ) {
console.info( circulation_type, data );
- $('ul#books').append('<li>' + data['AJ'] + ' <small>' + data['AF'] + '</small></li>');
+ $('ul#books').append('<li>' + ( data['AJ'] || barcode ) + ' <small>' + data['AF'] + '</small></li>');
book_barcodes[ barcode ] = 1;
console.debug( book_barcodes );
}).fail( function() {
password => 'viva2koha',
loc => 'FFZG',
};
+my $afi = {
+ secure => 0xDA,
+ unsecure => 0xD7,
+};
use Getopt::Long;
warn "PROGRAM $tag $content\n";
$rfid->write_blocks( $tag => $content );
- $rfid->write_afi( $tag => chr( $param->{$p} =~ /^130/ ? 0xDA : 0xD7 ) );
+ $rfid->write_afi( $tag => chr( $param->{$p} =~ /^130/ ? $afi->{secure} : $afi->{unsecure} ) );
}
print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n";
$hash = sip2_message("63000${ts} AO$loc|AA$patron|AC$password|");
} elsif ( $method eq 'checkout' ) {
- my ($patron,$barcode) = split(/\//, $args, 2);
+ my ($patron,$barcode,$sid) = split(/\//, $args, 3);
$hash = sip2_message("11YN${ts} AO$loc|AA$patron|AB$barcode|AC$password|BON|BIN|");
+ if ( substr( $hash->{fixed}, 2, 1 ) == 1 ) {
+ $rfid->write_afi( $sid => chr( $afi->{unsecure} ) );
+ }
} elsif ( $method eq 'checkin' ) {
- my $barcode = $args;
+ my ($patron,$barcode,$sid) = split(/\//, $args, 3);
$hash = sip2_message("09N${ts}${ts}AP|AO${loc}|AB$barcode|AC|BIN|");
+ if ( substr( $hash->{fixed}, 2, 1 ) == 1 ) {
+ $rfid->write_afi( $sid => chr( $afi->{secure} ) );
+ }
} else {
print $client "HTTP/1.0 500 $method not implemented\r\n\r\n";
}