/[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 78 - (show annotations)
Sat Mar 28 20:53:45 2009 UTC (15 years, 1 month ago) by dpavlin
File MIME type: application/javascript
File size: 1903 byte(s)
cleanup code, support of of range tags with negative
item numbers
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 if ( id > 0 ) {
13 var item = $('#item'+id);
14 if ( item.length > 0 ) {
15 console.error('element', id, 'allready exists', item);
16 } else {
17 $('#koha').append( '<div class="item" id="item'+id+'">Loading item '+id+' from Koha</div>' )
18 console.debug('created element', id);
19
20 $.get( '/koha/' + id, function(data) {
21 item.html( data );
22
23 var e = $('#clear_selection');
24 e.attr( 'value', parseInt( e.attr('value') ) + 1 );
25 console.info('loaded item:', id, 'total selected:', e.attr('value'));
26
27 rfid_selected[ id ] = data;
28 $('#clear_selection').click( function() {
29 rfid_selected[id] = undefined;
30 item.remove();
31 });
32 });
33 }
34 item.addClass('in_range');
35 } else if ( id < 0 ) {
36 id = Math.abs( parseInt( id ));
37 var item = $('#item'+id);
38 if ( item.length > 0 ) {
39 console.info('item', item, 'out of range');
40 item.removeClass('in_range');
41 } else {
42 console.error('item', item, 'not found on page');
43 }
44 }
45 };
46
47 $(document).ready( function() {
48
49 var channel = 'test';
50
51 Meteor.hostid = '409897502705';
52
53 // Our Meteor server is on the data. subdomain
54 Meteor.host = 'data.' + location.hostname;
55 Meteor.port = 4670;
56
57 // Call the test() function when data arrives
58 Meteor.registerEventCallback("process", process );
59
60 console.info('Meteor connect', channel, Meteor.status );
61
62 // Join the demo channel and get last five events, then stream
63 Meteor.joinChannel( channel, 5 );
64 Meteor.mode = 'stream';
65
66 // Start streaming!
67 Meteor.connect();
68
69 // clear selection
70 $('#clear_selection').click( function() {
71 $('#koha').html('No items selected');
72 $('#clear_selection').attr('value', '0');
73 rfid_selected = {};
74 console.debug('clear selection');
75 });
76
77 });

  ViewVC Help
Powered by ViewVC 1.1.26