X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Fselfcheck.js;h=29ec92f31d0de9941f53acaa95dd8f0b82c3211b;hb=c0a67873c977f590916e05d68fc45e2267643d8a;hp=3c825bb18917295a0eb6b1ceccc68c5f8ebbd63b;hpb=5e8fd05605a8f538fb594b77bd3c04c6b9afd11e;p=Biblio-RFID.git diff --git a/examples/selfcheck.js b/examples/selfcheck.js index 3c825bb..29ec92f 100644 --- a/examples/selfcheck.js +++ b/examples/selfcheck.js @@ -16,6 +16,7 @@ if(!window.console) { var state; var scan_timeout; var pending_jsonp = 0; +var only_reader = ''; // timeout warning dialog var tick_timeout = 25; // s @@ -36,11 +37,13 @@ function change_page(new_state) { $('.checkin').show(); circulation_type = 'checkin'; borrower_cardnumber = 0; // fake + only_reader = '/only/3M'; } else if ( new_state == 'checkout' ) { new_state = 'circulation'; // page has different name $('.checkout').show(); $('.checkin').hide(); circulation_type = 'checkout'; + only_reader = '/only/3M'; } state = new_state; @@ -59,6 +62,7 @@ function change_page(new_state) { book_barcodes = {}; $('ul#books').html(''); // clear book list $('#books_count').html( 0 ); + only_reader = ''; scan_tags(); } @@ -134,16 +138,22 @@ function got_visible_tags(data,textStatus) { pending_jsonp--; }; +var wait_counter = 0; + function scan_tags() { if ( pending_jsonp ) { - console.debug('scan_tags disabled ', pending_jsonp, ' requests waiting'); + wait_counter++; + console.debug('scan_tags disabled ', pending_jsonp, ' requests waiting counter', wait_counter); + if ( wait_counter > 3 ) $('#working').show(); } else { - console.info('scan_tags'); + console.info('scan_tags', only_reader); pending_jsonp++; - $.getJSON("/scan?callback=?", got_visible_tags).fail( function(data) { - console.error('scan error'); + $.getJSON("/scan"+only_reader+"?callback=?", got_visible_tags).fail( function(data) { + console.error('scan error pending jsonp', pending_jsonp); pending_jsonp--; }); + wait_counter = 0; + $('#working').hide(); } if ( tick > 0 ) {