From dcbe6fa71342358dcf77e1a90bd9378db5773dc6 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 9 Oct 2014 17:41:52 +0200 Subject: [PATCH] use SmartX tag_type instead of guessing using content --- examples/selfcheck.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/selfcheck.js b/examples/selfcheck.js index 1803949..a9cba91 100644 --- a/examples/selfcheck.js +++ b/examples/selfcheck.js @@ -99,6 +99,8 @@ function got_visible_tags(data,textStatus) { link = 'catalogue/search.pl?q='; } else if ( content.length == 12 && content.substr(0,2) == 20 ) { link = 'members/member.pl?member='; + } else if ( tag.tag_type == 'SmartX' ) { + link = 'members/member.pl?member='; } else { html += 'UNKNOWN TAG '+content; } @@ -111,7 +113,7 @@ function got_visible_tags(data,textStatus) { } console.debug( 'calling', state, content ); - window[state]( content, tag.sid ); // call function with barcode + window[state]( content, tag ); // call function with barcode } }); @@ -179,10 +181,10 @@ var borrower_cardnumber; var circulation_type; var book_barcodes = {}; -function start( cardnumber ) { +function start( cardnumber, tag ) { - if ( cardnumber.length != 12 || cardnumber.substr(0,2) != "20" ) { - console.error(cardnumber, ' is not borrower card'); + if ( tag.tag_type != 'SmartX' && ( cardnumber.length != 12 || cardnumber.substr(0,2) != "20" ) ) { + console.error(cardnumber, 'is not borrower card', tag); return; } @@ -212,7 +214,7 @@ function borrower_info() { // nop } -function circulation( barcode, sid ) { +function circulation( barcode, tag ) { if ( barcode && barcode.length == 10 && barcode.substr(0,3) == 130 @@ -220,7 +222,7 @@ function circulation( barcode, sid ) { ) { // book, not seen yet book_barcodes[ barcode ] = 1; pending_jsonp++; - $.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+sid , function( data ) { + $.getJSON('/sip2/'+circulation_type+'/'+borrower_cardnumber+'/'+barcode+'/'+tag.sid , function( data ) { console.info( circulation_type, data ); var color = 'red'; -- 2.20.1