Biblio-RFID

 view release on metacpan or  search on metacpan

scripts/RFID-JSONP-server.pl  view on Meta::CPAN


</style>
<script type="text/javascript">

// mock console
if(!window.console) {
	window.console = new function() {
		this.info = function(str) {};
		this.debug = function(str) {};
	};
}


function got_visible_tags(data,textStatus) {
	var html = 'No tags in range';
	if ( data.tags ) {
		html = '<ul class="tags">';
		$.each(data.tags, function(i,tag) {
			console.debug( i, tag );
			html += '<li><tt class="' + tag.security + '">' + tag.sid;
			var content = tag.content || tag.borrower.cardnumber;

			if ( content ) {
				html += ' <a href="http://koha.example.com:8080/cgi-bin/koha/';
				if ( tag.type == 1 ) { // book
					html += 'catalogue/search.pl?q=';
				} else {
					html += 'members/member.pl?member=';
				}
				html += content + '" title="lookup in Koha" target="koha-lookup">' + content + '</a>';
				html += '</tt>';
/*
				html += '<form method=get action=program style="display:inline">'
					+ '<input type=hidden name='+tag.sid+' value="blank">'
					+ '<input type=submit value="Blank" onclick="return confirm(\'Blank tag '+tag.sid+'\')">'
					+ '</form>'
				;
*/
			} else {
				html += '</tt>';
				html += ' <form method=get action=program style="display:inline">'
					+ '<!-- <input type=checkbox name=secure value='+tag.sid+' title="secure tag"> -->'
					+ '<input type=text name='+tag.sid+' size=12>'
					+ '<input type=submit value="Program">'
					+ '</form>'
				;
			}
		});
		html += '</ul>';
	}

	var arrows = Array( 8592, 8598, 8593, 8599, 8594, 8600, 8595, 8601 );

	html = '<div class=status>'
		+ textStatus
		+ ' &#' + arrows[ data.time % arrows.length ] + ';'
		+ '</div>'
		+ html
		;
	$('#tags').html( html );
	window.setTimeout(function(){
		scan_tags();
	},200);	// re-scan every 200ms
};

function scan_tags() {
	console.info('scan_tags');
	if ( $('input#pull-reader').attr('checked') )
		$.getJSON("/scan?callback=?", got_visible_tags);
}

$(document).ready(function() {
		$('input#pull-reader').click( function() {
			scan_tags();
		});
		$('input#pull-reader').attr('checked', true); // force check on load

		$('div#tags').click( function() {
			$('input#pull-reader').attr('checked', false);
		} );

		scan_tags();
});
</script>
</head>
<body>

<h1>RFID tags in range</h1>

<label for=pull-reader>
<input id=pull-reader type=checkbox checked=1>
active
</label>

<div id="tags">
RFID reader not found or driver program not started.
</div>

</body>
</html>



( run in 0.430 second using v1.01-cache-2.11-cpan-ceb78f64989 )