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"
109 ].forEach(function(k) { content_params[k] = xulG[k]; });
118 function set_marc_view() {
119 g.view = 'marc_view';
120 if (marc_view_reset) {
121 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
122 marc_view_reset = false;
124 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
126 opac_wrapper_set_help_context();
127 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
130 function set_marc_edit() {
131 g.view = 'marc_edit';
132 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
135 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
136 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
137 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
139 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
140 cat.util.spawn_copy_editor = function(params) {
142 if (!params.copy_ids && !params.copies) return;
143 if (params.copy_ids && params.copy_ids.length == 0) return;
144 if (params.copies && params.copies.length == 0) return;
145 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
146 if (!params.caller_handles_update) params.handle_update = 1; // legacy
149 JSAN.use('util.network'); obj.network = new util.network();
150 JSAN.use('util.error'); obj.error = new util.error();
153 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
154 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
155 else if(params.copies && params.copies.length > 1 && params.edit == 1)
156 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
157 else if(params.copy_ids && params.copy_ids.length == 1)
158 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
160 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
162 JSAN.use('util.window'); var win = new util.window();
163 var my_xulG = win.open(
164 (urls.XUL_COPY_EDITOR),
166 'chrome,modal,resizable',
169 if (!my_xulG.copies && params.edit) {
171 return my_xulG.copies;
175 JSAN.use('util.error'); var error = new util.error();
176 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
179 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
183 JSAN.use('util.error'); error = new util.error();
184 JSAN.use('util.network'); var network = new util.network();
186 var acn_blob = network.simple_request(
187 'FM_ACN_FIND_OR_CREATE',
188 [ ses(), cn_label, doc_id, ses('ws_ou') ]
191 if (typeof acn_blob.ilsevent != 'undefined') {
192 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
196 var copy_obj = new acp();
199 copy_obj.barcode( cp_barcode );
200 copy_obj.call_number( acn_blob.acn_id );
201 copy_obj.circ_lib( ses('ws_ou') );
202 /* FIXME -- use constants */
205 copy_obj.deposit_amount(0);
206 copy_obj.fine_level(2); // Normal
207 copy_obj.loan_duration(2); // Normal
208 copy_obj.location(1); // Stacks
209 copy_obj.status(5); // In Process
210 copy_obj.circulate(get_db_true());
211 copy_obj.holdable(get_db_true());
212 copy_obj.opac_visible(get_db_true());
213 copy_obj.ref(get_db_false());
215 JSAN.use('util.window'); var win = new util.window();
216 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
219 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);
222 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
224 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
228 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
229 'func' : function (new_marcxml) {
231 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
232 marc_view_reset = true;
233 copy_browser_reset = true;
234 hold_browser_reset = true;
235 if (typeof r.ilsevent != 'undefined') {
240 'oncomplete' : function() {}
244 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
248 'lock_tab' : xulG.lock_tab,
249 'unlock_tab' : xulG.unlock_tab
251 if (marc_edit_reset) {
252 bottom_pane.reset_iframe( a,b,c );
253 marc_edit_reset = false;
255 bottom_pane.set_iframe( a,b,c );
257 opac_wrapper_set_help_context();
258 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
261 function set_copy_browser() {
262 g.view = 'copy_browser';
263 if (copy_browser_reset) {
264 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
265 copy_browser_reset =false;
267 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
269 opac_wrapper_set_help_context();
270 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
273 function set_hold_browser() {
274 g.view = 'hold_browser';
275 if (hold_browser_reset) {
276 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
277 hold_browser_reset = false;
279 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
281 opac_wrapper_set_help_context();
282 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
286 function open_acq_orders() {
288 var content_params = {
290 "authtime": ses("authtime"),
292 "show_nav_buttons": true,
293 "show_print_button": false
296 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
297 "set_patron_tab", "volume_item_creator", "get_new_session",
298 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
299 "url_prefix", "network_meter", "page_meter", "set_statusbar",
301 ].forEach(function(k) { content_params[k] = xulG[k]; });
303 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
304 xulG.url_prefix("/eg/acq/lineitem/related/") +
305 docid + "?target=bib"
309 "tab_name": $("offlineStrings").getString(
310 "staff.cat.opac.related_items"
316 g.error.sdump("D_ERROR", E);
320 function open_alt_serial_mgmt() {
322 var content_params = {
324 "authtime": ses("authtime"),
325 "show_nav_buttons": true,
327 "show_print_button": false
330 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
331 "set_patron_tab", "volume_item_creator", "get_new_session",
332 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
333 "url_prefix", "network_meter", "page_meter", "set_statusbar",
335 ].forEach(function(k) { content_params[k] = xulG[k]; });
337 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
338 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
343 "tab_name": $("offlineStrings").getString(
344 "staff.cat.opac.serial_alt_mgmt"
350 g.error.sdump("D_ERROR", E);
354 function set_opac() {
357 var content_params = {
358 'show_nav_buttons' : true,
359 'show_print_button' : true,
360 'passthru_content_params' : {
362 'authtime' : ses('authtime'),
363 'window_open' : function(a,b,c) {
365 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
366 return window.open(a,b,c);
368 g.error.standard_unexpected_error_alert('window_open',E);
372 'on_url_load' : function(f) {
373 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
376 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
377 win = f.contentWindow.wrappedJSObject;
379 win = f.contentWindow;
382 win = f.contentWindow;
384 win.attachEvt("rdetail", "recordRetrieved",
387 if (docid == id) return;
391 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
396 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
397 $('record_start').disabled = true; $('record_next').disabled = true;
398 $('record_prev').disabled = true; $('record_end').disabled = true;
399 $('record_pos').setAttribute('value','');
401 win.attachEvt("rdetail", "nextPrevDrawn",
402 function(rIndex,rCount){
403 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
404 if (win.rdetailNext) {
405 g.f_record_next = function() {
406 g.view_override = g.view;
409 $('record_next').disabled = false;
411 if (win.rdetailPrev) {
412 g.f_record_prev = function() {
413 g.view_override = g.view;
416 $('record_prev').disabled = false;
418 if (win.rdetailStart) {
419 g.f_record_start = function() {
420 g.view_override = g.view;
423 $('record_start').disabled = false;
425 if (win.rdetailEnd) {
426 g.f_record_end = function() {
427 g.view_override = g.view;
430 $('record_end').disabled = false;
435 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
436 var mfhd_edit_menu = $('mfhd_edit');
437 var mfhd_delete_menu = $('mfhd_delete');
439 // clear menus on subsequent loads
440 if (mfhd_edit_menu.firstChild) {
441 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
442 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
445 mfhd_edit_menu.disabled = true;
446 mfhd_delete_menu.disabled = true;
448 win.attachEvt("rdetail", "MFHDDrawn",
450 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
452 g.mfhd.details = win.mfhdDetails;
453 mfhd_edit_menu.disabled = false;
454 mfhd_delete_menu.disabled = false;
455 for (var i = 0; i < win.mfhdDetails.length; i++) {
456 var mfhd_details = win.mfhdDetails[i];
457 var num = mfhd_details.entryNum;
459 var label = mfhd_details.label + ' (' + num + ')';
460 var item = mfhd_edit_menu.appendItem(label);
461 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
462 item = mfhd_delete_menu.appendItem(label);
463 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
469 'url_prefix' : xulG.url_prefix,
471 content_params.new_tab = xulG.new_tab;
472 content_params.set_tab = xulG.set_tab;
473 content_params.close_tab = xulG.close_tab;
474 content_params.lock_tab = xulG.lock_tab;
475 content_params.unlock_tab = xulG.unlock_tab;
476 content_params.inspect_tab = xulG.inspect_tab;
477 content_params.new_patron_tab = xulG.new_patron_tab;
478 content_params.set_patron_tab = xulG.set_patron_tab;
479 content_params.volume_item_creator = xulG.volume_item_creator;
480 content_params.get_new_session = xulG.get_new_session;
481 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
482 content_params.set_tab_name = xulG.set_tab_name;
483 content_params.open_chrome_window = xulG.open_chrome_window;
484 content_params.url_prefix = xulG.url_prefix;
485 content_params.network_meter = xulG.network_meter;
486 content_params.page_meter = xulG.page_meter;
487 content_params.set_statusbar = xulG.set_statusbar;
488 content_params.set_help_context = xulG.set_help_context;
490 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
491 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
492 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
493 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
496 g.error.sdump('D_ERROR','set_opac: ' + E);
498 opac_wrapper_set_help_context();
499 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
502 function set_serctrl_view() {
503 g.view = 'serctrl_view';
504 if (serctrl_view_reset) {
505 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
506 serctrl_view_reset =false;
508 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
512 function create_mfhd() {
514 JSAN.use('util.window'); var win = new util.window();
515 var select_aou_window = win.open(
516 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
518 'chrome,resizable,modal,centerscreen',
519 {'server_unadorned' : g.data.server_unadorned}
521 if (!select_aou_window.create_mfhd_aou) {
524 var r = g.network.simple_request(
525 'MFHD_XML_RECORD_CREATE',
526 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
528 if (typeof r.ilsevent != 'undefined') {
531 alert("MFHD record created."); //TODO: better success message
532 //TODO: refresh opac display
534 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
538 function delete_mfhd(sre_id) {
539 if (g.error.yns_alert(
540 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
541 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
542 document.getElementById('offlineStrings').getString('cat.opac.delete'),
543 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
545 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
546 var robj = g.network.request(
547 'open-ils.permacrud',
548 'open-ils.permacrud.delete.sre',
550 if (typeof robj.ilsevent != 'undefined') {
551 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
553 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
554 //TODO: refresh opac display
559 function open_mfhd_editor(sre_id) {
561 var r = g.network.simple_request(
565 if (typeof r.ilsevent != 'undefined') {
568 open_marc_editor(r, 'MFHD');
570 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
574 function open_marc_editor(rec, label) {
575 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
578 record : {marc : rec.marc()},
580 label: 'Save ' + label,
581 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
582 var method = 'open-ils.permacrud.update.' + rec.classname;
585 'open-ils.permacrud', method,
593 function bib_in_new_tab() {
595 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
596 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
597 content_params.url_prefix = xulG.url_prefix;
598 content_params.new_tab = xulG.new_tab;
599 content_params.set_tab = xulG.set_tab;
600 content_params.close_tab = xulG.close_tab;
601 content_params.lock_tab = xulG.lock_tab;
602 content_params.unlock_tab = xulG.unlock_tab;
603 content_params.inspect_tab = xulG.inspect_tab;
604 content_params.new_patron_tab = xulG.new_patron_tab;
605 content_params.set_patron_tab = xulG.set_patron_tab;
606 content_params.volume_item_creator = xulG.volume_item_creator;
607 content_params.get_new_session = xulG.get_new_session;
608 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
609 content_params.set_tab_name = xulG.set_tab_name;
610 content_params.open_chrome_window = xulG.open_chrome_window;
611 content_params.url_prefix = xulG.url_prefix;
612 content_params.network_meter = xulG.network_meter;
613 content_params.page_meter = xulG.page_meter;
614 content_params.set_statusbar = xulG.set_statusbar;
615 content_params.set_help_context = xulG.set_help_context;
617 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
619 g.error.sdump('D_ERROR',E);
623 function batch_receive_in_new_tab() {
625 var content_params = {"session": ses(), "authtime": ses("authtime")};
627 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
628 "set_patron_tab", "volume_item_creator", "get_new_session",
629 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
630 "url_prefix", "network_meter", "page_meter", "set_statusbar",
632 ].forEach(function(k) { content_params[k] = xulG[k]; });
635 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
636 "?docid=" + window.escape(docid), {
637 "tab_name": $("offlineStrings").getString(
638 "menu.cmd_serial_batch_receive.tab"
643 g.error.sdump("D_ERROR", E);
647 function remove_me() {
648 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
649 dump('removing ' + url + '\n');
650 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
651 $('nav').setAttribute('hidden','true');
654 function add_to_bucket() {
655 JSAN.use('util.window'); var win = new util.window();
657 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
659 'chrome,resizable,modal,centerscreen',
661 record_ids: [ docid ]
666 function mark_for_overlay() {
667 g.data.marked_record = docid;
668 g.data.stash('marked_record');
669 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
670 if (typeof robj.ilsevent == 'undefined') {
671 g.data.marked_record_mvr = robj;
673 g.data.marked_record_mvr = null;
674 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
676 g.data.stash('marked_record_mvr');
677 if (g.data.marked_record_mvr) {
678 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
681 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
682 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
683 gen_statusbar_click_handler('marked_record')
686 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
689 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
691 gen_statusbar_click_handler('marked_record')
696 function mark_for_hold_transfer() {
697 g.data.marked_record_for_hold_transfer = docid;
698 g.data.stash('marked_record_for_hold_transfer');
699 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
700 if (typeof robj.ilsevent == 'undefined') {
701 g.data.marked_record_for_hold_transfer_mvr = robj;
703 g.data.marked_record_for_hold_transfer_mvr = null;
704 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
706 g.data.stash('marked_record_for_hold_transfer_mvr');
707 if (g.data.marked_record_mvr) {
708 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
714 gen_statusbar_click_handler('marked_record_for_hold_transfer')
717 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
723 gen_statusbar_click_handler('marked_record_for_hold_transfer')
728 function transfer_title_holds() {
729 g.data.stash_retrieve();
730 var target = g.data.marked_record_for_hold_transfer;
732 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
736 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
738 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
741 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
744 hold_browser_reset = true;
745 if (g.view == 'hold_browser') { set_hold_browser(); };
748 function delete_record() {
749 if (g.error.yns_alert(
750 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
751 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
752 document.getElementById('offlineStrings').getString('cat.opac.delete'),
753 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
755 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
756 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
757 if (typeof robj.ilsevent != 'undefined') {
758 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
760 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
761 refresh_display(docid);
766 function undelete_record() {
767 if (g.error.yns_alert(
768 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
769 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
770 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
771 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
773 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
775 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
776 if (typeof robj.ilsevent != 'undefined') {
777 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
779 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
780 refresh_display(docid);
785 function refresh_display(id) {
787 marc_view_reset = true;
788 marc_edit_reset = true;
789 copy_browser_reset = true;
790 hold_browser_reset = true;
791 manage_parts_reset = true;
792 manage_multi_home_reset = true;
793 serctrl_view_reset = true;
794 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
795 var children = bottom_pane.node.childNodes;
796 for (var i = 0; i < children.length; i++) {
797 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
801 $('nav').setAttribute('hidden','false');
802 var settings = g.network.simple_request(
804 [ ses(), g.data.list.au[0].id() ]
806 var view = settings['staff_client.catalog.record_view.default'];
807 if (g.view_override) {
808 view = g.view_override;
809 g.view_override = null;
812 case 'marc_view' : set_marc_view(); break;
813 case 'marc_edit' : set_marc_edit(); break;
814 case 'copy_browser' : set_copy_browser(); break;
815 case 'hold_browser' : set_hold_browser(); break;
816 case 'serctrl_view' : set_serctrl_view(); break;
818 default: set_opac(); break;
820 opac_wrapper_set_help_context();
822 g.error.standard_unexpected_error_alert('in refresh_display',E);
826 function set_default() {
827 var robj = g.network.simple_request(
829 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
831 if (typeof robj.ilsevent != 'undefined') {
832 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
836 function add_volumes() {
840 edit = g.network.request(
841 api.PERM_MULTI_ORG_CHECK.app,
842 api.PERM_MULTI_ORG_CHECK.method,
847 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
849 ).length == 0 ? 1 : 0;
851 g.error.sdump('D_ERROR','batch permission check: ' + E);
855 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
856 return; // no read-only view for this interface
859 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
861 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
862 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
863 var w = xulG.new_tab(
865 { 'tab_name' : title },
866 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
869 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
873 function manage_parts() {
875 g.view = 'manage_parts';
876 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
877 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
879 if (manage_parts_reset) {
880 bottom_pane.reset_iframe( loc,{},xulG);
881 manage_parts_reset =false;
883 bottom_pane.set_iframe( loc,{},xulG);
885 opac_wrapper_set_help_context();
886 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
888 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
892 function manage_multi_home_items() {
894 g.view = 'manage_multi_home';
895 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
896 if (manage_multi_home_reset) {
897 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
898 manage_multi_home_reset =false;
900 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
902 opac_wrapper_set_help_context();
903 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
905 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
909 function mark_for_multi_home() {
910 g.data.marked_multi_home_record = docid;
911 g.data.stash('marked_multi_home_record');
912 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
913 if (typeof robj.ilsevent == 'undefined') {
914 g.data.marked_multi_home_record_mvr = robj;
916 g.data.marked_multi_home_record_mvr = null;
917 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
919 g.data.stash('marked_multi_home_record_mvr');
921 if (g.data.marked_multi_home_record_mvr) {
922 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
925 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
926 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
927 gen_statusbar_click_handler('marked_multi_home_record')
930 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
933 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
935 gen_statusbar_click_handler('marked_multi_home_record')
940 function gen_statusbar_click_handler(data_key) {
941 return function (ev) {
943 if (! g.data[data_key]) {
947 if (ev.button == 0 /* left click, spawn opac */) {
948 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + g.data[data_key];
949 var content_params = {
951 'authtime' : ses('authtime'),
952 'opac_url' : opac_url,
955 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
956 {'tab_name':'Retrieving title...'},
961 if (ev.button == 2 /* right click, remove mark */) {
962 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
963 g.data[data_key] = null;
964 g.data.stash(data_key);
965 ev.target.setAttribute('label','');
966 if (ev.target.hasAttribute('tooltiptext')) {
967 ev.target.removeAttribute('tooltiptext');