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());
219 JSAN.use('util.window'); var win = new util.window();
221 var unified_interface = String( data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
222 if (unified_interface) {
223 var horizontal_interface = String( data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
224 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
225 var w = xulG.set_tab(
228 'tab_name' : document.getElementById('offlineStrings').getFormattedString(
235 'existing_copies' : [ copy_obj ],
236 'load_opac_when_done' : true,
237 'labels_in_new_tab' : true
242 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
246 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);
249 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
251 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
255 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
256 'func' : function (new_marcxml) {
258 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
259 marc_view_reset = true;
260 copy_browser_reset = true;
261 hold_browser_reset = true;
262 if (typeof r.ilsevent != 'undefined') {
267 'oncomplete' : function() {}
271 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
275 'lock_tab' : xulG.lock_tab,
276 'unlock_tab' : xulG.unlock_tab
278 if (marc_edit_reset) {
279 bottom_pane.reset_iframe( a,b,c );
280 marc_edit_reset = false;
282 bottom_pane.set_iframe( a,b,c );
284 opac_wrapper_set_help_context();
285 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
288 function set_copy_browser() {
289 g.view = 'copy_browser';
290 if (copy_browser_reset) {
291 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
292 copy_browser_reset =false;
294 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
296 opac_wrapper_set_help_context();
297 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
300 function set_hold_browser() {
301 g.view = 'hold_browser';
302 if (hold_browser_reset) {
303 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
304 hold_browser_reset = false;
306 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
308 opac_wrapper_set_help_context();
309 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
313 function open_acq_orders() {
315 var content_params = {
317 "authtime": ses("authtime"),
319 "show_nav_buttons": true,
320 "show_print_button": false
323 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
324 "set_patron_tab", "volume_item_creator", "get_new_session",
325 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
326 "url_prefix", "network_meter", "page_meter", "set_statusbar",
327 "set_help_context", "get_barcode"
328 ].forEach(function(k) { content_params[k] = xulG[k]; });
330 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
331 xulG.url_prefix("/eg/acq/lineitem/related/") +
332 docid + "?target=bib"
336 "tab_name": $("offlineStrings").getString(
337 "staff.cat.opac.related_items"
343 g.error.sdump("D_ERROR", E);
347 function open_alt_serial_mgmt() {
349 var content_params = {
351 "authtime": ses("authtime"),
352 "show_nav_buttons": true,
354 "show_print_button": false
357 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
358 "set_patron_tab", "volume_item_creator", "get_new_session",
359 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
360 "url_prefix", "network_meter", "page_meter", "set_statusbar",
361 "set_help_context", "get_barcode"
362 ].forEach(function(k) { content_params[k] = xulG[k]; });
364 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
365 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
370 "tab_name": $("offlineStrings").getString(
371 "staff.cat.opac.serial_alt_mgmt"
377 g.error.sdump("D_ERROR", E);
381 function set_opac() {
384 var content_params = {
385 'show_nav_buttons' : true,
386 'show_print_button' : true,
387 'passthru_content_params' : {
389 'authtime' : ses('authtime'),
390 'window_open' : function(a,b,c) {
392 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
393 return window.open(a,b,c);
395 g.error.standard_unexpected_error_alert('window_open',E);
398 'get_barcode' : xulG.get_barcode
400 'on_url_load' : function(f) {
401 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
404 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
405 win = f.contentWindow.wrappedJSObject;
407 win = f.contentWindow;
410 win = f.contentWindow;
412 win.attachEvt("rdetail", "recordRetrieved",
415 if (docid == id) return;
419 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
424 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
425 $('record_start').disabled = true; $('record_next').disabled = true;
426 $('record_prev').disabled = true; $('record_end').disabled = true;
427 $('record_pos').setAttribute('value','');
429 win.attachEvt("rdetail", "nextPrevDrawn",
430 function(rIndex,rCount){
431 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
432 if (win.rdetailNext) {
433 g.f_record_next = function() {
434 g.view_override = g.view;
437 $('record_next').disabled = false;
439 if (win.rdetailPrev) {
440 g.f_record_prev = function() {
441 g.view_override = g.view;
444 $('record_prev').disabled = false;
446 if (win.rdetailStart) {
447 g.f_record_start = function() {
448 g.view_override = g.view;
451 $('record_start').disabled = false;
453 if (win.rdetailEnd) {
454 g.f_record_end = function() {
455 g.view_override = g.view;
458 $('record_end').disabled = false;
463 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
464 var mfhd_edit_menu = $('mfhd_edit');
465 var mfhd_delete_menu = $('mfhd_delete');
467 // clear menus on subsequent loads
468 if (mfhd_edit_menu.firstChild) {
469 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
470 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
473 mfhd_edit_menu.disabled = true;
474 mfhd_delete_menu.disabled = true;
476 win.attachEvt("rdetail", "MFHDDrawn",
478 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
480 g.mfhd.details = win.mfhdDetails;
481 mfhd_edit_menu.disabled = false;
482 mfhd_delete_menu.disabled = false;
483 for (var i = 0; i < win.mfhdDetails.length; i++) {
484 var mfhd_details = win.mfhdDetails[i];
485 var num = mfhd_details.entryNum;
487 var label = mfhd_details.label + ' (' + num + ')';
488 var item = mfhd_edit_menu.appendItem(label);
489 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
490 item = mfhd_delete_menu.appendItem(label);
491 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
493 var change_event = document.createEvent("Event");
494 change_event.initEvent("MFHDChange",false,false);
495 window.dispatchEvent(change_event);
500 'url_prefix' : xulG.url_prefix,
502 content_params.new_tab = xulG.new_tab;
503 content_params.set_tab = xulG.set_tab;
504 content_params.close_tab = xulG.close_tab;
505 content_params.lock_tab = xulG.lock_tab;
506 content_params.unlock_tab = xulG.unlock_tab;
507 content_params.inspect_tab = xulG.inspect_tab;
508 content_params.new_patron_tab = xulG.new_patron_tab;
509 content_params.set_patron_tab = xulG.set_patron_tab;
510 content_params.volume_item_creator = xulG.volume_item_creator;
511 content_params.get_new_session = xulG.get_new_session;
512 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
513 content_params.set_tab_name = xulG.set_tab_name;
514 content_params.open_chrome_window = xulG.open_chrome_window;
515 content_params.url_prefix = xulG.url_prefix;
516 content_params.network_meter = xulG.network_meter;
517 content_params.page_meter = xulG.page_meter;
518 content_params.set_statusbar = xulG.set_statusbar;
519 content_params.set_help_context = xulG.set_help_context;
520 content_params.get_barcode = xulG.get_barcode;
522 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
523 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
524 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
525 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
528 g.error.sdump('D_ERROR','set_opac: ' + E);
530 opac_wrapper_set_help_context();
531 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
534 function set_serctrl_view() {
535 g.view = 'serctrl_view';
536 if (serctrl_view_reset) {
537 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
538 serctrl_view_reset =false;
540 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
544 function create_mfhd() {
546 JSAN.use('util.window'); var win = new util.window();
547 var select_aou_window = win.open(
548 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
550 'chrome,resizable,modal,centerscreen',
551 {'server_unadorned' : g.data.server_unadorned}
553 if (!select_aou_window.create_mfhd_aou) {
556 var r = g.network.simple_request(
557 'MFHD_XML_RECORD_CREATE',
558 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
560 if (typeof r.ilsevent != 'undefined') {
563 alert("MFHD record created."); //TODO: better success message
564 browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
566 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
570 function delete_mfhd(sre_id) {
571 if (g.error.yns_alert(
572 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
573 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
574 document.getElementById('offlineStrings').getString('cat.opac.delete'),
575 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
577 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
578 var robj = g.network.request(
579 'open-ils.permacrud',
580 'open-ils.permacrud.delete.sre',
582 if (typeof robj.ilsevent != 'undefined') {
583 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
585 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
586 browser_frame.contentWindow.g.browser.controller.view.cmd_reload.doCommand();
591 function open_mfhd_editor(sre_id) {
593 var r = g.network.simple_request(
597 if (typeof r.ilsevent != 'undefined') {
600 open_marc_editor(r, 'MFHD');
602 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
606 function open_marc_editor(rec, label) {
607 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
610 record : {marc : rec.marc()},
612 label: 'Save ' + label,
613 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
614 var method = 'open-ils.permacrud.update.' + rec.classname;
617 'open-ils.permacrud', method,
625 function bib_in_new_tab() {
627 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
628 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
629 content_params.url_prefix = xulG.url_prefix;
630 content_params.new_tab = xulG.new_tab;
631 content_params.set_tab = xulG.set_tab;
632 content_params.close_tab = xulG.close_tab;
633 content_params.lock_tab = xulG.lock_tab;
634 content_params.unlock_tab = xulG.unlock_tab;
635 content_params.inspect_tab = xulG.inspect_tab;
636 content_params.new_patron_tab = xulG.new_patron_tab;
637 content_params.set_patron_tab = xulG.set_patron_tab;
638 content_params.volume_item_creator = xulG.volume_item_creator;
639 content_params.get_new_session = xulG.get_new_session;
640 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
641 content_params.set_tab_name = xulG.set_tab_name;
642 content_params.open_chrome_window = xulG.open_chrome_window;
643 content_params.url_prefix = xulG.url_prefix;
644 content_params.network_meter = xulG.network_meter;
645 content_params.page_meter = xulG.page_meter;
646 content_params.set_statusbar = xulG.set_statusbar;
647 content_params.set_help_context = xulG.set_help_context;
648 content_params.get_barcode = xulG.get_barcode;
650 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
652 g.error.sdump('D_ERROR',E);
656 function batch_receive_in_new_tab() {
658 var content_params = {"session": ses(), "authtime": ses("authtime")};
660 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
661 "set_patron_tab", "volume_item_creator", "get_new_session",
662 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
663 "url_prefix", "network_meter", "page_meter", "set_statusbar",
664 "set_help_context", "get_barcode"
665 ].forEach(function(k) { content_params[k] = xulG[k]; });
668 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
669 "?docid=" + window.escape(docid), {
670 "tab_name": $("offlineStrings").getString(
671 "menu.cmd_serial_batch_receive.tab"
676 g.error.sdump("D_ERROR", E);
680 function remove_me() {
681 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
682 dump('removing ' + url + '\n');
683 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
684 $('nav').setAttribute('hidden','true');
687 function add_to_bucket() {
688 JSAN.use('util.window'); var win = new util.window();
690 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
692 'chrome,resizable,modal,centerscreen',
694 record_ids: [ docid ]
699 function mark_for_overlay() {
700 g.data.marked_record = docid;
701 g.data.stash('marked_record');
702 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
703 if (typeof robj.ilsevent == 'undefined') {
704 g.data.marked_record_mvr = robj;
706 g.data.marked_record_mvr = null;
707 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
709 g.data.stash('marked_record_mvr');
710 if (g.data.marked_record_mvr) {
711 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
714 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
715 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
716 gen_statusbar_click_handler('marked_record')
719 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
722 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
724 gen_statusbar_click_handler('marked_record')
729 function mark_for_hold_transfer() {
730 g.data.marked_record_for_hold_transfer = docid;
731 g.data.stash('marked_record_for_hold_transfer');
732 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
733 if (typeof robj.ilsevent == 'undefined') {
734 g.data.marked_record_for_hold_transfer_mvr = robj;
736 g.data.marked_record_for_hold_transfer_mvr = null;
737 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
739 g.data.stash('marked_record_for_hold_transfer_mvr');
740 if (g.data.marked_record_mvr) {
741 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
747 gen_statusbar_click_handler('marked_record_for_hold_transfer')
750 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
756 gen_statusbar_click_handler('marked_record_for_hold_transfer')
761 function transfer_title_holds() {
762 g.data.stash_retrieve();
763 var target = g.data.marked_record_for_hold_transfer;
765 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
769 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
771 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
774 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
777 hold_browser_reset = true;
778 if (g.view == 'hold_browser') { set_hold_browser(); };
781 function delete_record() {
782 if (g.error.yns_alert(
783 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
784 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
785 document.getElementById('offlineStrings').getString('cat.opac.delete'),
786 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
788 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
789 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
790 if (typeof robj.ilsevent != 'undefined') {
791 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
793 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
794 refresh_display(docid);
799 function undelete_record() {
800 if (g.error.yns_alert(
801 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
802 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
803 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
804 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
806 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
808 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
809 if (typeof robj.ilsevent != 'undefined') {
810 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
812 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
813 refresh_display(docid);
818 function refresh_display(id) {
820 marc_view_reset = true;
821 marc_edit_reset = true;
822 copy_browser_reset = true;
823 hold_browser_reset = true;
824 manage_parts_reset = true;
825 manage_multi_home_reset = true;
826 serctrl_view_reset = true;
827 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
828 var children = bottom_pane.node.childNodes;
829 for (var i = 0; i < children.length; i++) {
830 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
834 $('nav').setAttribute('hidden','false');
835 var settings = g.network.simple_request(
837 [ ses(), g.data.list.au[0].id() ]
839 var view = settings['staff_client.catalog.record_view.default'];
840 if (g.view_override) {
841 view = g.view_override;
842 g.view_override = null;
845 case 'marc_view' : set_marc_view(); break;
846 case 'marc_edit' : set_marc_edit(); break;
847 case 'copy_browser' : set_copy_browser(); break;
848 case 'hold_browser' : set_hold_browser(); break;
849 case 'serctrl_view' : set_serctrl_view(); break;
851 default: set_opac(); break;
853 opac_wrapper_set_help_context();
855 g.error.standard_unexpected_error_alert('in refresh_display',E);
859 function set_default() {
860 var robj = g.network.simple_request(
862 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
864 if (typeof robj.ilsevent != 'undefined') {
865 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
869 function add_volumes() {
873 edit = g.network.request(
874 api.PERM_MULTI_ORG_CHECK.app,
875 api.PERM_MULTI_ORG_CHECK.method,
880 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
882 ).length == 0 ? 1 : 0;
884 g.error.sdump('D_ERROR','batch permission check: ' + E);
888 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
889 return; // no read-only view for this interface
892 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
895 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
896 if (unified_interface) {
897 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
898 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
900 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
903 var w = xulG.new_tab(
905 { 'tab_name' : title },
906 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
909 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
913 function manage_parts() {
915 g.view = 'manage_parts';
916 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
917 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
919 if (manage_parts_reset) {
920 bottom_pane.reset_iframe( loc,{},xulG);
921 manage_parts_reset =false;
923 bottom_pane.set_iframe( loc,{},xulG);
925 opac_wrapper_set_help_context();
926 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
928 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
932 function manage_multi_home_items() {
934 g.view = 'manage_multi_home';
935 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
936 if (manage_multi_home_reset) {
937 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
938 manage_multi_home_reset =false;
940 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
942 opac_wrapper_set_help_context();
943 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
945 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
949 function mark_for_multi_home() {
950 g.data.marked_multi_home_record = docid;
951 g.data.stash('marked_multi_home_record');
952 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
953 if (typeof robj.ilsevent == 'undefined') {
954 g.data.marked_multi_home_record_mvr = robj;
956 g.data.marked_multi_home_record_mvr = null;
957 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
959 g.data.stash('marked_multi_home_record_mvr');
961 if (g.data.marked_multi_home_record_mvr) {
962 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
965 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
966 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
967 gen_statusbar_click_handler('marked_multi_home_record')
970 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
973 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
975 gen_statusbar_click_handler('marked_multi_home_record')
980 function gen_statusbar_click_handler(data_key) {
981 return function (ev) {
983 if (! g.data[data_key]) {
987 if (ev.button == 0 /* left click, spawn opac */) {
988 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + g.data[data_key];
989 var content_params = {
991 'authtime' : ses('authtime'),
992 'opac_url' : opac_url,
995 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
996 {'tab_name':'Retrieving title...'},
1001 if (ev.button == 2 /* right click, remove mark */) {
1002 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1003 g.data[data_key] = null;
1004 g.data.stash(data_key);
1005 ev.target.setAttribute('label','');
1006 if (ev.target.hasAttribute('tooltiptext')) {
1007 ev.target.removeAttribute('tooltiptext');