call rfid_secure JSONP only if security changed
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Apr 2014 11:57:34 +0000 (13:57 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 25 Mar 2019 14:43:15 +0000 (15:43 +0100)
ffzg/rfid/koha-rfid.js

index 5bb8624..8f9ce3c 100644 (file)
@@ -27,10 +27,11 @@ console.debug(i,o,possible, barcode);
        return found;
 }
 
-function rfid_secure(barcode,sid,val) {
-       console.debug('rfid_secure', barcode, sid, val);
-       if ( barcode_on_screen(barcode) )
-               $.getJSON( 'http://localhost:9000/secure.js?' + sid + '=' + val + ';callback=?' )
+function rfid_secure(t,val) {
+       if ( t.security.toUpperCase() == val.toUpperCase() ) return;
+       console.debug('rfid_secure', t.content, t.sid, val);
+       if ( barcode_on_screen(t.content) )
+               $.getJSON( 'http://localhost:9000/secure.js?' + t.sid + '=' + val + ';callback=?' )
 }
 
 var rfid_reset_field = false;
@@ -67,10 +68,8 @@ function rfid_scan(data,textStatus) {
 
                                } 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' );
+                                       if ( circulation ) rfid_secure( t, 'D7' );
+                                       if ( returns     ) rfid_secure( t, 'DA' );
 
                                        var color = 'blue';
                                        if ( t.security.toUpperCase() == 'DA' ) color = 'red';
@@ -90,7 +89,9 @@ function rfid_scan(data,textStatus) {
                                } else {
                                        span.text( t.content ).css('color', 'blue' );
 
-                                       if ( url.substr(-14,14) != 'circulation.pl' || $('form[name=mainform]').size() == 0 ) {
+                                       if ( $('.patroninfo:contains('+t.content+')').length == 1 ) {
+                                               console.debug('not submitting', t.contains);
+                                       } else {
                                                rfid_refresh = 0;
                                                rfid_reset_field = 'findborrower';
                                                $('input[name=findborrower]').val( t.content )