projects
/
Biblio-RFID.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
better info message
[Biblio-RFID.git]
/
examples
/
selfcheck.js
diff --git
a/examples/selfcheck.js
b/examples/selfcheck.js
index
9436d79
..
ec6ee52
100644
(file)
--- a/
examples/selfcheck.js
+++ b/
examples/selfcheck.js
@@
-17,6
+17,16
@@
var state;
var scan_timeout;
var pending_jsonp = 0;
var scan_timeout;
var pending_jsonp = 0;
+// timeout warning dialog
+var tick_timeout = 25; // s
+var tick_warning = 10; // s
+var tick = 0;
+
+function start_timeout() {
+ $('#timeout').hide();
+ tick = Math.round( tick_timeout * ( 1000 / tag_rescan ) );
+}
+
function change_page(new_state) {
if ( state != new_state ) {
function change_page(new_state) {
if ( state != new_state ) {
@@
-61,9
+71,16
@@
function change_page(new_state) {
if ( state == 'error' ) {
window.setTimeout(function(){
if ( state == 'error' ) {
window.setTimeout(function(){
- change_page('start');
+ //change_page('start');
+ location.reload();
},error_timeout);
}
},error_timeout);
}
+
+ if ( state == 'circulation' || state == 'borrower_info' ) {
+ start_timeout();
+ } else {
+ tick = 0; // timeout disabled
+ }
}
}
}
}
@@
-124,6
+141,18
@@
function scan_tags() {
$.getJSON("/scan?callback=?", got_visible_tags);
}
$.getJSON("/scan?callback=?", got_visible_tags);
}
+ if ( tick > 0 ) {
+ if ( tick < tick_warning * ( 1000 / tag_rescan ) ) {
+ $('#tick').html( Math.round( tick * tag_rescan / 1000 ) );
+ $('#timeout').show();
+ }
+ tick--;
+ if ( tick == 0 ) {
+ $('#timeout').hide();
+ change_page('end');
+ }
+ }
+
scan_timeout = window.setTimeout(function(){
scan_tags();
},tag_rescan); // re-scan every 200ms
scan_timeout = window.setTimeout(function(){
scan_tags();
},tag_rescan); // re-scan every 200ms
@@
-193,10
+222,15
@@
function circulation( barcode, sid ) {
pending_jsonp++;
$.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+sid , function( data ) {
console.info( circulation_type, data );
pending_jsonp++;
$.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+sid , function( data ) {
console.info( circulation_type, data );
- $('ul#books').append('<li>' + ( data['AJ'] || barcode ) + ( data['AF'] ? ' <b>' + data['AF'] + '</b>' : '' ) + '</li>');
+
+ var color = 'red';
+ if ( data['fixed'].substr(2,1) == 1 ) color='green';
+
+ $('ul#books').append('<li style="color:'+color+'">' + ( data['AJ'] || barcode ) + ( data['AF'] ? ' <b>' + data['AF'] + '</b>' : '' ) + '</li>');
$('#books_count').html( $('ul#books > li').length );
console.debug( book_barcodes );
pending_jsonp--;
$('#books_count').html( $('ul#books > li').length );
console.debug( book_barcodes );
pending_jsonp--;
+ start_timeout(); // reset timeout
}).fail( function() {
change_page('error');
pending_jsonp--;
}).fail( function() {
change_page('error');
pending_jsonp--;