1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame; var opac_url;
3 var marc_view_reset = true;
4 var marc_edit_reset = true;
5 var copy_browser_reset = true;
6 var manage_parts_reset = true;
7 var manage_multi_home_reset = true;
8 var hold_browser_reset = true;
9 var serctrl_view_reset = true;
11 function $(id) { return document.getElementById(id); }
15 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
16 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
17 JSAN.errorLevel = "die"; // none, warn, or die
18 JSAN.addRepository('..');
19 JSAN.use('util.error'); g.error = new util.error();
20 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
22 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
23 XML_HTTP_SERVER = g.data.server_unadorned;
25 // Pull in local customizations
26 var r = new XMLHttpRequest();
27 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
29 if (r.status == 200) {
30 dump('Evaluating /xul/server/skin/custom.js\n');
31 eval( r.responseText );
34 window.help_context_set_locally = true;
36 JSAN.use('util.network'); g.network = new util.network();
39 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
41 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
42 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
44 JSAN.use('util.deck');
45 top_pane = new util.deck('top_pane');
46 bottom_pane = new util.deck('bottom_pane');
51 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
52 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
57 function default_focus() {
58 opac_wrapper_set_help_context();
61 function opac_wrapper_set_help_context() {
63 dump('Entering opac.js, opac_wrapper_set_help_context\n');
64 var cw = bottom_pane.get_contentWindow();
65 if (cw && typeof cw['location'] != 'undefined') {
66 if (typeof cw.help_context_set_locally == 'undefined') {
68 'protocol' : cw.location.protocol,
69 'hostname' : cw.location.hostname,
70 'port' : cw.location.port,
71 'pathname' : cw.location.pathname,
74 xulG.set_help_context(help_params);
76 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
77 if (typeof cw.default_focus == 'function') {
82 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
83 dump('\tcw.location = ' + cw.location + '\n');
86 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
87 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
91 function set_brief_view() {
92 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
93 dump('spawning ' + url + '\n');
95 var content_params = {
96 'set_tab_name' : function(n) {
97 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
98 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
100 dump('no set_tab_name\n');
105 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
106 "set_patron_tab", "volume_item_creator", "get_new_session",
107 "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
108 "network_meter", "page_meter", "set_statusbar", "set_help_context",
110 ].forEach(function(k) { content_params[k] = xulG[k]; });
119 function set_marc_view() {
120 g.view = 'marc_view';
121 if (marc_view_reset) {
122 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
123 marc_view_reset = false;
125 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
127 opac_wrapper_set_help_context();
128 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
131 function set_marc_edit() {
132 g.view = 'marc_edit';
133 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
136 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
137 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
138 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
140 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
141 cat.util.spawn_copy_editor = function(params) {
143 if (!params.copy_ids && !params.copies) return;
144 if (params.copy_ids && params.copy_ids.length == 0) return;
145 if (params.copies && params.copies.length == 0) return;
146 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
147 if (!params.caller_handles_update) params.handle_update = 1; // legacy
150 JSAN.use('util.network'); obj.network = new util.network();
151 JSAN.use('util.error'); obj.error = new util.error();
154 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
155 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
156 else if(params.copies && params.copies.length > 1 && params.edit == 1)
157 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
158 else if(params.copy_ids && params.copy_ids.length == 1)
159 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
161 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
163 JSAN.use('util.window'); var win = new util.window();
164 var my_xulG = win.open(
165 (urls.XUL_COPY_EDITOR),
167 'chrome,modal,resizable',
170 if (!my_xulG.copies && params.edit) {
172 return my_xulG.copies;
176 JSAN.use('util.error'); var error = new util.error();
177 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
180 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
184 JSAN.use('util.error'); error = new util.error();
185 JSAN.use('util.network'); var network = new util.network();
187 var acn_blob = network.simple_request(
188 'FM_ACN_FIND_OR_CREATE',
189 [ ses(), cn_label, doc_id, ses('ws_ou') ]
192 if (typeof acn_blob.ilsevent != 'undefined') {
193 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
197 // Get the default copy status; default to available if unset, per 1.6
198 var fast_ccs = g.data.hash.aous['cat.default_copy_status_fast'] || 0;
200 var copy_obj = new acp();
203 copy_obj.barcode( cp_barcode );
204 copy_obj.call_number( acn_blob.acn_id );
205 copy_obj.circ_lib( ses('ws_ou') );
206 /* FIXME -- use constants */
209 copy_obj.deposit_amount(0);
210 copy_obj.fine_level(2); // Normal
211 copy_obj.loan_duration(2); // Normal
212 copy_obj.location(1); // Stacks
213 copy_obj.status(fast_ccs);
214 copy_obj.circulate(get_db_true());
215 copy_obj.holdable(get_db_true());
216 copy_obj.opac_visible(get_db_true());
217 copy_obj.ref(get_db_false());
218 copy_obj.mint_condition(get_db_true());
220 JSAN.use('util.window'); var win = new util.window();
222 var unified_interface = String( data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
223 if (unified_interface) {
224 var horizontal_interface = String( data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
225 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
226 var w = xulG.set_tab(
229 'tab_name' : document.getElementById('offlineStrings').getFormattedString(
236 'existing_copies' : [ copy_obj ],
237 'load_opac_when_done' : true,
238 'labels_in_new_tab' : true
243 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
247 if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E);
250 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
252 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
256 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
257 'func' : function (new_marcxml) {
259 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
260 marc_view_reset = true;
261 copy_browser_reset = true;
262 hold_browser_reset = true;
263 if (typeof r.ilsevent != 'undefined') {
268 'oncomplete' : function() {}
272 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
276 'lock_tab' : xulG.lock_tab,
277 'unlock_tab' : xulG.unlock_tab
279 if (marc_edit_reset) {
280 bottom_pane.reset_iframe( a,b,c );
281 marc_edit_reset = false;
283 bottom_pane.set_iframe( a,b,c );
285 opac_wrapper_set_help_context();
286 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
289 function set_copy_browser() {
290 g.view = 'copy_browser';
291 if (copy_browser_reset) {
292 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
293 copy_browser_reset =false;
295 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
297 opac_wrapper_set_help_context();
298 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
301 function set_hold_browser() {
302 g.view = 'hold_browser';
303 if (hold_browser_reset) {
304 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
305 hold_browser_reset = false;
307 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
309 opac_wrapper_set_help_context();
310 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
314 function open_acq_orders() {
316 var content_params = {
318 "authtime": ses("authtime"),
320 "show_nav_buttons": true,
321 "show_print_button": false
324 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
325 "set_patron_tab", "volume_item_creator", "get_new_session",
326 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
327 "url_prefix", "network_meter", "page_meter", "set_statusbar",
328 "set_help_context", "get_barcode"
329 ].forEach(function(k) { content_params[k] = xulG[k]; });
331 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
332 xulG.url_prefix("/eg/acq/lineitem/related/") +
333 docid + "?target=bib"
337 "tab_name": $("offlineStrings").getString(
338 "staff.cat.opac.related_items"
344 g.error.sdump("D_ERROR", E);
348 function open_alt_serial_mgmt() {
350 var content_params = {
352 "authtime": ses("authtime"),
353 "show_nav_buttons": true,
355 "show_print_button": false
358 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
359 "set_patron_tab", "volume_item_creator", "get_new_session",
360 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
361 "url_prefix", "network_meter", "page_meter", "set_statusbar",
362 "set_help_context", "get_barcode"
363 ].forEach(function(k) { content_params[k] = xulG[k]; });
365 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
366 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
371 "tab_name": $("offlineStrings").getString(
372 "staff.cat.opac.serial_alt_mgmt"
378 g.error.sdump("D_ERROR", E);
382 function set_opac() {
385 var content_params = {
386 'show_nav_buttons' : true,
387 'show_print_button' : true,
388 'passthru_content_params' : {
390 'authtime' : ses('authtime'),
391 'window_open' : function(a,b,c) {
393 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
394 return window.open(a,b,c);
396 g.error.standard_unexpected_error_alert('window_open',E);
399 'get_barcode' : xulG.get_barcode
401 'on_url_load' : function(f) {
402 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
405 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
406 win = f.contentWindow.wrappedJSObject;
408 win = f.contentWindow;
411 win = f.contentWindow;
413 win.attachEvt("rdetail", "recordRetrieved",
416 if (docid == id) return;
420 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
425 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
426 $('record_start').disabled = true; $('record_next').disabled = true;
427 $('record_prev').disabled = true; $('record_end').disabled = true;
428 $('record_pos').setAttribute('value','');
430 win.attachEvt("rdetail", "nextPrevDrawn",
431 function(rIndex,rCount){
432 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
433 if (win.rdetailNext) {
434 g.f_record_next = function() {
435 g.view_override = g.view;
438 $('record_next').disabled = false;
440 if (win.rdetailPrev) {
441 g.f_record_prev = function() {
442 g.view_override = g.view;
445 $('record_prev').disabled = false;
447 if (win.rdetailStart) {
448 g.f_record_start = function() {
449 g.view_override = g.view;
452 $('record_start').disabled = false;
454 if (win.rdetailEnd) {
455 g.f_record_end = function() {
456 g.view_override = g.view;
459 $('record_end').disabled = false;
464 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
465 var mfhd_edit_menu = $('mfhd_edit');
466 var mfhd_delete_menu = $('mfhd_delete');
468 // clear menus on subsequent loads
469 if (mfhd_edit_menu.firstChild) {
470 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
471 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
474 mfhd_edit_menu.disabled = true;
475 mfhd_delete_menu.disabled = true;
477 win.attachEvt("rdetail", "MFHDDrawn",
479 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
481 g.mfhd.details = win.mfhdDetails;
482 mfhd_edit_menu.disabled = false;
483 mfhd_delete_menu.disabled = false;
484 for (var i = 0; i < win.mfhdDetails.length; i++) {
485 var mfhd_details = win.mfhdDetails[i];
486 var num = mfhd_details.entryNum;
488 var label = mfhd_details.label + ' (' + num + ')';
489 var item = mfhd_edit_menu.appendItem(label);
490 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
491 item = mfhd_delete_menu.appendItem(label);
492 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
494 } else if (g.mfhd) { // clear from previous runs if deleting last MFHD
497 var change_event = document.createEvent("Event");
498 change_event.initEvent("MFHDChange",false,false);
499 window.dispatchEvent(change_event);
503 'url_prefix' : xulG.url_prefix,
505 content_params.new_tab = xulG.new_tab;
506 content_params.set_tab = xulG.set_tab;
507 content_params.close_tab = xulG.close_tab;
508 content_params.lock_tab = xulG.lock_tab;
509 content_params.unlock_tab = xulG.unlock_tab;
510 content_params.inspect_tab = xulG.inspect_tab;
511 content_params.new_patron_tab = xulG.new_patron_tab;
512 content_params.set_patron_tab = xulG.set_patron_tab;
513 content_params.volume_item_creator = xulG.volume_item_creator;
514 content_params.get_new_session = xulG.get_new_session;
515 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
516 content_params.set_tab_name = xulG.set_tab_name;
517 content_params.open_chrome_window = xulG.open_chrome_window;
518 content_params.url_prefix = xulG.url_prefix;
519 content_params.network_meter = xulG.network_meter;
520 content_params.page_meter = xulG.page_meter;
521 content_params.set_statusbar = xulG.set_statusbar;
522 content_params.set_help_context = xulG.set_help_context;
523 content_params.get_barcode = xulG.get_barcode;
525 var secure_opac = true; // default to secure
526 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
527 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
528 if (prefs.prefHasUserValue('oils.secure_opac')) {
529 secure_opac = prefs.getBoolPref('oils.secure_opac');
531 dump('secure_opac = ' + secure_opac + '\n');
534 content_params.url = xulG.url_prefix( opac_url, secure_opac );
536 content_params.url = xulG.url_prefix( urls.browser, secure_opac );
538 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
539 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
540 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
543 g.error.sdump('D_ERROR','set_opac: ' + E);
545 opac_wrapper_set_help_context();
546 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
549 function set_serctrl_view() {
550 g.view = 'serctrl_view';
551 if (serctrl_view_reset) {
552 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
553 serctrl_view_reset =false;
555 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
559 function create_mfhd() {
560 // Check if the source is allowed to have copies, first.
562 var bibObj = g.network.request(
563 api.FM_BRE_RETRIEVE_VIA_ID.app,
564 api.FM_BRE_RETRIEVE_VIA_ID.method,
570 var cbsObj = g.network.request(
571 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
572 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
573 [ ses(), bibObj.source() ]
576 if (cbsObj.can_have_copies() != get_db_true()) {
577 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
581 g.error.sdump('D_ERROR','can have copies check: ' + E);
582 alert('Error in chrome/content/cat/opac.js, create_mfhd(): ' + E);
587 JSAN.use('util.window'); var win = new util.window();
588 var select_aou_window = win.open(
589 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
591 'chrome,resizable,modal,centerscreen',
592 {'server_unadorned' : g.data.server_unadorned}
594 if (!select_aou_window.create_mfhd_aou) {
597 var r = g.network.simple_request(
598 'MFHD_XML_RECORD_CREATE',
599 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
601 if (typeof r.ilsevent != 'undefined') {
604 alert("MFHD record created."); //TODO: better success message
605 browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
607 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
611 function delete_mfhd(sre_id) {
612 if (g.error.yns_alert(
613 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
614 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
615 document.getElementById('offlineStrings').getString('cat.opac.delete'),
616 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
618 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
619 var robj = g.network.request(
620 'open-ils.permacrud',
621 'open-ils.permacrud.delete.sre',
623 if (typeof robj.ilsevent != 'undefined') {
624 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
626 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
627 browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
632 function open_mfhd_editor(sre_id) {
634 var r = g.network.simple_request(
638 if (typeof r.ilsevent != 'undefined') {
641 open_marc_editor(r, 'MFHD');
643 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
647 function open_marc_editor(rec, label) {
648 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
651 record : {marc : rec.marc()},
653 label: 'Save ' + label,
654 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
655 var method = 'open-ils.permacrud.update.' + rec.classname;
658 'open-ils.permacrud', method,
666 function bib_in_new_tab() {
668 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
669 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
670 content_params.url_prefix = xulG.url_prefix;
671 content_params.new_tab = xulG.new_tab;
672 content_params.set_tab = xulG.set_tab;
673 content_params.close_tab = xulG.close_tab;
674 content_params.lock_tab = xulG.lock_tab;
675 content_params.unlock_tab = xulG.unlock_tab;
676 content_params.inspect_tab = xulG.inspect_tab;
677 content_params.new_patron_tab = xulG.new_patron_tab;
678 content_params.set_patron_tab = xulG.set_patron_tab;
679 content_params.volume_item_creator = xulG.volume_item_creator;
680 content_params.get_new_session = xulG.get_new_session;
681 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
682 content_params.set_tab_name = xulG.set_tab_name;
683 content_params.open_chrome_window = xulG.open_chrome_window;
684 content_params.url_prefix = xulG.url_prefix;
685 content_params.network_meter = xulG.network_meter;
686 content_params.page_meter = xulG.page_meter;
687 content_params.set_statusbar = xulG.set_statusbar;
688 content_params.set_help_context = xulG.set_help_context;
689 content_params.get_barcode = xulG.get_barcode;
691 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
693 g.error.sdump('D_ERROR',E);
697 function batch_receive_in_new_tab() {
699 var content_params = {"session": ses(), "authtime": ses("authtime")};
701 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
702 "set_patron_tab", "volume_item_creator", "get_new_session",
703 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
704 "url_prefix", "network_meter", "page_meter", "set_statusbar",
705 "set_help_context", "get_barcode"
706 ].forEach(function(k) { content_params[k] = xulG[k]; });
709 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
710 "?docid=" + window.escape(docid), {
711 "tab_name": $("offlineStrings").getString(
712 "menu.cmd_serial_batch_receive.tab"
717 g.error.sdump("D_ERROR", E);
721 function remove_me() {
722 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
723 dump('removing ' + url + '\n');
724 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
725 $('nav').setAttribute('hidden','true');
728 function add_to_bucket() {
729 JSAN.use('util.window'); var win = new util.window();
731 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
733 'chrome,resizable,modal,centerscreen',
735 record_ids: [ docid ]
740 // FIXME: now duplicated in cat.util, which we can't import here, though maybe
741 // we can do something at build time
742 function mark_for_overlay() {
743 g.data.marked_record = docid;
744 g.data.stash('marked_record');
745 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
746 if (typeof robj.ilsevent == 'undefined') {
747 g.data.marked_record_mvr = robj;
749 g.data.marked_record_mvr = null;
750 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
752 g.data.stash('marked_record_mvr');
753 if (g.data.marked_record_mvr) {
754 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
757 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
758 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
759 gen_statusbar_click_handler('marked_record')
762 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
765 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
767 gen_statusbar_click_handler('marked_record')
772 function mark_for_hold_transfer() {
773 g.data.marked_record_for_hold_transfer = docid;
774 g.data.stash('marked_record_for_hold_transfer');
775 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
776 if (typeof robj.ilsevent == 'undefined') {
777 g.data.marked_record_for_hold_transfer_mvr = robj;
779 g.data.marked_record_for_hold_transfer_mvr = null;
780 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
782 g.data.stash('marked_record_for_hold_transfer_mvr');
783 if (g.data.marked_record_mvr) {
784 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
790 gen_statusbar_click_handler('marked_record_for_hold_transfer')
793 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
799 gen_statusbar_click_handler('marked_record_for_hold_transfer')
804 function transfer_title_holds() {
805 g.data.stash_retrieve();
806 var target = g.data.marked_record_for_hold_transfer;
808 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
812 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
814 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
817 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
820 hold_browser_reset = true;
821 if (g.view == 'hold_browser') { set_hold_browser(); };
824 function delete_record() {
825 if (g.error.yns_alert(
826 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
827 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
828 document.getElementById('offlineStrings').getString('cat.opac.delete'),
829 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
831 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
832 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
833 if (typeof robj.ilsevent != 'undefined') {
834 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
836 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
837 refresh_display(docid);
842 function undelete_record() {
843 if (g.error.yns_alert(
844 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
845 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
846 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
847 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
849 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
851 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
852 if (typeof robj.ilsevent != 'undefined') {
853 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
855 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
856 refresh_display(docid);
861 function refresh_display(id) {
863 marc_view_reset = true;
864 marc_edit_reset = true;
865 copy_browser_reset = true;
866 hold_browser_reset = true;
867 manage_parts_reset = true;
868 manage_multi_home_reset = true;
869 serctrl_view_reset = true;
870 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
871 var children = bottom_pane.node.childNodes;
872 for (var i = 0; i < children.length; i++) {
873 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
877 $('nav').setAttribute('hidden','false');
878 var settings = g.network.simple_request(
880 [ ses(), g.data.list.au[0].id() ]
882 var view = settings['staff_client.catalog.record_view.default'];
883 if (g.view_override) {
884 view = g.view_override;
885 g.view_override = null;
888 case 'marc_view' : set_marc_view(); break;
889 case 'marc_edit' : set_marc_edit(); break;
890 case 'copy_browser' : set_copy_browser(); break;
891 case 'hold_browser' : set_hold_browser(); break;
892 case 'serctrl_view' : set_serctrl_view(); break;
894 default: set_opac(); break;
896 opac_wrapper_set_help_context();
898 g.error.standard_unexpected_error_alert('in refresh_display',E);
902 function set_default() {
903 var robj = g.network.simple_request(
905 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
907 if (typeof robj.ilsevent != 'undefined') {
908 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
912 function add_volumes() {
916 edit = g.network.request(
917 api.PERM_MULTI_ORG_CHECK.app,
918 api.PERM_MULTI_ORG_CHECK.method,
923 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
925 ).length == 0 ? 1 : 0;
927 g.error.sdump('D_ERROR','batch permission check: ' + E);
931 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
932 return; // no read-only view for this interface
935 // Check if the source is allowed to have copies.
937 var bibObj = g.network.request(
938 api.FM_BRE_RETRIEVE_VIA_ID.app,
939 api.FM_BRE_RETRIEVE_VIA_ID.method,
945 var cbsObj = g.network.request(
946 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
947 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
948 [ ses(), bibObj.source() ]
951 if (cbsObj.can_have_copies() != get_db_true()) {
952 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
956 g.error.sdump('D_ERROR','can have copies check: ' + E);
957 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
961 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
964 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
965 if (unified_interface) {
966 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
967 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
969 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
972 var w = xulG.new_tab(
974 { 'tab_name' : title },
975 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
978 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
982 function manage_parts() {
984 g.view = 'manage_parts';
985 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
986 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
988 if (manage_parts_reset) {
989 bottom_pane.reset_iframe( loc,{},xulG);
990 manage_parts_reset =false;
992 bottom_pane.set_iframe( loc,{},xulG);
994 opac_wrapper_set_help_context();
995 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
997 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
1001 function manage_multi_home_items() {
1003 g.view = 'manage_multi_home';
1004 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
1005 if (manage_multi_home_reset) {
1006 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1007 manage_multi_home_reset =false;
1009 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1011 opac_wrapper_set_help_context();
1012 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1014 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
1018 function mark_for_multi_home() {
1019 g.data.marked_multi_home_record = docid;
1020 g.data.stash('marked_multi_home_record');
1021 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
1022 if (typeof robj.ilsevent == 'undefined') {
1023 g.data.marked_multi_home_record_mvr = robj;
1025 g.data.marked_multi_home_record_mvr = null;
1026 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
1028 g.data.stash('marked_multi_home_record_mvr');
1030 if (g.data.marked_multi_home_record_mvr) {
1031 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
1034 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
1035 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1036 gen_statusbar_click_handler('marked_multi_home_record')
1039 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
1042 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1044 gen_statusbar_click_handler('marked_multi_home_record')
1049 function gen_statusbar_click_handler(data_key) {
1050 return function (ev) {
1052 if (! g.data[data_key]) {
1056 if (ev.button == 0 /* left click, spawn opac */) {
1057 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + g.data[data_key];
1058 var content_params = {
1060 'authtime' : ses('authtime'),
1061 'opac_url' : opac_url,
1064 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1065 {'tab_name':'Retrieving title...'},
1070 if (ev.button == 2 /* right click, remove mark */) {
1071 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1072 g.data[data_key] = null;
1073 g.data.stash(data_key);
1074 ev.target.setAttribute('label','');
1075 if (ev.target.hasAttribute('tooltiptext')) {
1076 ev.target.removeAttribute('tooltiptext');