Biblio-RFID
view release on metacpan or search on metacpan
examples/koha-rfid.js view on Meta::CPAN
if ( data.tags ) {
if ( data.tags.length === 1 ) {
var t = data.tags[0];
// if ( span.text() != t.content ) {
if ( 1 ) { // force update of security
var url = document.location.toString();
var circulation = url.substr(-14,14) == 'circulation.pl';
var returns = url.substr(-10,10) == 'returns.pl';
if ( t.content.length == 0 ) { // empty tag
span.text( t.sid + ' empty' ).css('color', 'red' );
} else if ( t.content.substr(0,3) == '130' ) { // books
if ( circulation )
rfid_secure( t.content, t.sid, 'D7' );
if ( returns )
rfid_secure( t.content, t.sid, 'DA' );
var color = 'blue';
if ( t.security.toUpperCase() == 'DA' ) color = 'red';
if ( t.security.toUpperCase() == 'D7' ) color = 'green';
span.text( t.content ).css('color', color);
if ( ! barcode_on_screen( t.content ) ) {
rfid_reset_field = 'barcode';
var i = $('input[name=barcode]:last');
if ( i.val() != t.content )
i.val( t.content )
.closest('form').submit();
}
} else {
span.text( t.content ).css('color', 'blue' );
if ( url.substr(-14,14) != 'circulation.pl' || $('form[name=mainform]').size() == 0 ) {
rfid_reset_field = 'findborrower';
$('input[name=findborrower]').val( t.content )
.parent().submit();
}
}
}
} else {
var error = data.tags.length + ' tags near reader: ';
$.each( data.tags, function(i,tag) { error += tag.content + ' '; } );
span.text( error ).css( 'color', 'red' );
}
} else {
span.text( 'no tags in range' ).css('color','gray');
if ( rfid_reset_field ) {
$('input[name='+rfid_reset_field+']').val( '' );
rfid_reset_field = false;
}
}
window.setTimeout( function() {
$.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
}, 1000 ); // 1000ms
}
$(document).ready( function() {
$.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
});
( run in 0.697 second using v1.01-cache-2.11-cpan-ceb78f64989 )