3 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
4 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
5 JSAN.errorLevel = "die"; // none, warn, or die
6 JSAN.addRepository('..');
7 JSAN.use('util.error'); g.error = new util.error();
8 g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
10 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
11 try { window.xulG.set_tab_name('Standalone'); } catch(E) { alert(E); }
14 JSAN.use('util.list'); g.list = new util.list('checkout_list');
19 'label' : 'Timestamp',
20 'flex' : 1, 'primary' : false, 'hidden' : true,
21 'render' : 'my.timestamp'
25 'label' : 'Back Date',
26 'flex' : 1, 'primary' : false, 'hidden' : true,
27 'render' : 'my.backdate'
31 'label' : 'Transaction Type',
32 'flex' : 1, 'primary' : false, 'hidden' : true,
37 'label' : 'Item Barcode',
38 'flex' : 2, 'primary' : true, 'hidden' : false,
39 'render' : 'my.barcode'
42 'map_row_to_column' : function(row,col) {
43 // row contains { 'my' : { 'barcode' : xxx, 'duedate' : xxx } }
44 // col contains one of the objects listed above in columns
49 value = eval( col.render );
50 if (typeof value == 'undefined') value = '';
53 JSAN.use('util.error'); var error = new util.error();
54 error.sdump('D_WARN','map_row_to_column: ' + E);
61 JSAN.use('util.date');
63 $('i_barcode').addEventListener('keypress',handle_keypress,false);
64 $('i_barcode').focus();
66 $('enter').addEventListener('command',handle_enter,false);
68 $('submit').addEventListener('command',next_patron,false);
70 var file = new util.file('offline_delta');
71 if (file._file.exists()) { g.delta = file.get_object(); file.close(); } else { g.delta = 0; }
74 var err_msg = "!! This software has encountered an error. Please tell your friendly " +
75 "system administrator or software developer the following:\ncirc/offline_checkin.xul\n" + E + '\n';
76 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
81 function $(id) { return document.getElementById(id); }
83 function handle_keypress(ev) {
84 if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
86 case $('i_barcode') : append_to_list(); break;
91 function handle_enter(ev) {
95 function append_to_list() {
102 my.timestamp = parseInt( new Date().getTime() / 1000);
103 my.backdate = util.date.formatted_date(new Date(),"%F %H:%M:%s");
105 var i_barcode = $('i_barcode').value;
106 if (! i_barcode) return;
107 my.barcode = i_barcode;
109 g.list.append( { 'row' : { 'my' : my } } );
111 var x = $('i_barcode'); x.value = ''; x.focus();
115 dump(E+'\n'); alert(E);
120 function next_patron() {
122 JSAN.use('util.file'); var file = new util.file('pending_xacts');
123 var rows = g.list.dump_with_keys();
124 for (var i = 0; i < rows.length; i++) {
125 var row = rows[i]; row.delta = g.delta;
126 file.append_object(row);
132 x = $('i_barcode'); x.value = ''; x.focus();
135 dump(E+'\n'); alert(E);