/[meteor]/trunk/public_html/koha.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

Contents of /trunk/public_html/koha.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations)
Sat Mar 28 17:53:26 2009 UTC (15 years ago) by dpavlin
File MIME type: application/javascript
File size: 1710 byte(s)
cleanup rfid_selected, counting of selected items
and never create item which allready exists on screen
1 // Set this to something unique to this client
2
3 var rfid_selected = {};
4
5 function process(data) {
6 var a = data.split('|');
7 console.info('process', a);
8 $('#test').html( a[1] );
9
10 var id = a[0];
11
12 console.debug( id, rfid_selected[id] === undefined );
13
14 if ( id > 0 && rfid_selected[ id ] === undefined ) {
15 if ( $('#'+id).length > 0 ) {
16 console.error('element', id, 'allready exists');
17 } else {
18 $('#koha').append( '<div class="item" id="'+id+'">Loading item '+id+' from Koha</div>' )
19 console.debug('created element', id);
20 }
21 $.get( '/koha/' + id, function(data) {
22 $('#'+id).html( data );
23
24 if ( rfid_selected[id] === undefined ) {
25 var e = $('#clear_selection');
26 e.attr( 'value', parseInt( e.attr('value') ) + 1 );
27 console.info('loaded item:', id, ' times:', rfid_selected[ id ], 'total selected:', e.attr('value'));
28 }
29
30 rfid_selected[ id ] = data;
31 });
32 } else if ( id < 0 ) {
33 console.info("No RFID chips in range");
34 }
35 };
36
37 $(document).ready( function() {
38
39 var channel = 'test';
40
41 Meteor.hostid = '409897502705';
42
43 // Our Meteor server is on the data. subdomain
44 Meteor.host = 'data.' + location.hostname;
45 Meteor.port = 4670;
46
47 // Call the test() function when data arrives
48 Meteor.registerEventCallback("process", process );
49
50 console.info('Meteor connect', channel, Meteor.status );
51
52 // Join the demo channel and get last five events, then stream
53 Meteor.joinChannel( channel, 5 );
54 Meteor.mode = 'stream';
55
56 // Start streaming!
57 Meteor.connect();
58
59 // clear selection
60 $('#clear_selection').click( function() {
61 $('#koha').html('No items selected');
62 $('#clear_selection').attr('value', '0');
63 rfid_selected = {};
64 console.debug('clear selection');
65 });
66
67 });

  ViewVC Help
Powered by ViewVC 1.1.26