1 |
|
|
2 |
// XXX dpavlin: RFID support for Koha |
// XXX dpavlin: RFID support for Koha |
3 |
|
|
4 |
function rfid_secure(barcode,sid,val) { |
function barcode_on_screen(barcode) { |
5 |
console.debug('rfid_secure', barcode, sid, val); |
var found = 0; |
6 |
$('table tr td a:contains(130)').each( function(i,o) { |
$('table tr td a:contains(130)').each( function(i,o) { |
7 |
var possible = $(o).text(); |
var possible = $(o).text(); |
8 |
console.debug(i,o,possible, barcode); |
console.debug(i,o,possible, barcode); |
9 |
if ( possible == barcode ) { |
if ( possible == barcode ) found++; |
10 |
$.getJSON( 'http://localhost:9000/secure.js?' + sid + '=' + val + ';callback=?' ) |
}) |
11 |
} |
return found; |
12 |
}); |
} |
13 |
|
|
14 |
|
function rfid_secure(barcode,sid,val) { |
15 |
|
console.debug('rfid_secure', barcode, sid, val); |
16 |
|
if ( barcode_on_screen(barcode) ) |
17 |
|
$.getJSON( 'http://localhost:9000/secure.js?' + sid + '=' + val + ';callback=?' ) |
18 |
} |
} |
19 |
|
|
20 |
var rfid_reset_field = false; |
var rfid_reset_field = false; |
31 |
if ( data.tags ) { |
if ( data.tags ) { |
32 |
if ( data.tags.length === 1 ) { |
if ( data.tags.length === 1 ) { |
33 |
var t = data.tags[0]; |
var t = data.tags[0]; |
34 |
if ( span.text() != t.content ) { |
// if ( span.text() != t.content ) { |
35 |
|
if ( 1 ) { // force update of security |
36 |
|
|
37 |
|
var url = document.location.toString(); |
38 |
|
var circulation = url.substr(-14,14) == 'circulation.pl'; |
39 |
|
var returns = url.substr(-10,10) == 'returns.pl'; |
40 |
|
|
41 |
if ( t.content.substr(0,3) == '130' ) { |
if ( t.content.substr(0,3) == '130' ) { |
42 |
|
|
43 |
|
if ( circulation ) |
44 |
|
rfid_secure( t.content, t.sid, 'D7' ); |
45 |
|
if ( returns ) |
46 |
|
rfid_secure( t.content, t.sid, 'DA' ); |
47 |
|
|
48 |
var color = 'blue'; |
var color = 'blue'; |
49 |
if ( t.security.toUpperCase() == 'DA' ) color = 'red'; |
if ( t.security.toUpperCase() == 'DA' ) color = 'red'; |
50 |
if ( t.security.toUpperCase() == 'D7' ) color = 'green'; |
if ( t.security.toUpperCase() == 'D7' ) color = 'green'; |
51 |
span.text( t.content ).css('color', color); |
span.text( t.content ).css('color', color); |
|
$('input[name=barcode]').val( t.content ); |
|
|
rfid_reset_field = 'barcode'; |
|
52 |
|
|
53 |
var url = document.location.toString(); |
if ( ! barcode_on_screen( t.content ) ) { |
54 |
if ( url.substr(-14,14) == 'circulation.pl' ) |
rfid_reset_field = 'barcode'; |
55 |
rfid_secure( t.content, t.sid, 'D7' ); |
var i = $('input[name=barcode]:last'); |
56 |
if ( url.substr(-10,10) == 'returns.pl' ) |
if ( i.val() != t.content ) |
57 |
rfid_secure( t.content, t.sid, 'DA' ); |
i.val( t.content ) |
58 |
|
.closest('form').submit(); |
59 |
|
} |
60 |
|
|
61 |
} else { |
} else { |
62 |
span.text( t.content ).css('color', 'blue' ); |
span.text( t.content ).css('color', 'blue' ); |
63 |
$('input[name=findborrower]').val( t.content ); |
|
64 |
rfid_reset_field = 'findborrower'; |
if ( url.substr(-14,14) != 'circulation.pl' || $('form[name=mainform]').size() == 0 ) { |
65 |
|
rfid_reset_field = 'findborrower'; |
66 |
|
$('input[name=findborrower]').val( t.content ) |
67 |
|
.parent().submit(); |
68 |
|
} |
69 |
} |
} |
70 |
} |
} |
71 |
} else { |
} else { |