1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_browser; 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",
109 "get_barcode", "reload_opac", "get_barcode_and_settings"
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 var x = cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
249 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);
252 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
254 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
258 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
259 'func' : function (new_marcxml) {
261 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
262 marc_view_reset = true;
263 copy_browser_reset = true;
264 hold_browser_reset = true;
266 if (typeof r.ilsevent != 'undefined') {
271 'oncomplete' : function() {}
275 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
279 'lock_tab' : xulG.lock_tab,
280 'unlock_tab' : xulG.unlock_tab
282 if (marc_edit_reset) {
283 bottom_pane.reset_iframe( a,b,c );
284 marc_edit_reset = false;
286 bottom_pane.set_iframe( a,b,c );
288 opac_wrapper_set_help_context();
289 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
292 function set_copy_browser() {
293 g.view = 'copy_browser';
294 if (copy_browser_reset) {
295 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
296 copy_browser_reset =false;
298 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
300 opac_wrapper_set_help_context();
301 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
304 function set_hold_browser() {
305 g.view = 'hold_browser';
306 if (hold_browser_reset) {
307 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
308 hold_browser_reset = false;
310 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
312 opac_wrapper_set_help_context();
313 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
317 function open_acq_orders() {
319 var content_params = {
321 "authtime": ses("authtime"),
323 "show_nav_buttons": true,
324 "show_print_button": false
327 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
328 "set_patron_tab", "volume_item_creator", "get_new_session",
329 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
330 "url_prefix", "network_meter", "page_meter", "set_statusbar",
331 "set_help_context", "get_barcode", "reload_opac",
332 "get_barcode_and_settings"
333 ].forEach(function(k) { content_params[k] = xulG[k]; });
335 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
336 xulG.url_prefix("/eg/acq/lineitem/related/") +
337 docid + "?target=bib"
341 "tab_name": $("offlineStrings").getString(
342 "staff.cat.opac.related_items"
348 g.error.sdump("D_ERROR", E);
352 function open_alt_serial_mgmt() {
354 var content_params = {
356 "authtime": ses("authtime"),
357 "show_nav_buttons": true,
359 "show_print_button": false,
360 "passthru_content_params": {
361 "reload_opac": xulG.reload_opac
365 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
366 "set_patron_tab", "volume_item_creator", "get_new_session",
367 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
368 "url_prefix", "network_meter", "page_meter", "set_statusbar",
369 "set_help_context", "get_barcode", "reload_opac",
370 "get_barcode_and_settings"
371 ].forEach(function(k) { content_params[k] = xulG[k]; });
373 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
374 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
379 "tab_name": $("offlineStrings").getString(
380 "staff.cat.opac.serial_alt_mgmt"
386 g.error.sdump("D_ERROR", E);
390 function set_opac() {
393 var content_params = {
394 'show_nav_buttons' : true,
395 'show_print_button' : true,
396 'passthru_content_params' : {
398 'authtime' : ses('authtime'),
399 'window_open' : function(a,b,c) {
401 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
402 return window.open(a,b,c);
404 g.error.standard_unexpected_error_alert('window_open',E);
407 'get_barcode' : xulG.get_barcode,
408 'get_barcode_and_settings' : xulG.get_barcode_and_settings
410 'on_url_load' : function(f) {
411 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
414 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
415 win = f.contentWindow.wrappedJSObject;
417 win = f.contentWindow;
420 win = f.contentWindow;
422 win.attachEvt("rdetail", "recordRetrieved",
425 if (docid == id) return;
429 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
434 g.f_record_start = null; g.f_record_prev = null;
435 g.f_record_next = null; g.f_record_end = null;
436 g.f_record_back_to_results = null;
437 $('record_start').disabled = true; $('record_next').disabled = true;
438 $('record_prev').disabled = true; $('record_end').disabled = true;
439 $('record_back_to_results').disabled = true;
440 $('record_pos').setAttribute('value','');
442 function safe_to_proceed() {
443 if (typeof xulG.is_tab_locked == 'undefined') { return true; }
444 if (! xulG.is_tab_locked()) { return true; }
445 var r = window.confirm(
446 document.getElementById('offlineStrings').getString(
447 'generic.unsaved_data_warning'
451 while ( xulG.unlock_tab() > 0 ) {};
458 win.attachEvt("rdetail", "nextPrevDrawn",
459 function(rIndex,rCount){
460 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
461 if (win.rdetailNext) {
462 g.f_record_next = function() {
463 if (safe_to_proceed()) {
464 g.view_override = g.view;
468 $('record_next').disabled = false;
470 if (win.rdetailPrev) {
471 g.f_record_prev = function() {
472 if (safe_to_proceed()) {
473 g.view_override = g.view;
477 $('record_prev').disabled = false;
479 if (win.rdetailStart) {
480 g.f_record_start = function() {
481 if (safe_to_proceed()) {
482 g.view_override = g.view;
486 $('record_start').disabled = false;
488 if (win.rdetailEnd) {
489 g.f_record_end = function() {
490 if (safe_to_proceed()) {
491 g.view_override = g.view;
495 $('record_end').disabled = false;
497 if (win.rdetailBackToResults) {
498 g.f_record_back_to_results = function() {
499 if (safe_to_proceed()) {
500 g.view_override = g.view;
501 win.rdetailBackToResults();
502 if (g.view != "opac") {
504 opac_wrapper_set_help_context();
508 $('record_back_to_results').disabled = false;
513 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
514 var mfhd_edit_menu = $('mfhd_edit');
515 var mfhd_delete_menu = $('mfhd_delete');
517 // clear menus on subsequent loads
518 if (mfhd_edit_menu.firstChild) {
519 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
520 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
523 mfhd_edit_menu.disabled = true;
524 mfhd_delete_menu.disabled = true;
526 win.attachEvt("rdetail", "MFHDDrawn",
528 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
530 g.mfhd.details = win.mfhdDetails;
531 mfhd_edit_menu.disabled = false;
532 mfhd_delete_menu.disabled = false;
533 for (var i = 0; i < win.mfhdDetails.length; i++) {
534 var mfhd_details = win.mfhdDetails[i];
535 var num = mfhd_details.entryNum;
537 var label = mfhd_details.label + ' (' + num + ')';
538 var item = mfhd_edit_menu.appendItem(label);
539 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
540 item = mfhd_delete_menu.appendItem(label);
541 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
543 } else if (g.mfhd) { // clear from previous runs if deleting last MFHD
546 var change_event = document.createEvent("Event");
547 change_event.initEvent("MFHDChange",false,false);
548 window.dispatchEvent(change_event);
552 'url_prefix' : xulG.url_prefix,
554 content_params.new_tab = xulG.new_tab;
555 content_params.set_tab = xulG.set_tab;
556 content_params.close_tab = xulG.close_tab;
557 content_params.lock_tab = xulG.lock_tab;
558 content_params.unlock_tab = xulG.unlock_tab;
559 content_params.inspect_tab = xulG.inspect_tab;
560 content_params.is_tab_locked = xulG.is_tab_locked;
561 content_params.new_patron_tab = xulG.new_patron_tab;
562 content_params.set_patron_tab = xulG.set_patron_tab;
563 content_params.volume_item_creator = xulG.volume_item_creator;
564 content_params.get_new_session = xulG.get_new_session;
565 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
566 content_params.set_tab_name = xulG.set_tab_name;
567 content_params.open_chrome_window = xulG.open_chrome_window;
568 content_params.url_prefix = xulG.url_prefix;
569 content_params.network_meter = xulG.network_meter;
570 content_params.page_meter = xulG.page_meter;
571 content_params.set_statusbar = xulG.set_statusbar;
572 content_params.set_help_context = xulG.set_help_context;
573 content_params.get_barcode = xulG.get_barcode;
574 content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
576 var secure_opac = true; // default to secure
577 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
578 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
579 if (prefs.prefHasUserValue('oils.secure_opac')) {
580 secure_opac = prefs.getBoolPref('oils.secure_opac');
582 dump('secure_opac = ' + secure_opac + '\n');
585 content_params.url = xulG.url_prefix( opac_url, secure_opac );
587 content_params.url = xulG.url_prefix( urls.browser, secure_opac );
589 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
590 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
591 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
594 g.error.sdump('D_ERROR','set_opac: ' + E);
596 opac_wrapper_set_help_context();
597 opac_browser = bottom_pane.get_contentWindow();
598 opac_browser.addEventListener('load',opac_wrapper_set_help_context,false);
601 xulG.reload_opac = function() {
603 JSAN.use('util.widgets');
604 opac_browser.g.browser.reload();
606 g.error.sdump("D_ERROR", 'error reloading opac: ' + E + '\n');
610 function set_serctrl_view() {
611 g.view = 'serctrl_view';
612 if (serctrl_view_reset) {
613 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
614 serctrl_view_reset =false;
616 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
620 function create_mfhd() {
621 // Check if the source is allowed to have copies, first.
623 var bibObj = g.network.request(
624 api.FM_BRE_RETRIEVE_VIA_ID.app,
625 api.FM_BRE_RETRIEVE_VIA_ID.method,
631 var cbsObj = g.network.request(
632 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
633 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
634 [ ses(), bibObj.source() ]
637 if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
638 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
642 g.error.sdump('D_ERROR','can have copies check: ' + E);
643 alert('Error in chrome/content/cat/opac.js, create_mfhd(): ' + E);
648 JSAN.use('util.window'); var win = new util.window();
649 var select_aou_window = win.open(
650 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
652 'chrome,resizable,modal,centerscreen',
653 {'server_unadorned' : g.data.server_unadorned}
655 if (!select_aou_window.create_mfhd_aou) {
658 var r = g.network.simple_request(
659 'MFHD_XML_RECORD_CREATE',
660 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
662 if (typeof r.ilsevent != 'undefined') {
665 alert("MFHD record created."); //TODO: better success message
666 xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
668 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
672 function delete_mfhd(sre_id) {
673 if (g.error.yns_alert(
674 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
675 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
676 document.getElementById('offlineStrings').getString('cat.opac.delete'),
677 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
679 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
680 var robj = g.network.request(
681 'open-ils.permacrud',
682 'open-ils.permacrud.delete.sre',
684 if (typeof robj.ilsevent != 'undefined') {
685 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
687 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
688 xulG.reload_opac(); // browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
693 function open_mfhd_editor(sre_id) {
695 var r = g.network.simple_request(
699 if (typeof r.ilsevent != 'undefined') {
702 open_marc_editor(r, 'MFHD');
704 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
708 function open_marc_editor(rec, label) {
709 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
712 record : {marc : rec.marc()},
714 label: 'Save ' + label,
715 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
716 var method = 'open-ils.permacrud.update.' + rec.classname;
719 'open-ils.permacrud', method,
728 function bib_in_new_tab() {
730 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
731 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
732 content_params.url_prefix = xulG.url_prefix;
733 content_params.new_tab = xulG.new_tab;
734 content_params.set_tab = xulG.set_tab;
735 content_params.close_tab = xulG.close_tab;
736 content_params.lock_tab = xulG.lock_tab;
737 content_params.unlock_tab = xulG.unlock_tab;
738 content_params.inspect_tab = xulG.inspect_tab;
739 content_params.is_tab_locked = xulG.is_tab_locked;
740 content_params.new_patron_tab = xulG.new_patron_tab;
741 content_params.set_patron_tab = xulG.set_patron_tab;
742 content_params.volume_item_creator = xulG.volume_item_creator;
743 content_params.get_new_session = xulG.get_new_session;
744 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
745 content_params.set_tab_name = xulG.set_tab_name;
746 content_params.open_chrome_window = xulG.open_chrome_window;
747 content_params.url_prefix = xulG.url_prefix;
748 content_params.network_meter = xulG.network_meter;
749 content_params.page_meter = xulG.page_meter;
750 content_params.set_statusbar = xulG.set_statusbar;
751 content_params.set_help_context = xulG.set_help_context;
752 content_params.get_barcode = xulG.get_barcode;
753 content_params.get_barcode_and_settings = xulG.get_barcode_and_settings;
755 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
757 g.error.sdump('D_ERROR',E);
761 function batch_receive_in_new_tab() {
763 var content_params = {"session": ses(), "authtime": ses("authtime")};
765 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
766 "set_patron_tab", "volume_item_creator", "get_new_session",
767 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
768 "url_prefix", "network_meter", "page_meter", "set_statusbar",
769 "set_help_context", "get_barcode", "reload_opac",
770 "get_barcode_and_settings"
771 ].forEach(function(k) { content_params[k] = xulG[k]; });
774 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
775 "?docid=" + window.escape(docid), {
776 "tab_name": $("offlineStrings").getString(
777 "menu.cmd_serial_batch_receive.tab"
782 g.error.sdump("D_ERROR", E);
786 function remove_me() {
787 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
788 dump('removing ' + url + '\n');
789 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
790 $('nav').setAttribute('hidden','true');
793 function add_to_bucket() {
794 JSAN.use('util.window'); var win = new util.window();
796 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
798 'chrome,resizable,modal,centerscreen',
800 record_ids: [ docid ]
805 // FIXME: now duplicated in cat.util, which we can't import here, though maybe
806 // we can do something at build time
807 function mark_for_overlay() {
808 g.data.marked_record = docid;
809 g.data.stash('marked_record');
810 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
811 if (typeof robj.ilsevent == 'undefined') {
812 g.data.marked_record_mvr = robj;
814 g.data.marked_record_mvr = null;
815 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
817 g.data.stash('marked_record_mvr');
818 if (g.data.marked_record_mvr) {
819 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
822 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
823 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
824 gen_statusbar_click_handler('marked_record')
827 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
830 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
832 gen_statusbar_click_handler('marked_record')
837 function mark_for_hold_transfer() {
838 g.data.marked_record_for_hold_transfer = docid;
839 g.data.stash('marked_record_for_hold_transfer');
840 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
841 if (typeof robj.ilsevent == 'undefined') {
842 g.data.marked_record_for_hold_transfer_mvr = robj;
844 g.data.marked_record_for_hold_transfer_mvr = null;
845 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
847 g.data.stash('marked_record_for_hold_transfer_mvr');
848 if (g.data.marked_record_mvr) {
849 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
855 gen_statusbar_click_handler('marked_record_for_hold_transfer')
858 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
864 gen_statusbar_click_handler('marked_record_for_hold_transfer')
869 function transfer_title_holds() {
870 g.data.stash_retrieve();
871 var target = g.data.marked_record_for_hold_transfer;
873 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
877 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
879 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
882 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
885 hold_browser_reset = true;
886 if (g.view == 'hold_browser') { set_hold_browser(); };
889 function delete_record() {
890 if (g.error.yns_alert(
891 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
892 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
893 document.getElementById('offlineStrings').getString('cat.opac.delete'),
894 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
896 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
897 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
898 if (typeof robj.ilsevent != 'undefined') {
899 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
901 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
902 refresh_display(docid);
907 function undelete_record() {
908 if (g.error.yns_alert(
909 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
910 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
911 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
912 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
914 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
916 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
917 if (typeof robj.ilsevent != 'undefined') {
918 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
920 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
921 refresh_display(docid);
926 function refresh_display(id) {
928 marc_view_reset = true;
929 marc_edit_reset = true;
930 copy_browser_reset = true;
931 hold_browser_reset = true;
932 manage_parts_reset = true;
933 manage_multi_home_reset = true;
934 serctrl_view_reset = true;
935 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
936 var children = bottom_pane.node.childNodes;
937 for (var i = 0; i < children.length; i++) {
938 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
942 $('nav').setAttribute('hidden','false');
943 var settings = g.network.simple_request(
945 [ ses(), g.data.list.au[0].id() ]
947 var view = settings['staff_client.catalog.record_view.default'];
948 if (g.view_override) {
949 view = g.view_override;
950 g.view_override = null;
953 case 'marc_view' : set_marc_view(); break;
954 case 'marc_edit' : set_marc_edit(); break;
955 case 'copy_browser' : set_copy_browser(); break;
956 case 'hold_browser' : set_hold_browser(); break;
957 case 'serctrl_view' : set_serctrl_view(); break;
959 default: set_opac(); break;
961 opac_wrapper_set_help_context();
963 g.error.standard_unexpected_error_alert('in refresh_display',E);
967 function set_default() {
968 var robj = g.network.simple_request(
970 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
972 if (typeof robj.ilsevent != 'undefined') {
973 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
977 function add_volumes() {
981 edit = g.network.request(
982 api.PERM_MULTI_ORG_CHECK.app,
983 api.PERM_MULTI_ORG_CHECK.method,
988 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
990 ).length == 0 ? 1 : 0;
992 g.error.sdump('D_ERROR','batch permission check: ' + E);
996 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
997 return; // no read-only view for this interface
1000 // Check if the source is allowed to have copies.
1002 var bibObj = g.network.request(
1003 api.FM_BRE_RETRIEVE_VIA_ID.app,
1004 api.FM_BRE_RETRIEVE_VIA_ID.method,
1010 var cbsObj = g.network.request(
1011 api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
1012 api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
1013 [ ses(), bibObj.source() ]
1016 if (cbsObj && cbsObj.can_have_copies() != get_db_true()) {
1017 alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()]));
1021 g.error.sdump('D_ERROR','can have copies check: ' + E);
1022 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
1026 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
1029 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
1030 if (unified_interface) {
1031 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
1032 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
1034 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
1037 var w = xulG.new_tab(
1039 { 'tab_name' : title },
1040 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ], 'reload_opac' : xulG.reload_opac }
1043 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
1047 function manage_parts() {
1049 g.view = 'manage_parts';
1050 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
1051 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
1053 if (manage_parts_reset) {
1054 bottom_pane.reset_iframe( loc,{},xulG);
1055 manage_parts_reset =false;
1057 bottom_pane.set_iframe( loc,{},xulG);
1059 opac_wrapper_set_help_context();
1060 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1062 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
1066 function manage_multi_home_items() {
1068 g.view = 'manage_multi_home';
1069 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
1070 if (manage_multi_home_reset) {
1071 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1072 manage_multi_home_reset =false;
1074 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
1076 opac_wrapper_set_help_context();
1077 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
1079 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
1083 function mark_for_multi_home() {
1084 g.data.marked_multi_home_record = docid;
1085 g.data.stash('marked_multi_home_record');
1086 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
1087 if (typeof robj.ilsevent == 'undefined') {
1088 g.data.marked_multi_home_record_mvr = robj;
1090 g.data.marked_multi_home_record_mvr = null;
1091 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
1093 g.data.stash('marked_multi_home_record_mvr');
1095 if (g.data.marked_multi_home_record_mvr) {
1096 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
1099 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
1100 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1101 gen_statusbar_click_handler('marked_multi_home_record')
1104 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
1107 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
1109 gen_statusbar_click_handler('marked_multi_home_record')
1114 function gen_statusbar_click_handler(data_key) {
1115 return function (ev) {
1117 if (! g.data[data_key]) {
1121 if (ev.button == 0 /* left click, spawn opac */) {
1122 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + g.data[data_key];
1123 var content_params = {
1125 'authtime' : ses('authtime'),
1126 'opac_url' : opac_url,
1129 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
1130 {'tab_name':'Retrieving title...'},
1135 if (ev.button == 2 /* right click, remove mark */) {
1136 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1137 g.data[data_key] = null;
1138 g.data.stash(data_key);
1139 ev.target.setAttribute('label','');
1140 if (ev.target.hasAttribute('tooltiptext')) {
1141 ev.target.removeAttribute('tooltiptext');