projects
/
koha.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
603975b
)
RFID: remove polling of RFID reader
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Wed, 8 Feb 2017 18:18:11 +0000
(19:18 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 25 Mar 2019 14:43:16 +0000
(15:43 +0100)
ffzg/rfid/koha-rfid.js
patch
|
blob
|
history
diff --git
a/ffzg/rfid/koha-rfid.js
b/ffzg/rfid/koha-rfid.js
index
351d6ad
..
f1ee765
100644
(file)
--- a/
ffzg/rfid/koha-rfid.js
+++ b/
ffzg/rfid/koha-rfid.js
@@
-9,12
+9,6
@@
*
* to provide overlay for tags in range and emulate form fill for Koha Library System
* which allows check-in and checkout-operations without touching html interface
*
* to provide overlay for tags in range and emulate form fill for Koha Library System
* which allows check-in and checkout-operations without touching html interface
- *
- * You will have to inject remote javascript in Koha intranetuserjs using:
-
-// inject JavaScript RFID support
-$.getScript('http://localhost:9000/examples/koha-rfid.js');
-
*/
function barcode_on_screen(barcode) {
*/
function barcode_on_screen(barcode) {
@@
-29,8
+23,10
@@
function barcode_on_screen(barcode) {
var rfid_refresh = 1000; // ms
var rfid_count_timeout = 30; // number of times to scan reader before turning off
var rfid_refresh = 1000; // ms
var rfid_count_timeout = 30; // number of times to scan reader before turning off
+rfid_count_timeout = 0; // FIXME disable
+
function rfid_secure_json(t,val, success) {
function rfid_secure_json(t,val, success) {
- if ( t.security.toUpperCase() == val.toUpperCase() ) return;
+ if ( t.security.toUpperCase() == val.toUpperCase() ) return
success()
;
rfid_refresh = 0; // disable rfid pull until secure call returns
console.log('rfid_secure_json', t, val);
$.getJSON( '///localhost:9000/secure.js?' + t.sid + '=' + val + ';callback=?', success );
rfid_refresh = 0; // disable rfid pull until secure call returns
console.log('rfid_secure_json', t, val);
$.getJSON( '///localhost:9000/secure.js?' + t.sid + '=' + val + ';callback=?', success );
@@
-65,7
+61,7
@@
function rfid_scan(data,textStatus) {
// span = $('ul#i18nMenu').append('<li><span id=rfid>RFID reader found<span>');
// alternative pop-up version
// 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: 0; 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>');
+ span = $('#breadcrumbs').append('<div id="rfid_popup" style="position: fixed; bottom: 0; right:
0; background: #fff; border: 0.25em solid #ff0; padding: 0.25em; opacity: 0.9; z-index: 1040; font-size: 200%"><label for="rfid_active"><input type=checkbox id="rfid_active"><!-- local_ip --> <span id="rfid">RFID reader</span><span id="rfid-info">
</span></label></div>');
if ( rfid_count ) $('input#rfid_active').attr('checked',true);
$('input#rfid_active').click(activate_scan_tags);
}
if ( rfid_count ) $('input#rfid_active').attr('checked',true);
$('input#rfid_active').click(activate_scan_tags);
}
@@
-75,6
+71,7
@@
function rfid_scan(data,textStatus) {
span = $('div#login').prepend('<span id=rfid>RFID reader found</span>');
span = $('span#rfid');
span = $('div#login').prepend('<span id=rfid>RFID reader found</span>');
span = $('span#rfid');
+ var info = $('span#rfid-info');
if ( data.tags ) {
if ( data.tags ) {
@@
-89,9
+86,12
@@
function rfid_scan(data,textStatus) {
// var tab_active = $("#header_search .ui-tabs-panel:not(.ui-tabs-hide)").prop('id');
var tab_active = $("#header_search li[aria-selected=true]").attr('aria-controls');
console.debug('tab_active', tab_active);
// var tab_active = $("#header_search .ui-tabs-panel:not(.ui-tabs-hide)").prop('id');
var tab_active = $("#header_search li[aria-selected=true]").attr('aria-controls');
console.debug('tab_active', tab_active);
- var circulation = script_name == 'circulation.pl' || tab_active == 'circ_search' ;
- var returns = script_name == 'returns.pl' || tab_active == 'checkin_search';
- console.debug('script_name', script_name, 'circulation', circulation, 'returns', returns);
+ var action =
+ ( script_name == 'circulation.pl' || tab_active == 'circ_search' ) ? 'circulation' :
+ ( script_name == 'returns.pl' || tab_active == 'checkin_search') ? 'checkin' :
+ 'scan';
+ console.debug('script_name', script_name, 'action', action);
+ info.text(action);
if ( t.content.length == 0 || t.content == 'UUUUUUUUUUUUUUUU' ) { // blank tag (3M is UUU....)
if ( t.content.length == 0 || t.content == 'UUUUUUUUUUUUUUUU' ) { // blank tag (3M is UUU....)
@@
-118,19
+118,23
@@
function rfid_scan(data,textStatus) {
$('input[name=q]')
.css('background', '#ff0')
.val( 'bc:' + t.content )
$('input[name=q]')
.css('background', '#ff0')
.val( 'bc:' + t.content )
- .closest('form').submit();
+
;//
.closest('form').submit();
}
}
}
}
- if ( ! barcode_on_screen( t.content ) ||
returns
) {
+ if ( ! barcode_on_screen( t.content ) ||
action == 'returns' || action == 'checkin'
) {
rfid_reset_field = 'barcode';
// return must be first to catch change of tab to check-in
rfid_reset_field = 'barcode';
// return must be first to catch change of tab to check-in
- var afi_secure = returns ? 'DA' : 'D7';
- var form_selector = returns ? 'first' : 'last';
- if ( returns || circulation ) {
-
- if ( circulation && $('#circ_needsconfirmation').length > 0 ) {
+ var afi_secure =
+ action == 'returns' ? 'DA' :
+ action == 'checkin' ? 'DA' :
+ action == 'FIXME' ? 'D7' :
+ t.security;
+ var form_selector = action == 'returns' ? 'first' : 'last';
+ if ( action == 'returns' || action == 'circulation' || action == 'checkin' ) {
+
+ if ( action == 'circulation' && $('#circ_needsconfirmation').length > 0 ) {
console.log("in circulation, but needs confirmation");
} else {
var i = $('input[name=barcode]:focus');
console.log("in circulation, but needs confirmation");
} else {
var i = $('input[name=barcode]:focus');
@@
-142,18
+146,18
@@
function rfid_scan(data,textStatus) {
i = $('input[name=barcode]:'+form_selector);
}
if ( i.val() != t.content ) {
i = $('input[name=barcode]:'+form_selector);
}
if ( i.val() != t.content ) {
- i.css('background', '#0ff' )
- .val( t.content );
+ i.css('background', '#0ff' );
rfid_secure_json( t, afi_secure, function(data) {
console.log('secure', afi_secure, data);
rfid_secure_json( t, afi_secure, function(data) {
console.log('secure', afi_secure, data);
- $.cookie('rfid_count', rfid_count_timeout);
+ $.cookie('rfid_count',
0); // FIXME once? to see change
rfid_count_timeout);
rfid_refresh = 0;
i.css('background',
afi_secure == 'DA' ? '#f00' :
afi_secure == 'D7' ? '#0f0' :
rfid_refresh = 0;
i.css('background',
afi_secure == 'DA' ? '#f00' :
afi_secure == 'D7' ? '#0f0' :
- '#0f
0
'
+ '#0f
f
'
)
)
- .closest('form').submit();
+ .val( t.content )
+ ; //.closest('form').submit();
});
}
}
});
}
}
@@
-177,7
+181,7
@@
function rfid_scan(data,textStatus) {
$('input[name=findborrower]')
.css('background', '#ff0')
.val( t.content )
$('input[name=findborrower]')
.css('background', '#ff0')
.val( t.content )
- .parent().submit();
+
;//
.parent().submit();
}
}
}
}
}
}
@@
-204,7
+208,7
@@
function rfid_scan(data,textStatus) {
}
$.cookie('rfid_count', rfid_count);
}
$.cookie('rfid_count', rfid_count);
-
+/*
if (rfid_refresh > 1 && $('input#rfid_active').attr('checked') ) {
window.setTimeout( function() {
if ( rfid_refresh ) {
if (rfid_refresh > 1 && $('input#rfid_active').attr('checked') ) {
window.setTimeout( function() {
if ( rfid_refresh ) {
@@
-219,6
+223,7
@@
function rfid_scan(data,textStatus) {
}
$('#rfid_popup').css('border','3px solid #fff');
}
$('#rfid_popup').css('border','3px solid #fff');
+*/
}
function scan_tags() {
}
function scan_tags() {
@@
-248,7
+253,7
@@
function activate_scan_tags() {
$(document).ready( function() {
console.log('rfid_active', $('input#rfid_active').attr('checked') );
$(document).ready( function() {
console.log('rfid_active', $('input#rfid_active').attr('checked') );
- scan_tags();
+ scan_tags();
// FIXME should we trigger this on page load even if rfid is not active
// circulation keyboard shortcuts (FFZG specific!)
shortcut.add('Alt+r', function() { set_rfid_active(true); } );
// circulation keyboard shortcuts (FFZG specific!)
shortcut.add('Alt+r', function() { set_rfid_active(true); } );
@@
-256,6
+261,14
@@
$(document).ready( function() {
shortcut.add('Alt+k', function() { set_rfid_active(false) } );
shortcut.add('Alt+y', function() { set_rfid_active(true); } ); // renew
shortcut.add('Alt+k', function() { set_rfid_active(false) } );
shortcut.add('Alt+y', function() { set_rfid_active(true); } ); // renew
+ // send RFID tag to currently focused field on screen
+ shortcut.add('Alt+s', function() {
+ var el = $('input:focus');
+ var tag = $('span#rfid').text().split(/\s+/)[0];
+ console.log('send', el, tag);
+ if ( el && tag ) el.css('background', '#ff0').val( tag );
+ } );
+
// intranet cataloging
shortcut.add('F4', function() {
// extract barcode from window title
// intranet cataloging
shortcut.add('F4', function() {
// extract barcode from window title