--- /dev/null
+$(document).ready(function(){
+
+koha_login = $('.loggedinusername').text();
+console.log('koha_login', koha_login);
+
+$.getScript('/rfid/register.pl?intranet-js=1&koha_login='+koha_login);
+
+});
-0. add new rfid registration vhost to apache config
-dpavlin@koha-dev:/srv/koha_ffzg/ffzg/rfid(koha_ffzg) $ sudo ln -sf /srv/koha_ffzg/ffzg/rfid/rfid.koha-dev.vbz.ffzg.hr.conf /etc/apache2/sites-available/
-dpavlin@koha-dev:/srv/koha_ffzg/ffzg/rfid(koha_ffzg) $ sudo a2ensite rfid.koha-dev.vbz.ffzg.hr
-Enabling site rfid.koha-dev.vbz.ffzg.hr.
-To activate the new configuration, you need to run:
- service apache2 reload
-dpavlin@koha-dev:/srv/koha_ffzg/ffzg/rfid(koha_ffzg) $ sudo service apache2 reload
+1. Configure Apache apache-rfid.conf
+2. Koha system preference IntranetUserJS.js
-1. add following to IntranetUserJS system preferences in Koha:
-$.getScript('http://rfid.koha-dev.vbz.ffzg.hr/register.pl?intranet-js=1');
+3. start RFID reader and point it to your koha registration:
-
-2. start RFID reader and point it to your koha registration:
-
-pi@rfid0 ~/Biblio-RFID $ RFID_URL=http://rfid.koha-dev.vbz.ffzg.hr KOHA_URL=http://ffzg.koha-dev.rot13.org:8080 ./scripts/RFID-JSONP-server.pl
+pi@rfid0 ~/Biblio-RFID $ RFID_URL=http://rfid.koha-dev.vbz.ffzg.hr KOHA_URL=https://ffzg.koha-dev.rot13.org:8443 ./scripts/RFID-JSONP-server.pl
http://ffzg.koha-dev.rot13.org:8080 at ./scripts/RFID-JSONP-server.pl line 31.
{ _last => "eth0", eth0 => "10.60.1.210", lo => "127.0.0.1" } at ./scripts/RFID-JSONP-server.pl line 368, <DATA> line 1.
GET http://rfid.koha-dev.vbz.ffzg.hr/register.pl?local_ip=10.60.1.210 at ./scripts/RFID-JSONP-server.pl line 375, <DATA> line 1.
Server ./scripts/RFID-JSONP-server.pl ready at http://:9000
-3. check under /srv/koha_ffzg/ffzg/rfid/ip/ for your client IP address, which should have IP address
+4. check under /srv/koha_ffzg/ffzg/rfid/ip/ for your client IP address, which should have IP address
of RFID reader inside it
+
+
+5. assign new reader to user
+
+cp ip/10.60.1.210 user/dpavlin@ffzg.hr
--- /dev/null
+# include after ScriptAlias and before first existing RewriteCond
+# Include /srv/koha_ffzg/ffzg/rfid/apache-rfid.conf
+
+ScriptAlias /rfid/register.pl "/srv/koha_ffzg/ffzg/rfid/register.pl"
+RewriteRule ^/rfid/to/(.+) http://$1 [P,L]
if ( t.security.toUpperCase() == val.toUpperCase() ) return;
rfid_refresh = 0; // disable rfid pull until secure call returns
console.log('rfid_secure_json', t, val);
- $.getJSON( 'http://localhost:9000/secure.js?' + t.sid + '=' + val + ';callback=?', success );
+ $.getJSON( '///localhost:9000/secure.js?' + t.sid + '=' + val + ';callback=?', success );
}
function rfid_secure_check(t,val) {
function rfid_scan(data,textStatus) {
- console.debug( 'rfid_scan', data, textStatus );
+ $.cookie('rfid', 'localhost'); // set cookie
+
+ console.debug( 'rfid_scan', data, textStatus, $.cookie('rfid') );
rfid_current_sid = false;
rfid_blank_sid = false;
var span = $('span#rfid');
- if ( span.size() == 0 ) // insert last in language bar on bottom
+ if ( span.size() == 0 ) {
+ // insert last in language bar on bottom
// span = $('ul#i18nMenu').append('<li><span id=rfid>RFID reader found<span>');
- span = $('#breadcrumbs').append('<div id="rfid_popup" style="position: fixed; bottom: 0; right: 0; background: #fff; border: 3px solid #ff0; padding: 1em; opacity: 0.7; z-index: 10;"><span id="rfid">RFID reader</span></div>');
+
+ // 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>');
+ $('input#rfid_active').attr('checked',true);
+ $('input#rfid_active').click(scan_tags);
+ }
+
if ( span.size() == 0 ) // or before login on top
span = $('div#login').prepend('<span id=rfid>RFID reader found</span>');
}
}
- if (rfid_refresh > 1) {
+ if (rfid_refresh > 1 && $('input#rfid_active').attr('checked') == 'checked' ) {
window.setTimeout( function() {
- $.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
+ $('#rfid_popup').css('border','3px solid #fff');
+ $.getJSON("///localhost:9000/scan?callback=?", rfid_scan);
}, rfid_refresh );
} else {
console.debug('rfid_refresh disabled',rfid_refresh);
}
+
+ $('#rfid_popup').css('border','3px solid #ff0');
+}
+
+function scan_tags() {
+ console.info('scan_tags');
+ $.getJSON("///localhost:9000/scan?callback=?", rfid_scan);
}
$(document).ready( function() {
- $.getJSON("http://localhost:9000/scan?callback=?", rfid_scan);
+ console.log('rfid_active', $('input#rfid_active').attr('checked') );
+
+ scan_tags();
+ // intranet catalogingdd
shortcut.add('F4', function() {
// extract barcode from window title
var barcode = document.title.split(/\(barcode\s+#|\)/)[1];
}
console.debug('program barcode', barcode, 'to', rfid_blank_sid);
- $.getJSON( 'http://localhost:9000/program?' + rfid_blank_sid + '=' + barcode + ';callback=?', function(data) {
+ $.getJSON( '///localhost:9000/program?' + rfid_blank_sid + '=' + barcode + ';callback=?', function(data) {
console.info('programmed', rfid_blank_sid, barcode, data);
});
} else {
my $query = new CGI;
+use Data::Dump qw(dump);
+warn "# query ", dump( $query );
+
my $hash = {
remote_host => $query->remote_host,
};
my $dir = $FindBin::Bin;
my $path = "$dir/ip/" . $hash->{remote_host};
+
if ( my $ip = $query->param('local_ip') ) {
$hash->{local_ip} = $ip;
chomp $ip;
$hash->{local_ip} = $ip;
close($fh);
+
+} elsif ( my $koha_login = $query->param('koha_login') ) {
+ my $path = "$dir/user/$koha_login";
+ if ( -e $path ) {
+ open(my $fh, '<', $path);
+ $hash->{local_ip} = <$fh>;
+ close $fh;
+ } else {
+ warn "# no $path";
+ }
+
} else {
warn $hash->{_error} = "ERROR: ", $hash->{remote_host}, " don't have RFID reader assigned";
}
if ( $query->param('intranet-js') ) {
print "Content-type: application/javascript\r\n\r\n";
- open(my $js, '<', 'koha-rfid.js');
- while(<$js>) {
- s/localhost/$hash->{local_ip}/g;
- print;
+
+ if ( my $local_ip = $hash->{local_ip} ) {
+ chomp $local_ip;
+ my $url = "/rfid/to/$local_ip";
+ open(my $js, '<', 'koha-rfid.js');
+ while(<$js>) {
+ s/local_ip/$local_ip/g;
+ s/localhost/$url/g;
+ s{///$url}{$url}g; # relative urls
+ print;
+ }
+ close($js);
+ } else {
+ print 'console.log("no RFID reader for client "'. $hash->{remote_host}, ");\n";
+
}
- close($js);
} else {
print "Content-type: application/json; charset=utf-8\r\n\r\n";
print encode_json $hash;
+ warn "# hash = ",dump($hash);
}