From 4140bebe5b8b51118e463b781dde519c2f3d6559 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 7 Jan 2010 22:56:34 +0000 Subject: [PATCH] Monster whitespace patch in the same vein of changesets 14577 and 14578 (this time restricted to staff_client/, and with the desired 1 tab = 4 spaces). Viewing the diff in TRAC will take forever :) git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@15275 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/OpenILS/data.js | 1600 +++---- .../chrome/content/OpenILS/global_util.js | 392 +- .../chrome/content/OpenILS/util/fmall.js | 24 +- .../chrome/content/OpenILS/util_overlay_chrome.xul | 32 +- .../content/OpenILS/util_overlay_offline.xul | 20 +- .../staff_client/chrome/content/admin/survey.js | 386 +- .../chrome/content/admin/survey_overlay.xul | 152 +- .../chrome/content/admin/survey_wizard.xul | 92 +- .../staff_client/chrome/content/auth/controller.js | 942 ++-- .../staff_client/chrome/content/auth/session.js | 234 +- .../xul/staff_client/chrome/content/cat/opac.js | 504 +-- .../xul/staff_client/chrome/content/cat/opac.xul | 90 +- .../staff_client/chrome/content/circ/offline.js | 266 +- .../staff_client/chrome/content/circ/offline.xul | 122 +- .../chrome/content/circ/offline_checkin.js | 176 +- .../chrome/content/circ/offline_checkin.xul | 122 +- .../chrome/content/circ/offline_checkout.js | 506 +-- .../chrome/content/circ/offline_checkout.xul | 196 +- .../chrome/content/circ/offline_in_house_use.js | 200 +- .../chrome/content/circ/offline_in_house_use.xul | 138 +- .../chrome/content/circ/offline_register.js | 614 +-- .../chrome/content/circ/offline_register.xul | 218 +- .../chrome/content/circ/offline_renew.js | 416 +- .../chrome/content/circ/offline_renew.xul | 188 +- .../xul/staff_client/chrome/content/circ/util.js | 508 +-- .../staff_client/chrome/content/main/about.html | 12 +- .../staff_client/chrome/content/main/constants.js | 614 +-- .../xul/staff_client/chrome/content/main/main.js | 622 +-- .../xul/staff_client/chrome/content/main/main.xul | 286 +- .../xul/staff_client/chrome/content/main/menu.js | 1854 ++++---- .../chrome/content/main/menu_frame.xul | 92 +- .../chrome/content/main/menu_frame_menus.xul | 438 +- .../chrome/content/main/menu_frame_overlay.xul | 74 +- .../chrome/content/main/simple_auth.xul | 274 +- .../xul/staff_client/chrome/content/main/test.xul | 6 +- .../xul/staff_client/chrome/content/test/test.js | 6 +- .../staff_client/chrome/content/util/barcode.js | 48 +- .../staff_client/chrome/content/util/browser.js | 474 +- .../staff_client/chrome/content/util/browser.xul | 186 +- .../staff_client/chrome/content/util/clipboard.js | 6 +- .../staff_client/chrome/content/util/controller.js | 100 +- .../xul/staff_client/chrome/content/util/date.js | 276 +- .../xul/staff_client/chrome/content/util/deck.js | 350 +- .../xul/staff_client/chrome/content/util/error.js | 1084 ++--- .../xul/staff_client/chrome/content/util/exec.js | 122 +- .../chrome/content/util/fancy_prompt.xul | 236 +- .../xul/staff_client/chrome/content/util/file.js | 518 +-- .../staff_client/chrome/content/util/fm_utils.js | 196 +- .../staff_client/chrome/content/util/fm_view.xul | 376 +- .../staff_client/chrome/content/util/functional.js | 186 +- .../xul/staff_client/chrome/content/util/list.js | 2320 +++++----- .../chrome/content/util/list_clipboard.xul | 162 +- .../xul/staff_client/chrome/content/util/money.js | 108 +- .../staff_client/chrome/content/util/mozilla.js | 46 +- .../staff_client/chrome/content/util/network.js | 682 +-- .../xul/staff_client/chrome/content/util/print.js | 862 ++-- .../staff_client/chrome/content/util/rbrowser.xul | 188 +- .../xul/staff_client/chrome/content/util/sound.js | 106 +- .../staff_client/chrome/content/util/sprintf.js | 96 +- .../xul/staff_client/chrome/content/util/text.js | 38 +- .../staff_client/chrome/content/util/widgets.js | 562 +-- .../xul/staff_client/chrome/content/util/window.js | 202 +- Open-ILS/xul/staff_client/chrome/skin/global.css | 12 +- Open-ILS/xul/staff_client/components/nsOpenILS.js | 2 +- Open-ILS/xul/staff_client/external/template.js | 58 +- Open-ILS/xul/staff_client/external/template.xul | 94 +- .../staff_client/server/OpenILS/util_overlay.xul | 38 +- Open-ILS/xul/staff_client/server/admin/admin.css | 34 +- Open-ILS/xul/staff_client/server/admin/adminlib.js | 134 +- .../xul/staff_client/server/admin/cash_reports.js | 168 +- .../staff_client/server/admin/cash_reports.xhtml | 172 +- .../xul/staff_client/server/admin/closed_dates.js | 540 +-- .../staff_client/server/admin/closed_dates.xhtml | 448 +- .../staff_client/server/admin/copy_locations.js | 270 +- .../staff_client/server/admin/copy_locations.xhtml | 346 +- .../staff_client/server/admin/font_settings.xul | 308 +- .../staff_client/server/admin/hold_pull_list.js | 142 +- .../staff_client/server/admin/hold_pull_list.xhtml | 162 +- .../server/admin/hold_pull_list_classic.js | 366 +- .../server/admin/hold_pull_list_classic.xhtml | 82 +- Open-ILS/xul/staff_client/server/admin/index.xhtml | 154 +- .../xul/staff_client/server/admin/non_cat_types.js | 270 +- .../staff_client/server/admin/non_cat_types.xhtml | 304 +- .../server/admin/offline_manage_xacts.js | 1754 ++++---- .../server/admin/offline_manage_xacts.xul | 140 +- .../server/admin/org_unit_settings.xhtml | 6 +- .../server/admin/printer_settings.html | 46 +- .../staff_client/server/admin/printer_settings.js | 70 +- .../staff_client/server/admin/stat_cat_editor.js | 484 +- .../server/admin/stat_cat_editor.xhtml | 472 +- .../xul/staff_client/server/admin/transit_list.js | 866 ++-- .../xul/staff_client/server/admin/transit_list.xul | 260 +- .../xul/staff_client/server/admin/upload_xacts.js | 86 +- .../staff_client/server/admin/upload_xacts.xhtml | 56 +- Open-ILS/xul/staff_client/server/cat/bib_brief.xul | 410 +- .../xul/staff_client/server/cat/copy_browser.js | 3278 +++++++------- .../xul/staff_client/server/cat/copy_browser.xul | 320 +- .../xul/staff_client/server/cat/copy_buckets.js | 1082 ++--- .../xul/staff_client/server/cat/copy_buckets.xul | 122 +- .../server/cat/copy_buckets_overlay.xul | 98 +- .../staff_client/server/cat/copy_buckets_quick.xul | 298 +- .../xul/staff_client/server/cat/copy_editor.js | 1842 ++++---- .../xul/staff_client/server/cat/copy_editor.xul | 122 +- .../xul/staff_client/server/cat/copy_notes.xul | 384 +- .../xul/staff_client/server/cat/copy_summary.xul | 432 +- Open-ILS/xul/staff_client/server/cat/marc_new.xul | 252 +- .../xul/staff_client/server/cat/marc_view.html | 38 +- Open-ILS/xul/staff_client/server/cat/marc_view.xul | 108 +- Open-ILS/xul/staff_client/server/cat/marcedit.css | 54 +- Open-ILS/xul/staff_client/server/cat/marcedit.js | 3634 +++++++-------- Open-ILS/xul/staff_client/server/cat/marcedit.xul | 358 +- .../xul/staff_client/server/cat/record_buckets.js | 1478 +++--- .../xul/staff_client/server/cat/record_buckets.xul | 174 +- .../server/cat/record_buckets_overlay.xul | 118 +- .../server/cat/record_buckets_quick.xul | 290 +- .../xul/staff_client/server/cat/spine_labels.js | 542 +-- .../xul/staff_client/server/cat/spine_labels.xul | 274 +- Open-ILS/xul/staff_client/server/cat/util.js | 674 +-- .../xul/staff_client/server/cat/volume_buckets.xul | 66 +- .../staff_client/server/cat/volume_copy_creator.js | 816 ++-- .../server/cat/volume_copy_creator.xul | 74 +- .../xul/staff_client/server/cat/volume_editor.xul | 152 +- Open-ILS/xul/staff_client/server/cat/z3950.js | 1094 ++--- Open-ILS/xul/staff_client/server/cat/z3950.xul | 124 +- Open-ILS/xul/staff_client/server/circ/checkin.js | 772 ++-- Open-ILS/xul/staff_client/server/circ/checkin.xul | 146 +- .../staff_client/server/circ/checkin_overlay.xul | 184 +- Open-ILS/xul/staff_client/server/circ/checkout.js | 1740 +++---- Open-ILS/xul/staff_client/server/circ/checkout.xul | 142 +- .../staff_client/server/circ/checkout_overlay.xul | 106 +- .../xul/staff_client/server/circ/circ_brief.xul | 256 +- .../xul/staff_client/server/circ/circ_summary.xul | 230 +- .../xul/staff_client/server/circ/copy_details.xul | 386 +- .../xul/staff_client/server/circ/copy_status.js | 2072 ++++----- .../xul/staff_client/server/circ/copy_status.xul | 218 +- .../server/circ/copy_status_overlay.xul | 296 +- .../xul/staff_client/server/circ/in_house_use.js | 632 +-- .../xul/staff_client/server/circ/in_house_use.xul | 158 +- .../staff_client/server/circ/pre_cat_fields.xul | 118 +- .../server/circ/print_list_template_editor.js | 752 ++-- .../server/circ/print_list_template_editor.xul | 202 +- Open-ILS/xul/staff_client/server/circ/util.js | 4724 ++++++++++---------- Open-ILS/xul/staff_client/server/index.xhtml | 6 +- Open-ILS/xul/staff_client/server/main/data.xul | 334 +- .../server/main/gen_offline_widgets.xul | 406 +- .../staff_client/server/main/verify_credentials.js | 2 +- .../server/main/verify_credentials.xul | 36 +- Open-ILS/xul/staff_client/server/main/ws_info.xul | 298 +- .../staff_client/server/patron/barcode_entry.xul | 338 +- .../staff_client/server/patron/bill_cc_info.xul | 170 +- .../staff_client/server/patron/bill_check_info.xul | 122 +- .../staff_client/server/patron/bill_details.xul | 650 +-- .../staff_client/server/patron/bill_history.xul | 632 +-- .../server/patron/bill_summary_overlay.xul | 104 +- .../xul/staff_client/server/patron/bill_wizard.xul | 84 +- Open-ILS/xul/staff_client/server/patron/bills.js | 2088 ++++----- Open-ILS/xul/staff_client/server/patron/bills.xul | 110 +- .../staff_client/server/patron/bills_overlay.xul | 208 +- Open-ILS/xul/staff_client/server/patron/display.js | 1248 +++--- .../xul/staff_client/server/patron/display.xul | 186 +- .../staff_client/server/patron/display_horiz.xul | 186 +- .../server/patron/display_horiz_overlay.xul | 60 +- .../staff_client/server/patron/display_overlay.xul | 60 +- .../staff_client/server/patron/hold_notices.xul | 406 +- Open-ILS/xul/staff_client/server/patron/holds.js | 1544 +++---- Open-ILS/xul/staff_client/server/patron/holds.xul | 164 +- .../staff_client/server/patron/holds_overlay.xul | 86 +- .../xul/staff_client/server/patron/info_group.xul | 876 ++-- .../xul/staff_client/server/patron/info_notes.xul | 424 +- .../staff_client/server/patron/info_stat_cats.xul | 352 +- .../staff_client/server/patron/info_surveys.xul | 332 +- Open-ILS/xul/staff_client/server/patron/items.js | 1518 +++---- Open-ILS/xul/staff_client/server/patron/items.xul | 174 +- .../staff_client/server/patron/items_overlay.xul | 216 +- .../xul/staff_client/server/patron/search_form.js | 560 +-- .../xul/staff_client/server/patron/search_form.xul | 122 +- .../server/patron/search_form_horiz.xul | 122 +- .../server/patron/search_form_horiz_overlay.xul | 164 +- .../server/patron/search_form_overlay.xul | 234 +- .../staff_client/server/patron/search_result.js | 416 +- .../staff_client/server/patron/search_result.xul | 112 +- .../server/patron/search_result_overlay.xul | 26 +- .../server/patron/standing_penalties.js | 2 +- .../server/patron/standing_penalties.xul | 38 +- Open-ILS/xul/staff_client/server/patron/summary.js | 1378 +++--- .../xul/staff_client/server/patron/summary.xul | 158 +- .../staff_client/server/patron/summary_overlay.xul | 368 +- .../server/patron/summary_overlay_horiz.xul | 232 +- Open-ILS/xul/staff_client/server/patron/ue.js | 958 ++-- Open-ILS/xul/staff_client/server/patron/ue.xhtml | 1992 ++++----- .../xul/staff_client/server/patron/ue_config.js | 1900 ++++---- Open-ILS/xul/staff_client/server/patron/ue_ui.js | 622 +-- .../staff_client/server/patron/user_buckets.xul | 64 +- .../xul/staff_client/server/patron/user_edit.js | 740 +-- .../xul/staff_client/server/patron/user_edit.xhtml | 238 +- Open-ILS/xul/staff_client/server/patron/util.js | 1308 +++--- Open-ILS/xul/staff_client/server/skin/global.css | 14 +- 197 files changed, 43660 insertions(+), 43660 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index 8a23cf40ab..70f861179f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -3,811 +3,811 @@ dump('entering OpenILS/data.js\n'); if (typeof OpenILS == 'undefined') OpenILS = {}; OpenILS.data = function () { - JSAN.use('util.error'); this.error = new util.error(); - JSAN.use('util.network'); this.network = new util.network(); + JSAN.use('util.error'); this.error = new util.error(); + JSAN.use('util.network'); this.network = new util.network(); - return this; + return this; } OpenILS.data.prototype = { - 'list' : {}, - 'hash' : {}, - 'tree' : {}, - - 'temp' : '', - - 'data_progress' : function(msg) { - try { - var x = document.getElementById('data_progress'); - if (x) { - x.appendChild( document.createTextNode( msg ) ); - } - } catch(E) { - this.error.sdump('D_ERROR',msg + '\n' + E); - } - }, - - 'init' : function (params) { - - try { - if (params && params.via == 'stash') { - this.stash_retrieve(); - } else { - this.network_retrieve(); - } - - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data.init(' - +js2JSON(params)+'): ' + js2JSON(E) ); - } - - - }, - - // This should be invoked only once per application, in a persistant window - 'init_observer_functions' : function() { - try { - var obj = this; // OpenILS.data - obj.observers = {}; // - obj.observers.id = 1; // Unique id for each observer function added - obj.observers.id2path = {}; // Lookup for full_path via observer id - obj.observers.cache = {}; // Observer funcs go in here - - // For a given path, this executes all the registered observer funcs - obj.observers.dispatch = function(full_path, old_value, new_value) { - obj.error.sdump('D_OBSERVERS', 'entering observers.dispatch\nfull_path = ' + full_path + '\nold_value = ' + js2JSON(old_value) + '\nnew_value = ' + js2JSON(new_value) + '\n'); - try { - var path = full_path.split(/\./).pop(); - for (var i in obj.observers.cache[full_path]) { - try { - var o = obj.observers.cache[full_path][i]; - if (typeof o.func == 'function') o.func(path, old_value, new_value); - } catch(E) { - obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) ); - } - } - } catch(E) { - obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) ); - } - } - - // This registers an observer function for a given path - obj.observers.add = function(full_path, func) { - try { - obj.error.sdump('D_OBSERVERS', 'entering observers.add\nfull_path = ' + full_path + '\nfunc = ' + func + '\n'); - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var data_cache=new OpenILS( ); - var stash = data_cache.wrappedJSObject.OpenILS.prototype.data; - - var id = obj.observers.id++; - if (typeof obj.observers.cache[ full_path ] == 'undefined') obj.observers.cache[ full_path ] = {}; - obj.observers.cache[ full_path ][ id ] = { 'func' : func, 'time_added' : new Date() }; - obj.observers.id2path[ id ] = [ full_path ]; - - var path_list = full_path.split(/\./); - var observed_prop = path_list.pop(); - - // Convert soft path to object reference. Error if any but the last node is undefined - for (var i in path_list) stash = stash[ path_list[i] ]; - - /* - - // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug - - if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) { - stash['_' + observed_prop] = js2JSON(stash[observed_prop]); - } - - stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); }); - stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); }); - */ - - stash.watch( - observed_prop, - function(p,old_value,new_value) { - obj.observers.dispatch(full_path,old_value,new_value); - return new_value; - } - ); - - return id; - } catch(E) { - obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.add(): ' + js2JSON(E) ); - } - } - - // This unregisters an observer function for a given observer id - obj.observers.remove = function(id) { - try { - obj.error.sdump('D_OBSERVERS', 'entering observers.remove\nid = ' + id + '\n'); - var path = obj.observers.id2path[ id ]; - delete obj.observers.cache[ path ][ id ]; - delete obj.observers.id2path[ id ]; - } catch(E) { - obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.remove(): ' + js2JSON(E) ); - } - } - - // This purges observer functions for a given path - obj.observers.purge = function(full_path) { - obj.error.sdump('D_OBSERVERS', 'entering observers.purge\nfull_path = ' + full_path + '\n'); - try { - var remove_these = []; - for (var id in obj.observers.cache[ full_path ]) remove_these.push( id ); - for (var id in remove_these) delete obj.observers.id2path[ id ]; - delete obj.observers.cache[ full_path ]; - } catch(E) { - obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.purge(): ' + js2JSON(E) ); - } - } - - obj.stash('observers'); // make this accessible globally - - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data.init_observer_functions(): ' + js2JSON(E) ); - } - }, - - 'stash' : function () { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var data_cache=new OpenILS( ); - for (var i = 0; i < arguments.length; i++) { - try { - if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + (this[arguments[i]]) : '') + '\n'); - } catch(F) { alert(F); } - data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]]; - } - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) ); - } - }, - - 'lookup' : function(key,value) { - try { - var obj = this; var found; - if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value]; - switch(key) { - case 'acpl': - found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID.authoritative',[ value ]); - break; - default: return undefined; break; - } - if (typeof found.ilsevent != 'undefined') throw(found); - if (!obj.hash[key]) obj.hash[key] = {}; - obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list'); - return found; - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) ); - return undefined; - } - }, - - '_debug_stash' : function() { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var data_cache=new OpenILS( ); - for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) { - dump('_debug_stash ' + i + '\n'); - } - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) ); - } - }, - - '_fm_objects' : { - - 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ], - 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ], - 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ], - /* - 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ], - */ - /* - 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ], - */ - 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ], - 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ], - 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ], - 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ] - }, - - 'stash_retrieve' : function() { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); - var data_cache=new OpenILS( ); - var dc = data_cache.wrappedJSObject.OpenILS.prototype.data; - for (var i in dc) { - this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n'); - this[i] = dc[i]; - } - if (typeof this.on_complete == 'function') { - - this.on_complete(); - } - } catch(E) { - this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) ); - } - }, - - 'print_list_defaults' : function() { - var obj = this; - //if (typeof obj.print_list_templates == 'undefined') { - { - obj.print_list_types = [ - 'offline_checkout', - 'offline_checkin', - 'offline_renew', - 'offline_inhouse_use', - 'items', - 'bills', - 'payment', - 'holds', - /* 'patrons' */ - ]; - obj.print_list_templates = { - 'item_status' : { - 'type' : 'items', - 'header' : 'The following items have been examined:
    ', - 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode%\r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'transit_list' : { - 'type' : 'transits', - 'header' : 'Transits:
    ', - 'line_item' : '
  1. From: %transit_source% To: %transit_dest_lib%
    \r\nWhen: %transit_source_send_time%
    \r\nBarcode: %transit_item_barcode% Title: %transit_item_title%
    \r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'items_out' : { - 'type' : 'items', - 'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following items:
    ', - 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Due: %due_date%\r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' - }, - 'checkout' : { - 'type' : 'items', - 'header' : 'Welcome to %LIBRARY%!
\r\nYou checked out the following items:
    ', - 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Due: %due_date%\r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' - }, - 'offline_checkout' : { - 'type' : 'offline_checkout', - 'header' : 'Patron %patron_barcode%
\r\nYou checked out the following items:
    ', - 'line_item' : '
  1. Barcode: %barcode%
    \r\nDue: %due_date%\r\n', - 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' - }, - 'checkin' : { - 'type' : 'items', - 'header' : 'You checked in the following items:
    ', - 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Call Number: %call_number%\r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'bill_payment' : { - 'type' : 'payment', - 'header' : 'Welcome to %LIBRARY%!
A receipt of your transaction:
Original Balance: $%original_balance%
Payment Method: %payment_type%
Payment Received: $%payment_received%
Payment Applied: $%payment_applied%
Billings Voided: %voided_balance%
Change Given: $%change_given%
New Balance: $%new_balance%

Note: %note%

Specific bills:

', - 'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%
%barcode% %title%

', - 'footer' : '


%SHORTNAME% %TODAY_TRIM%

' - }, - 'bills_historical' : { - 'type' : 'bills', - 'header' : 'Welcome to %LIBRARY%!
You had the following bills:
    ', - 'line_item' : '
    Bill #%id%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'bills_current' : { - 'type' : 'bills', - 'header' : 'Welcome to %LIBRARY%!
You have the following bills:
    ', - 'line_item' : '
    Bill #%id%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'bills_main_view' : { - 'type' : 'bills', - 'header' : 'Welcome to %LIBRARY%!
You have the following bills:
    ', - 'line_item' : '
    Bill #%id% %title%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' - }, - 'offline_checkin' : { - 'type' : 'offline_checkin', - 'header' : 'You checked in the following items:
    ', - 'line_item' : '
  1. Barcode: %barcode%\r\n', - 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' - }, - 'offline_renew' : { - 'type' : 'offline_renew', - 'header' : 'You renewed the following items:
    ', - 'line_item' : '
  1. Barcode: %barcode%\r\n', - 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' - }, - 'offline_inhouse_use' : { - 'type' : 'offline_inhouse_use', - 'header' : 'You marked the following in-house items used:
    ', - 'line_item' : '
  1. Barcode: %barcode%\r\nUses: %count%', - 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' - }, - 'in_house_use' : { - 'type' : 'items', - 'header' : 'You marked the following in-house items used:
    ', - 'line_item' : '
  1. Barcode: %barcode%\r\nUses: %uses%\r\n
    %alert_message%', - 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' - }, - 'holds' : { - 'type' : 'holds', - 'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following titles on hold:
    ', - 'line_item' : '
  1. %title%\r\n', - 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' - } - }; - - obj.stash( 'print_list_templates', 'print_list_types' ); - } - }, - - 'network_retrieve' : function() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var obj = this; - - - JSAN.use('util.file'); var file = new util.file('print_list_templates'); - obj.print_list_defaults(); - obj.data_progress('Default print templates set. '); - if (file._file.exists()) { - try { - var x = file.get_object(); - if (x) { - for (var i in x) { - obj.print_list_templates[i] = x[i]; - } - obj.stash('print_list_templates'); - obj.data_progress('Saved print templates retrieved from file. '); - } - } catch(E) { - alert(E); - } - } - file.close(); - - JSAN.use('util.file'); var file = new util.file('global_font_adjust'); - if (file._file.exists()) { - try { - var x = file.get_object(); - if (x) { - obj.global_font_adjust = x; - obj.stash('global_font_adjust'); - obj.data_progress('Saved font settings retrieved from file. '); - } - } catch(E) { - alert(E); - } - } - file.close(); - - JSAN.use('util.file'); var file = new util.file('no_sound'); - if (file._file.exists()) { - try { - var x = file.get_content(); - if (x) { - obj.no_sound = x; - obj.stash('no_sound'); - obj.data_progress('Saved sound settings retrieved from file. '); - } - } catch(E) { - alert(E); - } - } - file.close(); - - JSAN.use('util.file'); var file = new util.file('print_strategy'); - if (file._file.exists()) { - try { - var x = file.get_content(); - if (x) { - obj.print_strategy = x; - obj.stash('print_strategy'); - obj.data_progress('Print strategy retrieved from file. '); - } - } catch(E) { - alert(E); - } - } - file.close(); - - JSAN.use('util.print'); (new util.print()).GetPrintSettings(); - obj.data_progress('Printer settings retrieved. '); - - JSAN.use('util.functional'); - JSAN.use('util.fm_utils'); - - function gen_fm_retrieval_func(classname,data) { - var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3]; - return function () { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - - function convert() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - try { - if (obj.list[classname].constructor.name == 'Array') { - obj.hash[classname] = - util.functional.convert_object_list_to_hash( - obj.list[classname] - ); - } - } catch(E) { - - obj.error.sdump('D_ERROR',E + '\n'); - } - - } - - try { - var level = obj.error.sdump_levels.D_SES_RESULT; - if (classname == 'aou' || classname == 'my_aou') - obj.error.sdump_levels.D_SES_RESULT = false; - var robj = obj.network.request( app, method, params); - if (robj != null && typeof robj.ilsevent != 'undefined') { - obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj); - throw(robj); - } - obj.list[classname] = robj == null ? [] : robj; - obj.error.sdump_levels.D_SES_RESULT = level; - convert(); - obj.data_progress('Retrieved list for ' + classname + ' objects. '); - - } catch(E) { - // if cacheable, try offline - if (cacheable) { - /* FIXME -- we're going to revisit caching and do it differently - try { - var file = new util.file( classname ); - obj.list[classname] = file.get_object(); file.close(); - convert(); - } catch(E) { - throw(E); - } - */ - throw(E); // for now - } else { - throw(E); // for now - } - } - } - } - - this.chain = []; - - this.chain.push( - function() { - try { - var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]); - if (typeof robj.ilsevent != 'undefined') throw(robj); - obj.list.circ_modifier = robj; - obj.data_progress('Retrieved circ modifier list. '); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'cnal', - [ - api.FM_CNAL_RETRIEVE.app, - api.FM_CNAL_RETRIEVE.method, - [ obj.session.key ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'csp', - [ - api.FM_CSP_PCRUD_SEARCH.app, - api.FM_CSP_PCRUD_SEARCH.method, - [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"csp":"id"}} ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'au', - [ - api.FM_AU_RETRIEVE_VIA_SESSION.app, - api.FM_AU_RETRIEVE_VIA_SESSION.method, - [ obj.session.key ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - obj.list.au = [ obj.list.au ]; - } - ); - - this.chain.push( - function() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var f = gen_fm_retrieval_func( - 'my_asv', - [ - api.FM_ASV_RETRIEVE_REQUIRED.app, - api.FM_ASV_RETRIEVE_REQUIRED.method, - [ obj.session.key ], - true - ] - ); - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var f = gen_fm_retrieval_func( - 'asv', - [ - api.FM_ASV_RETRIEVE.app, - api.FM_ASV_RETRIEVE.method, - [ obj.session.key ], - true - ] - ); - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n'); - - for (var i in this._fm_objects) { - this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) ); - } - - // The previous org_tree call returned a tree, not a list or hash. - this.chain.push( - function () { - obj.tree.aou = obj.list.aou; - obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou ); - for (var i = 0; i < obj.list.aou.length; i++) { - var c = obj.list.aou[i].children(); - if (!c) c = []; - c = c.sort( - function( a, b ) { - if (a.shortname() < b.shortname()) return -1; - if (a.shortname() > b.shortname()) return 1; - return 0; - } - ); - obj.list.aou[i].children( c ); - } - obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou ); - obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou ); - } - ); - - // The previous pgt call returned a tree, not a list or hash. - this.chain.push( - function () { - obj.tree.pgt = obj.list.pgt; - obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt ); - obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt ); - } - ); - - // Do these after we get the user object - - this.chain.push( - function() { - try { - var robj = obj.network.simple_request('FM_AOUS_RETRIEVE',[ obj.session.key, obj.list.au[0].ws_ou() ]); - if (typeof robj.ilsevent != 'undefined') throw(robj); - obj.hash.aous = robj; - obj.data_progress('Retrieved org unit settings. '); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - - function() { - - gen_fm_retrieval_func('my_aou', - [ - api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app, - api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method, - [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */ - true - ] - )(); - } - ); - - this.chain.push( - - function () { - - gen_fm_retrieval_func( 'my_actsc', - [ - api.FM_ACTSC_RETRIEVE_VIA_AOU.app, - api.FM_ACTSC_RETRIEVE_VIA_AOU.method, - [ obj.session.key, obj.list.au[0].ws_ou() ], - true - ] - )(); - } - ); - - this.chain.push( - - function () { - - gen_fm_retrieval_func( 'my_asc', - [ - api.FM_ASC_RETRIEVE_VIA_AOU.app, - api.FM_ASC_RETRIEVE_VIA_AOU.method, - [ obj.session.key, obj.list.au[0].ws_ou() ], - true - ] - )(); - } - ); - - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'cnct', - [ - api.FM_CNCT_RETRIEVE.app, - api.FM_CNCT_RETRIEVE.method, - [ obj.list.au[0].ws_ou() ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'my_cnct', - [ - api.FM_CNCT_RETRIEVE.app, - api.FM_CNCT_RETRIEVE.method, - [ obj.list.au[0].ws_ou() ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'acpl', - [ - api.FM_ACPL_RETRIEVE.app, - api.FM_ACPL_RETRIEVE.method, - [ obj.list.au[0].ws_ou() ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - this.chain.push( - function() { - var f = gen_fm_retrieval_func( - 'cbt', - [ - api.FM_CBT_RETRIEVE.app, - api.FM_CBT_RETRIEVE.method, - [ obj.session.key, obj.list.au[0].ws_ou() ], - false - ] - ); - try { - f(); - } catch(E) { - var error = 'Error: ' + js2JSON(E); - obj.error.sdump('D_ERROR',error); - throw(E); - } - } - ); - - if (typeof this.on_complete == 'function') { - - this.chain.push( this.on_complete ); - } - JSAN.use('util.exec'); this.exec = new util.exec(); - this.exec.on_error = function(E) { - - if (typeof obj.on_error == 'function') { - return obj.on_error(E); /* false breaks chain */ - } else { - alert('oops: ' + E ); - return false; /* break chain */ - } - - } - - this.exec.chain( this.chain ); - - } + 'list' : {}, + 'hash' : {}, + 'tree' : {}, + + 'temp' : '', + + 'data_progress' : function(msg) { + try { + var x = document.getElementById('data_progress'); + if (x) { + x.appendChild( document.createTextNode( msg ) ); + } + } catch(E) { + this.error.sdump('D_ERROR',msg + '\n' + E); + } + }, + + 'init' : function (params) { + + try { + if (params && params.via == 'stash') { + this.stash_retrieve(); + } else { + this.network_retrieve(); + } + + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.init(' + +js2JSON(params)+'): ' + js2JSON(E) ); + } + + + }, + + // This should be invoked only once per application, in a persistant window + 'init_observer_functions' : function() { + try { + var obj = this; // OpenILS.data + obj.observers = {}; // + obj.observers.id = 1; // Unique id for each observer function added + obj.observers.id2path = {}; // Lookup for full_path via observer id + obj.observers.cache = {}; // Observer funcs go in here + + // For a given path, this executes all the registered observer funcs + obj.observers.dispatch = function(full_path, old_value, new_value) { + obj.error.sdump('D_OBSERVERS', 'entering observers.dispatch\nfull_path = ' + full_path + '\nold_value = ' + js2JSON(old_value) + '\nnew_value = ' + js2JSON(new_value) + '\n'); + try { + var path = full_path.split(/\./).pop(); + for (var i in obj.observers.cache[full_path]) { + try { + var o = obj.observers.cache[full_path][i]; + if (typeof o.func == 'function') o.func(path, old_value, new_value); + } catch(E) { + obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) ); + } + } + } catch(E) { + obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) ); + } + } + + // This registers an observer function for a given path + obj.observers.add = function(full_path, func) { + try { + obj.error.sdump('D_OBSERVERS', 'entering observers.add\nfull_path = ' + full_path + '\nfunc = ' + func + '\n'); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + var stash = data_cache.wrappedJSObject.OpenILS.prototype.data; + + var id = obj.observers.id++; + if (typeof obj.observers.cache[ full_path ] == 'undefined') obj.observers.cache[ full_path ] = {}; + obj.observers.cache[ full_path ][ id ] = { 'func' : func, 'time_added' : new Date() }; + obj.observers.id2path[ id ] = [ full_path ]; + + var path_list = full_path.split(/\./); + var observed_prop = path_list.pop(); + + // Convert soft path to object reference. Error if any but the last node is undefined + for (var i in path_list) stash = stash[ path_list[i] ]; + + /* + + // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug + + if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) { + stash['_' + observed_prop] = js2JSON(stash[observed_prop]); + } + + stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); }); + stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); }); + */ + + stash.watch( + observed_prop, + function(p,old_value,new_value) { + obj.observers.dispatch(full_path,old_value,new_value); + return new_value; + } + ); + + return id; + } catch(E) { + obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.add(): ' + js2JSON(E) ); + } + } + + // This unregisters an observer function for a given observer id + obj.observers.remove = function(id) { + try { + obj.error.sdump('D_OBSERVERS', 'entering observers.remove\nid = ' + id + '\n'); + var path = obj.observers.id2path[ id ]; + delete obj.observers.cache[ path ][ id ]; + delete obj.observers.id2path[ id ]; + } catch(E) { + obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.remove(): ' + js2JSON(E) ); + } + } + + // This purges observer functions for a given path + obj.observers.purge = function(full_path) { + obj.error.sdump('D_OBSERVERS', 'entering observers.purge\nfull_path = ' + full_path + '\n'); + try { + var remove_these = []; + for (var id in obj.observers.cache[ full_path ]) remove_these.push( id ); + for (var id in remove_these) delete obj.observers.id2path[ id ]; + delete obj.observers.cache[ full_path ]; + } catch(E) { + obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.purge(): ' + js2JSON(E) ); + } + } + + obj.stash('observers'); // make this accessible globally + + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.init_observer_functions(): ' + js2JSON(E) ); + } + }, + + 'stash' : function () { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + for (var i = 0; i < arguments.length; i++) { + try { + if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + (this[arguments[i]]) : '') + '\n'); + } catch(F) { alert(F); } + data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]]; + } + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) ); + } + }, + + 'lookup' : function(key,value) { + try { + var obj = this; var found; + if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value]; + switch(key) { + case 'acpl': + found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID.authoritative',[ value ]); + break; + default: return undefined; break; + } + if (typeof found.ilsevent != 'undefined') throw(found); + if (!obj.hash[key]) obj.hash[key] = {}; + obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list'); + return found; + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) ); + return undefined; + } + }, + + '_debug_stash' : function() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) { + dump('_debug_stash ' + i + '\n'); + } + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) ); + } + }, + + '_fm_objects' : { + + 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ], + 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ], + 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ], + /* + 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ], + */ + /* + 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ], + */ + 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ], + 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ], + 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ], + 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ] + }, + + 'stash_retrieve' : function() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache=new OpenILS( ); + var dc = data_cache.wrappedJSObject.OpenILS.prototype.data; + for (var i in dc) { + this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n'); + this[i] = dc[i]; + } + if (typeof this.on_complete == 'function') { + + this.on_complete(); + } + } catch(E) { + this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) ); + } + }, + + 'print_list_defaults' : function() { + var obj = this; + //if (typeof obj.print_list_templates == 'undefined') { + { + obj.print_list_types = [ + 'offline_checkout', + 'offline_checkin', + 'offline_renew', + 'offline_inhouse_use', + 'items', + 'bills', + 'payment', + 'holds', + /* 'patrons' */ + ]; + obj.print_list_templates = { + 'item_status' : { + 'type' : 'items', + 'header' : 'The following items have been examined:
    ', + 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode%\r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'transit_list' : { + 'type' : 'transits', + 'header' : 'Transits:
    ', + 'line_item' : '
  1. From: %transit_source% To: %transit_dest_lib%
    \r\nWhen: %transit_source_send_time%
    \r\nBarcode: %transit_item_barcode% Title: %transit_item_title%
    \r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'items_out' : { + 'type' : 'items', + 'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following items:
    ', + 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Due: %due_date%\r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' + }, + 'checkout' : { + 'type' : 'items', + 'header' : 'Welcome to %LIBRARY%!
\r\nYou checked out the following items:
    ', + 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Due: %due_date%\r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' + }, + 'offline_checkout' : { + 'type' : 'offline_checkout', + 'header' : 'Patron %patron_barcode%
\r\nYou checked out the following items:
    ', + 'line_item' : '
  1. Barcode: %barcode%
    \r\nDue: %due_date%\r\n', + 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' + }, + 'checkin' : { + 'type' : 'items', + 'header' : 'You checked in the following items:
    ', + 'line_item' : '
  1. %title%
    \r\nBarcode: %barcode% Call Number: %call_number%\r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'bill_payment' : { + 'type' : 'payment', + 'header' : 'Welcome to %LIBRARY%!
A receipt of your transaction:
Original Balance: $%original_balance%
Payment Method: %payment_type%
Payment Received: $%payment_received%
Payment Applied: $%payment_applied%
Billings Voided: %voided_balance%
Change Given: $%change_given%
New Balance: $%new_balance%

Note: %note%

Specific bills:

', + 'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%
%barcode% %title%

', + 'footer' : '


%SHORTNAME% %TODAY_TRIM%

' + }, + 'bills_historical' : { + 'type' : 'bills', + 'header' : 'Welcome to %LIBRARY%!
You had the following bills:
    ', + 'line_item' : '
    Bill #%id%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'bills_current' : { + 'type' : 'bills', + 'header' : 'Welcome to %LIBRARY%!
You have the following bills:
    ', + 'line_item' : '
    Bill #%id%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'bills_main_view' : { + 'type' : 'bills', + 'header' : 'Welcome to %LIBRARY%!
You have the following bills:
    ', + 'line_item' : '
    Bill #%id% %title%
    Date:%xact_start%
    Type:%xact_type%
    Last Billing:%last_billing_type%
    %last_billing_note%
    Total Billed:$%total_owed%
    Last Payment:%last_payment_type%
    %last_payment_note%
    Total Paid:$%total_paid%
    Balance:$%balance_owed%

    ', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n' + }, + 'offline_checkin' : { + 'type' : 'offline_checkin', + 'header' : 'You checked in the following items:
    ', + 'line_item' : '
  1. Barcode: %barcode%\r\n', + 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' + }, + 'offline_renew' : { + 'type' : 'offline_renew', + 'header' : 'You renewed the following items:
    ', + 'line_item' : '
  1. Barcode: %barcode%\r\n', + 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' + }, + 'offline_inhouse_use' : { + 'type' : 'offline_inhouse_use', + 'header' : 'You marked the following in-house items used:
    ', + 'line_item' : '
  1. Barcode: %barcode%\r\nUses: %count%', + 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' + }, + 'in_house_use' : { + 'type' : 'items', + 'header' : 'You marked the following in-house items used:
    ', + 'line_item' : '
  1. Barcode: %barcode%\r\nUses: %uses%\r\n
    %alert_message%', + 'footer' : '

%TODAY_TRIM%
\r\n
\r\n' + }, + 'holds' : { + 'type' : 'holds', + 'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following titles on hold:
    ', + 'line_item' : '
  1. %title%\r\n', + 'footer' : '

%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n' + } + }; + + obj.stash( 'print_list_templates', 'print_list_types' ); + } + }, + + 'network_retrieve' : function() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var obj = this; + + + JSAN.use('util.file'); var file = new util.file('print_list_templates'); + obj.print_list_defaults(); + obj.data_progress('Default print templates set. '); + if (file._file.exists()) { + try { + var x = file.get_object(); + if (x) { + for (var i in x) { + obj.print_list_templates[i] = x[i]; + } + obj.stash('print_list_templates'); + obj.data_progress('Saved print templates retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); + + JSAN.use('util.file'); var file = new util.file('global_font_adjust'); + if (file._file.exists()) { + try { + var x = file.get_object(); + if (x) { + obj.global_font_adjust = x; + obj.stash('global_font_adjust'); + obj.data_progress('Saved font settings retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); + + JSAN.use('util.file'); var file = new util.file('no_sound'); + if (file._file.exists()) { + try { + var x = file.get_content(); + if (x) { + obj.no_sound = x; + obj.stash('no_sound'); + obj.data_progress('Saved sound settings retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); + + JSAN.use('util.file'); var file = new util.file('print_strategy'); + if (file._file.exists()) { + try { + var x = file.get_content(); + if (x) { + obj.print_strategy = x; + obj.stash('print_strategy'); + obj.data_progress('Print strategy retrieved from file. '); + } + } catch(E) { + alert(E); + } + } + file.close(); + + JSAN.use('util.print'); (new util.print()).GetPrintSettings(); + obj.data_progress('Printer settings retrieved. '); + + JSAN.use('util.functional'); + JSAN.use('util.fm_utils'); + + function gen_fm_retrieval_func(classname,data) { + var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3]; + return function () { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + function convert() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + try { + if (obj.list[classname].constructor.name == 'Array') { + obj.hash[classname] = + util.functional.convert_object_list_to_hash( + obj.list[classname] + ); + } + } catch(E) { + + obj.error.sdump('D_ERROR',E + '\n'); + } + + } + + try { + var level = obj.error.sdump_levels.D_SES_RESULT; + if (classname == 'aou' || classname == 'my_aou') + obj.error.sdump_levels.D_SES_RESULT = false; + var robj = obj.network.request( app, method, params); + if (robj != null && typeof robj.ilsevent != 'undefined') { + obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj); + throw(robj); + } + obj.list[classname] = robj == null ? [] : robj; + obj.error.sdump_levels.D_SES_RESULT = level; + convert(); + obj.data_progress('Retrieved list for ' + classname + ' objects. '); + + } catch(E) { + // if cacheable, try offline + if (cacheable) { + /* FIXME -- we're going to revisit caching and do it differently + try { + var file = new util.file( classname ); + obj.list[classname] = file.get_object(); file.close(); + convert(); + } catch(E) { + throw(E); + } + */ + throw(E); // for now + } else { + throw(E); // for now + } + } + } + } + + this.chain = []; + + this.chain.push( + function() { + try { + var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]); + if (typeof robj.ilsevent != 'undefined') throw(robj); + obj.list.circ_modifier = robj; + obj.data_progress('Retrieved circ modifier list. '); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'cnal', + [ + api.FM_CNAL_RETRIEVE.app, + api.FM_CNAL_RETRIEVE.method, + [ obj.session.key ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'csp', + [ + api.FM_CSP_PCRUD_SEARCH.app, + api.FM_CSP_PCRUD_SEARCH.method, + [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"csp":"id"}} ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'au', + [ + api.FM_AU_RETRIEVE_VIA_SESSION.app, + api.FM_AU_RETRIEVE_VIA_SESSION.method, + [ obj.session.key ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + obj.list.au = [ obj.list.au ]; + } + ); + + this.chain.push( + function() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var f = gen_fm_retrieval_func( + 'my_asv', + [ + api.FM_ASV_RETRIEVE_REQUIRED.app, + api.FM_ASV_RETRIEVE_REQUIRED.method, + [ obj.session.key ], + true + ] + ); + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var f = gen_fm_retrieval_func( + 'asv', + [ + api.FM_ASV_RETRIEVE.app, + api.FM_ASV_RETRIEVE.method, + [ obj.session.key ], + true + ] + ); + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n'); + + for (var i in this._fm_objects) { + this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) ); + } + + // The previous org_tree call returned a tree, not a list or hash. + this.chain.push( + function () { + obj.tree.aou = obj.list.aou; + obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou ); + for (var i = 0; i < obj.list.aou.length; i++) { + var c = obj.list.aou[i].children(); + if (!c) c = []; + c = c.sort( + function( a, b ) { + if (a.shortname() < b.shortname()) return -1; + if (a.shortname() > b.shortname()) return 1; + return 0; + } + ); + obj.list.aou[i].children( c ); + } + obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou ); + obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou ); + } + ); + + // The previous pgt call returned a tree, not a list or hash. + this.chain.push( + function () { + obj.tree.pgt = obj.list.pgt; + obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt ); + obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt ); + } + ); + + // Do these after we get the user object + + this.chain.push( + function() { + try { + var robj = obj.network.simple_request('FM_AOUS_RETRIEVE',[ obj.session.key, obj.list.au[0].ws_ou() ]); + if (typeof robj.ilsevent != 'undefined') throw(robj); + obj.hash.aous = robj; + obj.data_progress('Retrieved org unit settings. '); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + + function() { + + gen_fm_retrieval_func('my_aou', + [ + api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app, + api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method, + [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */ + true + ] + )(); + } + ); + + this.chain.push( + + function () { + + gen_fm_retrieval_func( 'my_actsc', + [ + api.FM_ACTSC_RETRIEVE_VIA_AOU.app, + api.FM_ACTSC_RETRIEVE_VIA_AOU.method, + [ obj.session.key, obj.list.au[0].ws_ou() ], + true + ] + )(); + } + ); + + this.chain.push( + + function () { + + gen_fm_retrieval_func( 'my_asc', + [ + api.FM_ASC_RETRIEVE_VIA_AOU.app, + api.FM_ASC_RETRIEVE_VIA_AOU.method, + [ obj.session.key, obj.list.au[0].ws_ou() ], + true + ] + )(); + } + ); + + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'cnct', + [ + api.FM_CNCT_RETRIEVE.app, + api.FM_CNCT_RETRIEVE.method, + [ obj.list.au[0].ws_ou() ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'my_cnct', + [ + api.FM_CNCT_RETRIEVE.app, + api.FM_CNCT_RETRIEVE.method, + [ obj.list.au[0].ws_ou() ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'acpl', + [ + api.FM_ACPL_RETRIEVE.app, + api.FM_ACPL_RETRIEVE.method, + [ obj.list.au[0].ws_ou() ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( + 'cbt', + [ + api.FM_CBT_RETRIEVE.app, + api.FM_CBT_RETRIEVE.method, + [ obj.session.key, obj.list.au[0].ws_ou() ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + if (typeof this.on_complete == 'function') { + + this.chain.push( this.on_complete ); + } + JSAN.use('util.exec'); this.exec = new util.exec(); + this.exec.on_error = function(E) { + + if (typeof obj.on_error == 'function') { + return obj.on_error(E); /* false breaks chain */ + } else { + alert('oops: ' + E ); + return false; /* break chain */ + } + + } + + this.exec.chain( this.chain ); + + } } dump('exiting OpenILS/data.js\n'); diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index f915d244fe..05b1ac80e1 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -1,39 +1,39 @@ - function $(id) { return document.getElementById(id); } + function $(id) { return document.getElementById(id); } - function ses(a) { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - switch(a) { + function ses(a) { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + switch(a) { case 'ws_ou' : return data.list.au[0].ws_ou(); break; - case 'authtime' : - return data.session.authtime; - break; - case 'key': - default: - return data.session.key; - break; - } - } + case 'authtime' : + return data.session.authtime; + break; + case 'key': + default: + return data.session.key; + break; + } + } - function font_helper() { - try { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - removeCSSClass(document.documentElement,'ALL_FONTS_LARGER'); - removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER'); - removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL'); - removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL'); - removeCSSClass(document.documentElement,'ALL_FONTS_SMALL'); - removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM'); - removeCSSClass(document.documentElement,'ALL_FONTS_LARGE'); - removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE'); - removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE'); - addCSSClass(document.documentElement,data.global_font_adjust); - } catch(E) { + function font_helper() { + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + removeCSSClass(document.documentElement,'ALL_FONTS_LARGER'); + removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER'); + removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL'); + removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL'); + removeCSSClass(document.documentElement,'ALL_FONTS_SMALL'); + removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM'); + removeCSSClass(document.documentElement,'ALL_FONTS_LARGE'); + removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE'); + removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE'); + addCSSClass(document.documentElement,data.global_font_adjust); + } catch(E) { var Strings = $('offlineStrings') || $('commonStrings'); - alert(Strings.getFormattedString('openils.global_util.font_size.error', [E])); - } - } + alert(Strings.getFormattedString('openils.global_util.font_size.error', [E])); + } + } function persist_helper() { try { @@ -87,20 +87,20 @@ } } - function getKeys(o) { - var keys = []; - for (var k in o) keys.push(k); - return keys; - } + function getKeys(o) { + var keys = []; + for (var k in o) keys.push(k); + return keys; + } - function get_contentWindow(frame) { + function get_contentWindow(frame) { try { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); if (frame && frame.contentWindow) { try { if (typeof frame.contentWindow.wrappedJSObject != 'undefined') { - return frame.contentWindow.wrappedJSObject; - } + return frame.contentWindow.wrappedJSObject; + } } catch(E) { var Strings = $('offlineStrings') || $('commonStrings'); alert(Strings.getFormattedString('openils.global_util.content_window_jsobject.error', [frame, E])); @@ -113,174 +113,174 @@ var Strings = $('offlineStrings') || $('commonStrings'); alert(Strings.getFormattedString('openils.global_util.content_window.error', [frame, E])); } - } + } - function update_modal_xulG(v) { - try { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var key = location.pathname + location.search + location.hash; - if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { - data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v; - data.stash('modal_xulG_stack'); - } - } catch(E) { - alert('FIXME: update_modal_xulG => ' + E); - } - } + function update_modal_xulG(v) { + try { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + var key = location.pathname + location.search + location.hash; + if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { + data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v; + data.stash('modal_xulG_stack'); + } + } catch(E) { + alert('FIXME: update_modal_xulG => ' + E); + } + } - function xul_param(param_name,_params) { - /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */ - try { - //dump('xul_param('+param_name+','+js2JSON(_params)+')\n'); - var value = undefined; if (!_params) _params = {}; - if (typeof _params.no_cgi == 'undefined') { - var cgi = new CGI(); - if (cgi.param(param_name)) { - var x = cgi.param(param_name); - //dump('\tfound via location.href = ' + x + '\n'); - if (typeof _params.JSON2js_if_cgi != 'undefined') { - x = JSON2js( x ); - //dump('\tJSON2js = ' + x + '\n'); - } - if (typeof _params.concat == 'undefined') { - //alert(param_name + ' x = ' + x); - return x; // value - } else { - if (value) { - if (value.constructor != Array) value = [ value ]; - value = value.concat(x); - } else { - value = x; - } - } - } - } - if (typeof _params.no_xulG == 'undefined') { - if (typeof _params.modal_xulG != 'undefined') { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var key = location.pathname + location.search + location.hash; - //dump('xul_param, considering modal key = ' + key + '\n'); - if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { - xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ]; - } - } - if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') { - var x = xulG[ param_name ]; - //dump('\tfound via xulG = ' + x + '\n'); - if (typeof _params.JSON2js_if_xulG != 'undefined') { - x = JSON2js( x ); - //dump('\tJSON2js = ' + x + '\n'); - } - if (typeof _params.concat == 'undefined') { - //alert(param_name + ' x = ' + x); - return x; // value - } else { - if (value) { - if (value.constructor != Array) value = [ value ]; - value = value.concat(x); - } else { - value = x; - } - } - } - } - if (typeof _params.no_xpcom == 'undefined') { - /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */ - if (typeof _params.stash_name != 'undefined') { - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - if (typeof data[ _params.stash_name ] != 'undefined') { - var x = data[ _params.stash_name ]; - //dump('\tfound via xpcom = ' + x + '\n'); - if (typeof _params.JSON2js_if_xpcom != 'undefined') { - x = JSON2js( x ); - //dump('\tJSON2js = ' + x + '\n'); - } - if (_params.clear_xpcom) { - data[ _params.stash_name ] = undefined; data.stash( _params.stash_name ); - } - if (typeof _params.concat == 'undefined') { - //alert(param_name + ' x = ' + x); - return x; // value - } else { - if (value) { - if (value.constructor != Array) value = [ value ]; - value = value.concat(x); - } else { - value = x; - } - } - } - } - } - //alert(param_name + ' value = ' + value); - return value; - } catch(E) { - dump('xul_param error: ' + E + '\n'); - } - } + function xul_param(param_name,_params) { + /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */ + try { + //dump('xul_param('+param_name+','+js2JSON(_params)+')\n'); + var value = undefined; if (!_params) _params = {}; + if (typeof _params.no_cgi == 'undefined') { + var cgi = new CGI(); + if (cgi.param(param_name)) { + var x = cgi.param(param_name); + //dump('\tfound via location.href = ' + x + '\n'); + if (typeof _params.JSON2js_if_cgi != 'undefined') { + x = JSON2js( x ); + //dump('\tJSON2js = ' + x + '\n'); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + if (typeof _params.no_xulG == 'undefined') { + if (typeof _params.modal_xulG != 'undefined') { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + var key = location.pathname + location.search + location.hash; + //dump('xul_param, considering modal key = ' + key + '\n'); + if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') { + xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ]; + } + } + if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') { + var x = xulG[ param_name ]; + //dump('\tfound via xulG = ' + x + '\n'); + if (typeof _params.JSON2js_if_xulG != 'undefined') { + x = JSON2js( x ); + //dump('\tJSON2js = ' + x + '\n'); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + if (typeof _params.no_xpcom == 'undefined') { + /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */ + if (typeof _params.stash_name != 'undefined') { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + if (typeof data[ _params.stash_name ] != 'undefined') { + var x = data[ _params.stash_name ]; + //dump('\tfound via xpcom = ' + x + '\n'); + if (typeof _params.JSON2js_if_xpcom != 'undefined') { + x = JSON2js( x ); + //dump('\tJSON2js = ' + x + '\n'); + } + if (_params.clear_xpcom) { + data[ _params.stash_name ] = undefined; data.stash( _params.stash_name ); + } + if (typeof _params.concat == 'undefined') { + //alert(param_name + ' x = ' + x); + return x; // value + } else { + if (value) { + if (value.constructor != Array) value = [ value ]; + value = value.concat(x); + } else { + value = x; + } + } + } + } + } + //alert(param_name + ' value = ' + value); + return value; + } catch(E) { + dump('xul_param error: ' + E + '\n'); + } + } - function get_bool(a) { - // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false, and '0' == false (newer JSON is returning '0' instead of 0 in cases) - // So false includes 'f', '', '0', 0, null, and undefined - if (a == 'f') return false; - if (a == 'F') return false; - if (a == '0') return false; - if (a) return true; else return false; - } + function get_bool(a) { + // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false, and '0' == false (newer JSON is returning '0' instead of 0 in cases) + // So false includes 'f', '', '0', 0, null, and undefined + if (a == 'f') return false; + if (a == 'F') return false; + if (a == '0') return false; + if (a) return true; else return false; + } - function get_db_true() { - return 't'; - } + function get_db_true() { + return 't'; + } - function get_db_false() { - return 'f'; - } + function get_db_false() { + return 'f'; + } - function copy_to_clipboard(ev) { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var text; - if (typeof ev == 'object') { - if (typeof ev.target != 'undefined') { - if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent; - if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value; - } - } else if (typeof ev == 'string') { - text = ev; - } - const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] - .getService(Components.interfaces.nsIClipboardHelper); - gClipboardHelper.copyString(text); + function copy_to_clipboard(ev) { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var text; + if (typeof ev == 'object') { + if (typeof ev.target != 'undefined') { + if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent; + if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value; + } + } else if (typeof ev == 'string') { + text = ev; + } + const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] + .getService(Components.interfaces.nsIClipboardHelper); + gClipboardHelper.copyString(text); var Strings = $('offlineStrings') || $('commonStrings'); - alert(Strings.getFormattedString('openils.global_util.clipboard', [text])); - } catch(E) { + alert(Strings.getFormattedString('openils.global_util.clipboard', [text])); + } catch(E) { var Strings = $('offlineStrings') || $('commonStrings'); - alert(Strings.getFormattedString('openils.global_util.clipboard.error', [E])); - } - } + alert(Strings.getFormattedString('openils.global_util.clipboard.error', [E])); + } + } - function clear_the_cache() { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"]; - var cacheService = cacheClass.getService(Components.interfaces.nsICacheService); - cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK); - cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY); - } catch(E) { + function clear_the_cache() { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"]; + var cacheService = cacheClass.getService(Components.interfaces.nsICacheService); + cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK); + cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY); + } catch(E) { var Strings = $('offlineStrings') || $('commonStrings'); - alert(Strings.getFormattedString('openils.global_util.clear_cache.error', [E])); - } - } + alert(Strings.getFormattedString('openils.global_util.clear_cache.error', [E])); + } + } - function toOpenWindowByType(inType, uri) { - var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"; - window.open(uri, "_blank", winopts); - } + function toOpenWindowByType(inType, uri) { + var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"; + window.open(uri, "_blank", winopts); + } - function url_prefix(url) { - if (url.match(/^\//)) url = urls.remote + url; - if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url; - dump('url_prefix = ' + url + '\n'); - return url; - } + function url_prefix(url) { + if (url.match(/^\//)) url = urls.remote + url; + if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url; + dump('url_prefix = ' + url + '\n'); + return url; + } diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util/fmall.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util/fmall.js index 2032b12336..a1384ace65 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util/fmall.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util/fmall.js @@ -1,15 +1,15 @@ try { - if (typeof JSAN == 'undefined') { - throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); - } - JSAN.errorLevel = "die"; // none, warn, or die - JSAN.addRepository('..'); - JSAN.use('OpenILS.data'); - var data = new OpenILS.data(); data.init({'via':'stash'}); - var url = data.server + urls.fieldmapper; - dump('url = ' + url + '\n'); - var js = JSAN._loadJSFromUrl( url ); - eval( js ); + if (typeof JSAN == 'undefined') { + throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); + } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('..'); + JSAN.use('OpenILS.data'); + var data = new OpenILS.data(); data.init({'via':'stash'}); + var url = data.server + urls.fieldmapper; + dump('url = ' + url + '\n'); + var js = JSAN._loadJSFromUrl( url ); + eval( js ); } catch(E) { - alert('fmall.js: ' + E); + alert('fmall.js: ' + E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_chrome.xul b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_chrome.xul index cc4e031082..98ec9e8c43 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_chrome.xul +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_chrome.xul @@ -2,22 +2,22 @@ - - - - + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_offline.xul b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_offline.xul index 17b7370a22..d3ef41f1cd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_offline.xul +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/util_overlay_offline.xul @@ -4,16 +4,16 @@ - - - + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/admin/survey.js b/Open-ILS/xul/staff_client/chrome/content/admin/survey.js index 8bed642ac3..42b37a5fde 100644 --- a/Open-ILS/xul/staff_client/chrome/content/admin/survey.js +++ b/Open-ILS/xul/staff_client/chrome/content/admin/survey.js @@ -60,225 +60,225 @@ function render_lib_menu() { function survey_init() { - dump('survey_init()\n'); - render_lib_menu(); - SURVEY['asv'] = new asv(); SURVEY['asv'].isnew('1'); - SURVEY['num_of_questions'] = 0; - document.getElementById('survey_name').focus(); + dump('survey_init()\n'); + render_lib_menu(); + SURVEY['asv'] = new asv(); SURVEY['asv'].isnew('1'); + SURVEY['num_of_questions'] = 0; + document.getElementById('survey_name').focus(); } function save_survey() { - SURVEY.asv.description( - document.getElementById('survey_description').value - ); - SURVEY.asv.name( - document.getElementById('survey_name').value - ); - SURVEY.asv.owner( - document.getElementById('lib_menulist').value - ); - var survey_start = document.getElementById('survey_start').value; - if (survey_start) { - SURVEY.asv.start_date( - survey_start - ); - } else { - SURVEY.asv.start_date( - null - ); - } - var survey_end = document.getElementById('survey_end').value; - if (survey_end) { - SURVEY.asv.end_date( - survey_end - ); - } else { - SURVEY.asv.end_date( - null - ); - } - if ( document.getElementById('required_checkbox').checked ) { - SURVEY.asv.required('1'); - } else { - SURVEY.asv.required('0'); - } - if ( document.getElementById('opac_checkbox').checked ) { - SURVEY.asv.opac('1'); - } else { - SURVEY.asv.opac('0'); - } - if ( document.getElementById('poll_checkbox').checked ) { - SURVEY.asv.poll('1'); - } else { - SURVEY.asv.poll('0'); - } - - if ( document.getElementById('patron_summary_checkbox').checked ) { - SURVEY.asv.usr_summary('1'); - } else { - SURVEY.asv.usr_summary('0'); - } - g.error.sdump('D_SURVEY', 'before survey = ' + js2JSON( SURVEY.asv ) + '\n'); - try { - var result = g.network.request( - api.FM_ASV_CREATE.app, - api.FM_ASV_CREATE.method, - [ ses(), SURVEY.asv ] - ); - if (! (result instanceof asv) ) { - throw('save_survey: result not an asv'); - } else { - var surveys_list = g.OpenILS.data.list.asv; - var surveys_hash = g.OpenILS.data.hash.asv; - surveys_list.push( result ); - surveys_hash[ result.id() ] = result; - g.OpenILS.data.stash('list','hash'); - } - } catch(E) { - var err = ('Survey failed: ' + js2JSON(E) + '\n'); - g.error.sdump('D_ERROR',err); - alert(err); - throw(err); - } - g.error.sdump('D_SURVEY', 'after survey = ' + js2JSON( SURVEY.asv ) + '\n'); + SURVEY.asv.description( + document.getElementById('survey_description').value + ); + SURVEY.asv.name( + document.getElementById('survey_name').value + ); + SURVEY.asv.owner( + document.getElementById('lib_menulist').value + ); + var survey_start = document.getElementById('survey_start').value; + if (survey_start) { + SURVEY.asv.start_date( + survey_start + ); + } else { + SURVEY.asv.start_date( + null + ); + } + var survey_end = document.getElementById('survey_end').value; + if (survey_end) { + SURVEY.asv.end_date( + survey_end + ); + } else { + SURVEY.asv.end_date( + null + ); + } + if ( document.getElementById('required_checkbox').checked ) { + SURVEY.asv.required('1'); + } else { + SURVEY.asv.required('0'); + } + if ( document.getElementById('opac_checkbox').checked ) { + SURVEY.asv.opac('1'); + } else { + SURVEY.asv.opac('0'); + } + if ( document.getElementById('poll_checkbox').checked ) { + SURVEY.asv.poll('1'); + } else { + SURVEY.asv.poll('0'); + } + + if ( document.getElementById('patron_summary_checkbox').checked ) { + SURVEY.asv.usr_summary('1'); + } else { + SURVEY.asv.usr_summary('0'); + } + g.error.sdump('D_SURVEY', 'before survey = ' + js2JSON( SURVEY.asv ) + '\n'); + try { + var result = g.network.request( + api.FM_ASV_CREATE.app, + api.FM_ASV_CREATE.method, + [ ses(), SURVEY.asv ] + ); + if (! (result instanceof asv) ) { + throw('save_survey: result not an asv'); + } else { + var surveys_list = g.OpenILS.data.list.asv; + var surveys_hash = g.OpenILS.data.hash.asv; + surveys_list.push( result ); + surveys_hash[ result.id() ] = result; + g.OpenILS.data.stash('list','hash'); + } + } catch(E) { + var err = ('Survey failed: ' + js2JSON(E) + '\n'); + g.error.sdump('D_ERROR',err); + alert(err); + throw(err); + } + g.error.sdump('D_SURVEY', 'after survey = ' + js2JSON( SURVEY.asv ) + '\n'); } var original_description; function setDescription(e,t) { - var page = document.getElementById(e); - var desc = page.getAttribute('description'); - if (!original_description) original_description = desc; - var value = document.getElementById(t).value; - page.setAttribute('description',original_description + ' ' + value); + var page = document.getElementById(e); + var desc = page.getAttribute('description'); + if (!original_description) original_description = desc; + var value = document.getElementById(t).value; + page.setAttribute('description',original_description + ' ' + value); } var new_id = -1; function add_answer(e, my_asvq_id) { - var row = e.target.parentNode; - var rows = row.parentNode; - var answer = e.target.previousSibling; answer.select(); - - if (! answer.value ) { return; } - - /* XUL */ - var n_row = document.createElement('row'); - rows.insertBefore( n_row, row ); - var label_1 = document.createElement('label'); - n_row.appendChild( label_1 ); - var label_2 = document.createElement('label'); - label_2.setAttribute('value', answer.value ); - n_row.appendChild( label_2 ); - - /* OBJECT */ - - var my_asva = new asva(); my_asva.isnew('1'); my_asva.id( new_id-- ); - my_asva.answer( answer.value ); - - JSAN.use('util.functional'); - var my_asvq = util.functional.find_id_object_in_list( SURVEY.asv.questions(), my_asvq_id ); - if (my_asvq.answers() == null) { - my_asvq.answers( [] ); - } - - my_asvq.answers().push( my_asva ); - - var num_of_answers = my_asvq.answers().length; - var last_number = 96 + num_of_answers; - var next_number = 97 + num_of_answers; - var last_letter = String.fromCharCode( last_number ); - var next_letter = String.fromCharCode( next_number ); - label_1.setAttribute('value', last_letter + ')' ); - row.firstChild.setAttribute('value', next_letter + ')' ); - - if (num_of_answers == 26) { - rows.removeChild(row); - } + var row = e.target.parentNode; + var rows = row.parentNode; + var answer = e.target.previousSibling; answer.select(); + + if (! answer.value ) { return; } + + /* XUL */ + var n_row = document.createElement('row'); + rows.insertBefore( n_row, row ); + var label_1 = document.createElement('label'); + n_row.appendChild( label_1 ); + var label_2 = document.createElement('label'); + label_2.setAttribute('value', answer.value ); + n_row.appendChild( label_2 ); + + /* OBJECT */ + + var my_asva = new asva(); my_asva.isnew('1'); my_asva.id( new_id-- ); + my_asva.answer( answer.value ); + + JSAN.use('util.functional'); + var my_asvq = util.functional.find_id_object_in_list( SURVEY.asv.questions(), my_asvq_id ); + if (my_asvq.answers() == null) { + my_asvq.answers( [] ); + } + + my_asvq.answers().push( my_asva ); + + var num_of_answers = my_asvq.answers().length; + var last_number = 96 + num_of_answers; + var next_number = 97 + num_of_answers; + var last_letter = String.fromCharCode( last_number ); + var next_letter = String.fromCharCode( next_number ); + label_1.setAttribute('value', last_letter + ')' ); + row.firstChild.setAttribute('value', next_letter + ')' ); + + if (num_of_answers == 26) { + rows.removeChild(row); + } } function add_question() { - SURVEY.num_of_questions++; - var question = document.getElementById('new_question'); + SURVEY.num_of_questions++; + var question = document.getElementById('new_question'); - if (! question.value ) { return; } + if (! question.value ) { return; } - document.getElementById('survey_add').canAdvance = true; + document.getElementById('survey_add').canAdvance = true; - var my_asvq = new asvq(); my_asvq.isnew('1'); my_asvq.id( new_id-- ); - my_asvq.question( question.value ); + var my_asvq = new asvq(); my_asvq.isnew('1'); my_asvq.id( new_id-- ); + my_asvq.question( question.value ); - if ( SURVEY.asv.questions() == null ) { - SURVEY.asv.questions( [] ); - } + if ( SURVEY.asv.questions() == null ) { + SURVEY.asv.questions( [] ); + } - SURVEY.asv.questions().push( my_asvq ); + SURVEY.asv.questions().push( my_asvq ); - add_question_row(my_asvq); + add_question_row(my_asvq); - document.getElementById('new_question_label').setAttribute('value', '#' + (SURVEY.num_of_questions + 1) ); - //question.select(); - if (last_answer) last_answer.focus(); + document.getElementById('new_question_label').setAttribute('value', '#' + (SURVEY.num_of_questions + 1) ); + //question.select(); + if (last_answer) last_answer.focus(); } function add_question_row(my_asvq) { - var rows = document.getElementById('page2_grid1_rows'); - var row = document.createElement('row'); - rows.insertBefore(row, document.getElementById('page2_grid1_row1')); - - var label_number = document.createElement('label'); - label_number.setAttribute('value','#' + SURVEY['num_of_questions']); - row.appendChild(label_number); - - var grid = document.createElement('grid'); - row.appendChild(grid); - var g_cols = document.createElement('columns'); - grid.appendChild(g_cols); - var g_col_1 = document.createElement('column'); - g_cols.appendChild(g_col_1); - var g_col_2 = document.createElement('column'); - g_col_2.setAttribute('flex','1'); - g_cols.appendChild(g_col_2); - var g_col_3 = document.createElement('column'); - g_cols.appendChild(g_col_3); - var g_rows = document.createElement('rows'); - grid.appendChild(g_rows); - var g_row_1 = document.createElement('row'); - g_rows.appendChild(g_row_1); - var g_label_1 = document.createElement('label'); - g_row_1.appendChild(g_label_1); - var g_label_2 = document.createElement('label'); - g_label_2.setAttribute('value', my_asvq.question() ); - g_row_1.appendChild(g_label_2); - var g_row_2 = document.createElement('row'); - g_rows.appendChild(g_row_2); - var g_label2_1 = document.createElement('label'); - g_label2_1.setAttribute('value', 'a)' ); - g_row_2.appendChild(g_label2_1); - var g_tb = document.createElement('textbox'); - g_tb.setAttribute('flex','1'); - g_row_2.appendChild(g_tb); - if (last_button) last_button.setAttribute('accesskey',''); - var g_b = document.createElement('button'); - var strbundle = document.getElementById("offlineStrings"); - g_b.setAttribute('label', strbundle.getString('staff.admin.survey.save_response.label')); - g_b.setAttribute('accesskey', strbundle.getString('staff.admin.survey.save_response.label')); - g_b.setAttribute('oncommand','add_answer(event,' + my_asvq.id() + ');'); - g_row_2.appendChild(g_b); - - var blank = document.createElement('row'); - rows.insertBefore( blank , document.getElementById('page2_grid1_row1') ); - var blank2 = document.createElement('label'); - blank2.setAttribute('value', ' '); - blank.appendChild( blank2 ); - - last_answer = g_tb; - last_button = g_b; + var rows = document.getElementById('page2_grid1_rows'); + var row = document.createElement('row'); + rows.insertBefore(row, document.getElementById('page2_grid1_row1')); + + var label_number = document.createElement('label'); + label_number.setAttribute('value','#' + SURVEY['num_of_questions']); + row.appendChild(label_number); + + var grid = document.createElement('grid'); + row.appendChild(grid); + var g_cols = document.createElement('columns'); + grid.appendChild(g_cols); + var g_col_1 = document.createElement('column'); + g_cols.appendChild(g_col_1); + var g_col_2 = document.createElement('column'); + g_col_2.setAttribute('flex','1'); + g_cols.appendChild(g_col_2); + var g_col_3 = document.createElement('column'); + g_cols.appendChild(g_col_3); + var g_rows = document.createElement('rows'); + grid.appendChild(g_rows); + var g_row_1 = document.createElement('row'); + g_rows.appendChild(g_row_1); + var g_label_1 = document.createElement('label'); + g_row_1.appendChild(g_label_1); + var g_label_2 = document.createElement('label'); + g_label_2.setAttribute('value', my_asvq.question() ); + g_row_1.appendChild(g_label_2); + var g_row_2 = document.createElement('row'); + g_rows.appendChild(g_row_2); + var g_label2_1 = document.createElement('label'); + g_label2_1.setAttribute('value', 'a)' ); + g_row_2.appendChild(g_label2_1); + var g_tb = document.createElement('textbox'); + g_tb.setAttribute('flex','1'); + g_row_2.appendChild(g_tb); + if (last_button) last_button.setAttribute('accesskey',''); + var g_b = document.createElement('button'); + var strbundle = document.getElementById("offlineStrings"); + g_b.setAttribute('label', strbundle.getString('staff.admin.survey.save_response.label')); + g_b.setAttribute('accesskey', strbundle.getString('staff.admin.survey.save_response.label')); + g_b.setAttribute('oncommand','add_answer(event,' + my_asvq.id() + ');'); + g_row_2.appendChild(g_b); + + var blank = document.createElement('row'); + rows.insertBefore( blank , document.getElementById('page2_grid1_row1') ); + var blank2 = document.createElement('label'); + blank2.setAttribute('value', ' '); + blank.appendChild( blank2 ); + + last_answer = g_tb; + last_button = g_b; } function page1_check_advance() { - if ( document.getElementById('survey_name').value ) { - document.getElementById('survey_add').canAdvance = true; - } else { - document.getElementById('survey_add').canAdvance = false; - } + if ( document.getElementById('survey_name').value ) { + document.getElementById('survey_add').canAdvance = true; + } else { + document.getElementById('survey_add').canAdvance = false; + } } diff --git a/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul b/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul index 0ac3dca092..8afa457c54 100644 --- a/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul +++ b/Open-ILS/xul/staff_client/chrome/content/admin/survey_overlay.xul @@ -1,96 +1,96 @@ + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - + - - - + + + - - - - - - - - - - + + - - + + - - - - - + + + + + - - + + - - - - - - - - + + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - -