RFID add renew shortcut
[koha.git] / ffzg / rfid / koha-rfid.js
index e50240b..4c6a00a 100644 (file)
@@ -68,7 +68,7 @@ function rfid_scan(data,textStatus) {
 //             span = $('ul#i18nMenu').append('<li><span id=rfid>RFID reader found<span>');
 
                // alternative pop-up version
-               span = $('#breadcrumbs').append('<div id="rfid_popup" style="position: fixed; bottom: 3em; right: 1em; background: #fff; border: 3px solid #ff0; padding: 1em; opacity: 0.7; z-index: 10;"><label for="rfid_active"><input type=checkbox id="rfid_active"> local_ip <span id="rfid">RFID reader</span></label></div>');
+               span = $('#breadcrumbs').append('<div id="rfid_popup" style="position: fixed; bottom: 3em; right: 1em; background: #fff; border: 3px solid #ff0; padding: 1em; opacity: 0.7; z-index: 1040;"><label for="rfid_active"><input type=checkbox id="rfid_active"> local_ip <span id="rfid">RFID reader</span></label></div>');
                if ( rfid_count ) $('input#rfid_active').attr('checked',true);
                $('input#rfid_active').click(activate_scan_tags);
        }
@@ -112,6 +112,7 @@ function rfid_scan(data,textStatus) {
 
                                        if ( tab_active == 'catalog_search' && script_name != 'moredetail.pl' && $('input#rfid_active').attr('checked') ) {
                                                if ( $('span.term:contains(bc:'+t.content+')').length == 0 ) {
+                                                       $.cookie('rfid_count', rfid_count_timeout);
                                                        $('input[name=q]').val( 'bc:' + t.content ).closest('form').submit();
                                                }
                                        }
@@ -131,6 +132,7 @@ function rfid_scan(data,textStatus) {
                                                                        if ( i.val() != t.content )  {
                                                                                rfid_secure_json( t, afi_secure, function(data) {
                                                                                        console.log('secure', afi_secure, data);
+                                                                                       $.cookie('rfid_count', rfid_count_timeout);
                                                                                        i.val( t.content ).closest('form').submit();
                                                                                });
                                                                        }
@@ -197,24 +199,35 @@ function scan_tags() {
        $.getJSON("///localhost:9000/scan?callback=?", rfid_scan);
 }
 
-function activate_scan_tags() {
-       var active = $('input#rfid_active').attr('checked');
-       if ( ! active ) {
-               $('input#rfid_active').attr('checked',true);
+function set_rfid_active(active) {
+       var input_active = $('input#rfid_active').attr('checked');
+       console.info('set_rfid_active', active);
+       if ( active ) {
                $.cookie('rfid_count', rfid_count_timeout);
                scan_tags();
+               if ( ! input_active ) $('input#rfid_active').attr('checked', true);
+       } else {
+               if ( input_active ) $('input#rfid_active').attr('checked', false);
+               $.cookie('rfid_count', 0);
        }
 }
 
+function activate_scan_tags() {
+       var active = $('input#rfid_active').attr('checked');
+       console.info('activate_scan_tags', active);
+       set_rfid_active(active);
+}
+
 $(document).ready( function() {
        console.log('rfid_active', $('input#rfid_active').attr('checked') );
 
        scan_tags();
 
        // circulation keyboard shortcuts (FFZG specific!)
-       shortcut.add('Alt+r', function() { activate_scan_tags(); } );
-       shortcut.add('Alt+z', function() { activate_scan_tags(); } );
-       shortcut.add('Alt+k', function() { $('input#rfid_active').attr('checked',false) } );
+       shortcut.add('Alt+r', function() { set_rfid_active(true); } );
+       shortcut.add('Alt+z', function() { set_rfid_active(true); } );
+       shortcut.add('Alt+k', function() { set_rfid_active(false) } );
+       shortcut.add('Alt+y', function() { set_rfid_active(true); } ); // renew
 
        // intranet cataloging
        shortcut.add('F4', function() {