/[RFID]/koha/koha-rfid.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /koha/koha-rfid.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (hide annotations)
Thu Feb 11 20:59:42 2010 UTC (14 years, 3 months ago) by dpavlin
File MIME type: application/javascript
File size: 1880 byte(s)
use new /secure.js REST API

1 dpavlin 69
2     // XXX dpavlin: RFID support for Koha
3    
4 dpavlin 72 function rfid_secure(barcode,sid,val) {
5     console.debug('rfid_secure', barcode, sid, val);
6     $('table tr td a:contains(130)').each( function(i,o) {
7     var possible = $(o).text();
8     console.debug(i,o,possible, barcode);
9     if ( possible == barcode ) {
10     $.getJSON( 'http://localhost:9000/secure.js?' + sid + '=' + val + ';callback=?' )
11     }
12     });
13     }
14    
15 dpavlin 69 function rfid_scan(data,textStatus) {
16     // console.debug( 'rfid_scan', data, textStatus );
17    
18     var span = $('span#rfid');
19     if ( span.size() == 0 ) {
20     $('ul#i18nMenu').append('<li><span id=rfid>RFID reader found<span>');
21     span = $('span#rfid');
22     }
23    
24     if ( data.tags ) {
25     if ( data.tags.length === 1 ) {
26 dpavlin 70 var t = data.tags[0];
27     if ( span.text() != t.content ) {
28     if ( t.content.substr(0,3) == '130' ) {
29     var color = 'blue';
30     if ( t.security.toUpperCase() == 'DA' ) color = 'red';
31     if ( t.security.toUpperCase() == 'D7' ) color = 'green';
32     span.text( t.content ).css('color', color);
33     $('input[name=barcode]').val( t.content );
34 dpavlin 72
35     var url = document.location.toString();
36     if ( url.substr(-14,14) == 'circulation.pl' )
37     rfid_secure( t.content, t.sid, 'D7' );
38     if ( url.substr(-10,10) == 'returns.pl' )
39     rfid_secure( t.content, t.sid, 'DA' );
40    
41 dpavlin 69 } else {
42 dpavlin 72 span.text( t.content ).css('color', 'blue' );
43 dpavlin 70 $('input[name=findborrower]').val( t.content );
44 dpavlin 69 }
45     }
46     } else {
47     var error = data.tags.length + ' tags near reader: ';
48     $.each( data.tags, function(i,tag) { error += tag.content + ' '; } );
49     span.text( error ).css( 'color', 'red' );
50     }
51 dpavlin 72
52 dpavlin 69 } else {
53     span.text( 'no tags in range' ).css('color','gray');
54     }
55    
56     window.setTimeout( function() {
57     $.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
58     }, 1000 ); // 1000ms
59     }
60    
61     $(document).ready( function() {
62     $.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
63     });

  ViewVC Help
Powered by ViewVC 1.1.26