'auth_ses' : [],
// Org Unit for the login user
- 'user_ou' : ''
+ 'user_ou' : '',
+
+ // The related org units for the login user
+ 'my_orgs' : [], 'my_orgs_hash' : {},
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+ // The Org Unit tree
+ 'org_tree' : '', 'org_tree_hash' : {},
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+ // Historically, was the list of actor::profile's, but now it's user groups.
+ 'ap_list' : [], 'ap_hash' : {},
+
+ // config::identification_type
+ 'cit_list' : [], 'cit_hash' : {},
+
+ // config::standing
+ 'cst_list' : [], 'cst_hash' : {},
+
+ // assett::copy_location, and for my_orgs
+ 'acpl_list' : [], 'acpl_hash' : {},
+ 'acpl_my_orgs' : [], 'acpl_my_orgs_hash' : {},
+
+ // actor::org_unit_type
+ 'aout_list' : [], 'aout_hash' : {},
+
+ // config::copy_status
+ 'ccs_list' : [], 'ccs_hash' : {},
+
+ // asset::stat_cat. WHERE IS THIS POPULATED AGAIN?
+ 'asc_list' : [],
+
+ // actor::stat_cat
+ 'actsc_list' : [], 'actsc_hash' : {},
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+ 'itemsout_header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following items:<hr/><ol>',
+ 'itemsout_line_item' : '<li>%TITLE: 50%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n',
+ 'itemsout_footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
+
+ 'checkout_header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou checked out the following items:<hr/><ol>',
+ 'checkout_line_item' : '<li>%TITLE%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n',
+ 'checkout_footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%'
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
var debug_ignore_auth_failures = false;
-G['org_tree'] = '';
-G['my_orgs'] = [];
-G['my_orgs_hash'] = {};
-
-G['ap_list'] = []; // actor::profile
-G['ap_hash'] = {};
-G['cit_list'] = []; // config::identification_type
-G['cit_hash'] = {};
-G['cst_list'] = []; // config::standing
-G['cst_hash'] = {};
-G['acpl_list'] = []; // asset::copy_location
-G['acpl_hash'] = {}; G['acpl_my_orgs'] = []; G['acpl_my_orgs_hash'] = {};
-G['aout_list'] = []; // actor::org_unit_type
-G['aout_hash'] = {};
-G['ccs_list'] = []; // config::copy_status
-G['ccs_hash'] = {};
-G['asc_list'] = []; // asset::stat_cat
-G['actsc_list'] = []; // actor::stat_cat
-G['actsc_hash']; // actor::stat_cat
-
-G['itemsout_header'] = 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following items:<hr/><ol>';
-G['itemsout_line_item'] = '<li>%TITLE: 50%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n';
-G['itemsout_footer'] = '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%';
-
-G['checkout_header'] = 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou checked out the following items:<hr/><ol>';
-G['checkout_line_item'] = '<li>%TITLE%\r\nBarcode: %COPY_BARCODE% Due: %DUE_D%\r\n';
-G['checkout_footer'] = '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%';
-
var mw = G['main_window'];
var auth_meter_incr = 10;
+/////////////////////////////////////////////////////////////////////////////////////
+
function auth_init() {
sdump('D_AUTH','TESTING: auth.js: ' + mw.G['main_test_variable'] + '\n');
sdump('D_AUTH',arg_dump(arguments));
+
var np = document.getElementById('name_prompt');
- np.addEventListener("keypress",handle_keypress,false);
- np.focus();
+ np.addEventListener("keypress",handle_keypress,false);
+ np.focus();
var pp = document.getElementById('password_prompt');
- pp.addEventListener("keypress",handle_keypress,false);
+ pp.addEventListener("keypress",handle_keypress,false);
self.addEventListener("unload",nice_shutdown,false);
- G['sound'] = xp_sound_init();
- //G.sound.beep();
- snd_logon();
+
+ G['sound'] = xp_sound_init(); snd_logon();
}
function handle_keypress(ev) {
enable_widgets(document,'password_prompt','name_prompt','submit_button');
document.getElementById('password_prompt').value = '';
var np = document.getElementById('name_prompt');
- np.focus(); np.select();
+ np.focus(); np.select();
document.getElementById('auth_meter').value = 0;
document.getElementById('auth_meter').setAttribute('real', '0.0');
G.sound.beep();
}
+/////////////////////////////////////////////////////////////////////////////////////
+
function authenticate() {
sdump('D_AUTH',arg_dump(arguments));
timer_init('cat');
var pw = document.getElementById('password_prompt').value;
G.name = name; G.pw = pw;
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.auth',
'open-ils.auth.authenticate.complete',
mw.G.auth_ses = [ auth_ses ];
sdump( 'D_AUTH', 'D_AUTH_SES: ' + typeof(mw.G['auth_ses'][0]) + ' : ' + mw.G['auth_ses'][0] + '\n');
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
//'open-ils.actor.user.profiles.retrieve',
user_async_request(
'open-ils.actor',
function ap_list_callback(request) {
sdump('D_AUTH',arg_dump(arguments));
+ var ap_file = get_file('ap_list');
var ap_list;
try {
ap_list = request.getResultObject();
- if (!ap_list) {
- if (!G.offline) {
- throw('null result');
- } else {
- var f = create_input_stream('ap_list');
- ap_list = JSON2js( f.read(-1) ); f.close();
- }
+ if (!ap_list && G.offline) {
+ ap_list = get_object_in_file('ap_list');
}
+ if (!ap_list) { throw('null result'); }
if (ap_list.length == 0) { throw('zero length result'); }
} catch(E) {
- alert('Login failed on ap_list: ' + js2JSON(E));
+ handle_error('Login failed on ap_list: ' + js2JSON(E));
if (!debug_ignore_auth_failures) {
enable_login_prompts(); return;
}
}
- var f = create_output_stream('ap_list');
- var ap_list_json = js2JSON( ap_list );
- f.write( ap_list_json, ap_list_json.length ); f.close();
+ try { set_object_in_file('ap_list',ap_list); } catch(E) { handle_error(E); }
mw.G.ap_list = ap_list;
mw.G.ap_hash = convert_object_list_to_hash( ap_list );
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.actor',
'open-ils.actor.user.ident_types.retrieve',
var cit_list;
try {
cit_list = request.getResultObject();
+ if (!cit_list && G.offline) { cit_list = get_object_in_file('cit_list'); }
if (!cit_list) { throw('null result'); }
if (cit_list.length == 0) { throw('zero length result'); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('cit_list',cit_list); } catch(E) { handle_error(E); }
mw.G.cit_list = cit_list;
mw.G.cit_hash = convert_object_list_to_hash( cit_list );
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.actor',
'open-ils.actor.standings.retrieve',
var cst_list;
try {
cst_list = request.getResultObject();
+ if (!cst_list && G.offline) { cst_list = get_object_in_file('cst_list'); }
if (!cst_list) { throw('null result'); }
if (cst_list.length == 0) { throw('zero length result'); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('cst_list',cst_list); } catch(E) { handle_error(E); }
mw.G.cst_list = cst_list;
mw.G.cst_hash = convert_object_list_to_hash( cst_list );
sdump('D_AUTH', 'cst_list = ' + js2JSON(cst_list) + '\n');
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.search',
'open-ils.search.config.copy_location.retrieve.all',
var acpl_list;
try {
acpl_list = request.getResultObject();
+ if (!acpl_list && G.offline) { acpl_list = get_object_in_file('acpl_list'); }
if (!acpl_list) { throw('null result'); }
if (acpl_list.length == 0) { throw('zero length result'); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('acpl_list',acpl_list); } catch(E) { handle_error(E); }
mw.G.acpl_list = acpl_list;
mw.G.acpl_hash = convert_object_list_to_hash( acpl_list );
sdump('D_AUTH', 'acpl_list = ' + js2JSON(acpl_list) + '\n');
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.search',
'open-ils.search.config.copy_status.retrieve.all',
var ccs_list;
try {
ccs_list = request.getResultObject();
+ if (!ccs_list && G.offline) { ccs_list = get_object_in_file('ccs_list'); }
if (!ccs_list) { throw('null result'); }
if (ccs_list.length == 0) { throw('zero length result'); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('ccs_list',ccs_list); } catch(E) { handle_error(E); }
mw.G.ccs_list = ccs_list;
mw.G.ccs_hash = convert_object_list_to_hash( ccs_list );
sdump('D_AUTH', 'ccs_list = ' + js2JSON(ccs_list) + '\n');
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.search',
'open-ils.search.actor.user.session',
var user_ou;
try {
user = request.getResultObject();
+ if (!user && G.offline) {
+ user = new au();
+ user.home_ou( get_object_in_file('user_ou') );
+ }
if (!user) { throw('null result'); }
if (typeof(user) != 'object') { throw('result not an object' + user); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('user_ou',user_ou); } catch(E) { handle_error(E); }
mw.G.user = user;
mw.G.user_ou = user.home_ou();
sdump('D_AUTH', "user: " + js2JSON(mw.G['user']) + '\n');
sdump('D_AUTH', "user_ou: " + js2JSON(mw.G['user_ou']) + '\n');
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.actor',
'open-ils.actor.org_tree.retrieve',
var org_tree;
try {
org_tree = request.getResultObject();
+ if (!org_tree && G.offline) { org_tree = get_object_in_file('org_tree'); }
if (!org_tree) { throw('null result'); }
if (typeof(org_tree) != 'object') { throw('result not an object' + org_tree); }
} catch(E) {
}
//mw.G.org_tree = globalOrgTree;
+ try { set_object_in_file('org_tree',org_tree); } catch(E) { handle_error(E); }
mw.G.org_tree = org_tree;
mw.G.org_tree_hash = convert_object_list_to_hash( flatten_ou_branch( mw.G.org_tree ) );
mw.G.user_ou = find_ou( mw.G.org_tree, mw.G.user_ou );
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
/*user_async_request(
'open-ils.actor',
'open-ils.actor.org_types.retrieve',
mw.G.aout_list = aout_list;
mw.G.aout_hash = convert_object_list_to_hash( aout_list );
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.actor',
'open-ils.actor.org_unit.full_path.retrieve',
var my_orgs;
try {
my_orgs = request.getResultObject();
+ if (!my_orgs && G.offline) { my_orgs = get_object_in_file('my_orgs'); }
if (!my_orgs) { throw('null result'); }
if (typeof(my_orgs) != 'object') { throw('result not an object' + my_orgs); }
if (my_orgs.length == 0) { throw('empty my_orgs'); }
}
}
+ try { set_object_in_file('my_orgs',my_orgs); } catch(E) { handle_error(E); }
mw.G.my_orgs = my_orgs;
mw.G.my_orgs_hash = convert_object_list_to_hash( my_orgs );
sdump('D_AUTH','my_orgs = ' + js2JSON(my_orgs) + '\n');
mw.G.acpl_my_orgs_hash = convert_object_list_to_hash( mw.G.acpl_my_orgs );
//sdump('D_AUTH', 'my_orgs.length = ' + mw.G.my_orgs.length + ' other_orgs.length = ' + mw.G.other_orgs.length + '\n');
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
user_async_request(
'open-ils.circ',
'open-ils.circ.stat_cat.actor.retrieve.all',
var actsc_list;
try {
actsc_list = request.getResultObject();
+ if (!actsc_list && G.offline) { actsc_list = get_object_in_file('actsc_list'); }
if (!actsc_list) { throw('null result'); }
//if (actsc_list.length == 0) { throw('zero length result'); }
} catch(E) {
enable_login_prompts(); return;
}
}
+ try { set_object_in_file('actsc_list',actsc_list); } catch(E) { handle_error(E); }
mw.G.actsc_list = actsc_list;
mw.G.actsc_hash = convert_object_list_to_hash( actsc_list );
sdump('D_AUTH', 'actsc_list = ' + js2JSON(actsc_list) + '\n');