X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=examples%2Fselfcheck.js;h=218bf3aceedf7dd90cd039f0c71922cca727e91d;hb=282b54550a8a651fe528648d40aa7c582d288511;hp=032aa7e2f15e56978a0f339c0bc64ee928c21077;hpb=a02727b7554fb61ae907688c7440e47251afa021;p=Biblio-RFID.git diff --git a/examples/selfcheck.js b/examples/selfcheck.js index 032aa7e..218bf3a 100644 --- a/examples/selfcheck.js +++ b/examples/selfcheck.js @@ -23,6 +23,17 @@ var tick_timeout = 25; // s var tick_warning = 10; // s var tick = 0; +function beep( message ) { + pending_jsonp++; + $.getJSON("/beep/" + message) + .done( function(data) { + pending_jsonp--; + }) + .fail( function(data) { + pending_jsonp--; + }); +} + function start_timeout() { $('#timeout').hide(); tick = Math.round( tick_timeout * ( 1000 / tag_rescan ) ); @@ -74,6 +85,7 @@ function change_page(new_state) { } if ( state == 'error' ) { + beep( 'error page' ); window.setTimeout(function(){ //change_page('start'); location.reload(); @@ -211,10 +223,18 @@ function start( cardnumber, tag ) { console.info('patron', data); fill_in( 'borrower_name', data['AE'] ); fill_in( 'borrower_email', data['BE'] ); - fill_in( 'hold_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 0 * 4 ), 4 ) ) * 1; - fill_in( 'overdue_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 1 * 4 ), 4 ) ) * 1; - fill_in( 'charged_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 2 * 4 ), 4 ) ) * 1; - fill_in( 'fine_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 3 * 4 ), 4 ) ) * 1; + fill_in( 'hold_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 0 * 4 ), 4 ) * 1 ); + //fill_in( 'overdue_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 1 * 4 ), 4 ) * 1 ); + var overdue = data['fixed'].substr( 2 + 14 + 3 + 18 + ( 1 * 4 ), 4 ) * 1; + if ( overdue > 0 ) { + overdue = ''+overdue+''; + beep( 'overdue: ' + overdue ); + } + fill_in( 'overdue_items', overdue ); + fill_in( 'charged_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 2 * 4 ), 4 ) * 1 ); + fill_in( 'fine_items', data['fixed'].substr( 2 + 14 + 3 + 18 + ( 3 * 4 ), 4 ) * 1 ); + + pending_jsonp--; change_page('borrower_info'); }).fail( function(data) { @@ -232,6 +252,7 @@ function circulation( barcode, tag ) { && barcode.length == 10 && barcode.substr(0,3) == 130 && book_barcodes[barcode] != 1 + && tag.reader == '3M810' ) { // book, not seen yet book_barcodes[ barcode ] = 1; pending_jsonp++; @@ -239,13 +260,19 @@ function circulation( barcode, tag ) { console.info( circulation_type, data ); var color = 'red'; - var error = 'Transakcija neuspješna. Odnesite knjige na pult!'; + var message = 'Transakcija neuspješna. Odnesite knjige na pult!'; if ( data['fixed'].substr(2,1) == 1 ) { color='green'; - error = ''; + message = circulation_type == 'checkout' ? 'Posuđeno' : 'Vraćeno'; + } else { + beep( circulation_type + ': ' + data['AF'] ); + } + + if ( data['AF'] ) { + message = data['AF'] + ' ' + message; } - $('ul#books').append('
  • ' + ( data['AJ'] || barcode ) + ( data['AF'] ? ' ' + data['AF'] + ' ' + error : '' ) + '
  • '); + $('ul#books').append('
  • ' + ( data['AJ'] || barcode ) + ' ' + message + '
  • '); $('#books_count').html( $('ul#books > li').length ); console.debug( book_barcodes ); pending_jsonp--;