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 // Get the default copy status; default to available if unset, per 1.6
197 var fast_ccs = g.data.hash.aous['cat.default_copy_status_fast'] || 0;
199 var copy_obj = new acp();
202 copy_obj.barcode( cp_barcode );
203 copy_obj.call_number( acn_blob.acn_id );
204 copy_obj.circ_lib( ses('ws_ou') );
205 /* FIXME -- use constants */
208 copy_obj.deposit_amount(0);
209 copy_obj.fine_level(2); // Normal
210 copy_obj.loan_duration(2); // Normal
211 copy_obj.location(1); // Stacks
212 copy_obj.status(fast_ccs);
213 copy_obj.circulate(get_db_true());
214 copy_obj.holdable(get_db_true());
215 copy_obj.opac_visible(get_db_true());
216 copy_obj.ref(get_db_false());
218 JSAN.use('util.window'); var win = new util.window();
219 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
222 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);
225 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
227 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
231 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
232 'func' : function (new_marcxml) {
234 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
235 marc_view_reset = true;
236 copy_browser_reset = true;
237 hold_browser_reset = true;
238 if (typeof r.ilsevent != 'undefined') {
243 'oncomplete' : function() {}
247 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
251 'lock_tab' : xulG.lock_tab,
252 'unlock_tab' : xulG.unlock_tab
254 if (marc_edit_reset) {
255 bottom_pane.reset_iframe( a,b,c );
256 marc_edit_reset = false;
258 bottom_pane.set_iframe( a,b,c );
260 opac_wrapper_set_help_context();
261 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
264 function set_copy_browser() {
265 g.view = 'copy_browser';
266 if (copy_browser_reset) {
267 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
268 copy_browser_reset =false;
270 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
272 opac_wrapper_set_help_context();
273 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
276 function set_hold_browser() {
277 g.view = 'hold_browser';
278 if (hold_browser_reset) {
279 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
280 hold_browser_reset = false;
282 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
284 opac_wrapper_set_help_context();
285 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
289 function open_acq_orders() {
291 var content_params = {
293 "authtime": ses("authtime"),
295 "show_nav_buttons": true,
296 "show_print_button": false
299 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
300 "set_patron_tab", "volume_item_creator", "get_new_session",
301 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
302 "url_prefix", "network_meter", "page_meter", "set_statusbar",
304 ].forEach(function(k) { content_params[k] = xulG[k]; });
306 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
307 xulG.url_prefix("/eg/acq/lineitem/related/") +
308 docid + "?target=bib"
312 "tab_name": $("offlineStrings").getString(
313 "staff.cat.opac.related_items"
319 g.error.sdump("D_ERROR", E);
323 function open_alt_serial_mgmt() {
325 var content_params = {
327 "authtime": ses("authtime"),
328 "show_nav_buttons": true,
330 "show_print_button": false
333 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
334 "set_patron_tab", "volume_item_creator", "get_new_session",
335 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
336 "url_prefix", "network_meter", "page_meter", "set_statusbar",
338 ].forEach(function(k) { content_params[k] = xulG[k]; });
340 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
341 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
346 "tab_name": $("offlineStrings").getString(
347 "staff.cat.opac.serial_alt_mgmt"
353 g.error.sdump("D_ERROR", E);
357 function set_opac() {
360 var content_params = {
361 'show_nav_buttons' : true,
362 'show_print_button' : true,
363 'passthru_content_params' : {
365 'authtime' : ses('authtime'),
366 'window_open' : function(a,b,c) {
368 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
369 return window.open(a,b,c);
371 g.error.standard_unexpected_error_alert('window_open',E);
375 'on_url_load' : function(f) {
376 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
379 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
380 win = f.contentWindow.wrappedJSObject;
382 win = f.contentWindow;
385 win = f.contentWindow;
387 win.attachEvt("rdetail", "recordRetrieved",
390 if (docid == id) return;
394 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
399 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
400 $('record_start').disabled = true; $('record_next').disabled = true;
401 $('record_prev').disabled = true; $('record_end').disabled = true;
402 $('record_pos').setAttribute('value','');
404 win.attachEvt("rdetail", "nextPrevDrawn",
405 function(rIndex,rCount){
406 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
407 if (win.rdetailNext) {
408 g.f_record_next = function() {
409 g.view_override = g.view;
412 $('record_next').disabled = false;
414 if (win.rdetailPrev) {
415 g.f_record_prev = function() {
416 g.view_override = g.view;
419 $('record_prev').disabled = false;
421 if (win.rdetailStart) {
422 g.f_record_start = function() {
423 g.view_override = g.view;
426 $('record_start').disabled = false;
428 if (win.rdetailEnd) {
429 g.f_record_end = function() {
430 g.view_override = g.view;
433 $('record_end').disabled = false;
438 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
439 var mfhd_edit_menu = $('mfhd_edit');
440 var mfhd_delete_menu = $('mfhd_delete');
442 // clear menus on subsequent loads
443 if (mfhd_edit_menu.firstChild) {
444 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
445 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
448 mfhd_edit_menu.disabled = true;
449 mfhd_delete_menu.disabled = true;
451 win.attachEvt("rdetail", "MFHDDrawn",
453 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
455 g.mfhd.details = win.mfhdDetails;
456 mfhd_edit_menu.disabled = false;
457 mfhd_delete_menu.disabled = false;
458 for (var i = 0; i < win.mfhdDetails.length; i++) {
459 var mfhd_details = win.mfhdDetails[i];
460 var num = mfhd_details.entryNum;
462 var label = mfhd_details.label + ' (' + num + ')';
463 var item = mfhd_edit_menu.appendItem(label);
464 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
465 item = mfhd_delete_menu.appendItem(label);
466 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
472 'url_prefix' : xulG.url_prefix,
474 content_params.new_tab = xulG.new_tab;
475 content_params.set_tab = xulG.set_tab;
476 content_params.close_tab = xulG.close_tab;
477 content_params.lock_tab = xulG.lock_tab;
478 content_params.unlock_tab = xulG.unlock_tab;
479 content_params.inspect_tab = xulG.inspect_tab;
480 content_params.new_patron_tab = xulG.new_patron_tab;
481 content_params.set_patron_tab = xulG.set_patron_tab;
482 content_params.volume_item_creator = xulG.volume_item_creator;
483 content_params.get_new_session = xulG.get_new_session;
484 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
485 content_params.set_tab_name = xulG.set_tab_name;
486 content_params.open_chrome_window = xulG.open_chrome_window;
487 content_params.url_prefix = xulG.url_prefix;
488 content_params.network_meter = xulG.network_meter;
489 content_params.page_meter = xulG.page_meter;
490 content_params.set_statusbar = xulG.set_statusbar;
491 content_params.set_help_context = xulG.set_help_context;
493 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
494 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
495 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
496 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
499 g.error.sdump('D_ERROR','set_opac: ' + E);
501 opac_wrapper_set_help_context();
502 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
505 function set_serctrl_view() {
506 g.view = 'serctrl_view';
507 if (serctrl_view_reset) {
508 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
509 serctrl_view_reset =false;
511 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
515 function create_mfhd() {
517 JSAN.use('util.window'); var win = new util.window();
518 var select_aou_window = win.open(
519 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
521 'chrome,resizable,modal,centerscreen',
522 {'server_unadorned' : g.data.server_unadorned}
524 if (!select_aou_window.create_mfhd_aou) {
527 var r = g.network.simple_request(
528 'MFHD_XML_RECORD_CREATE',
529 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
531 if (typeof r.ilsevent != 'undefined') {
534 alert("MFHD record created."); //TODO: better success message
535 //TODO: refresh opac display
537 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
541 function delete_mfhd(sre_id) {
542 if (g.error.yns_alert(
543 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
544 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
545 document.getElementById('offlineStrings').getString('cat.opac.delete'),
546 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
548 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
549 var robj = g.network.request(
550 'open-ils.permacrud',
551 'open-ils.permacrud.delete.sre',
553 if (typeof robj.ilsevent != 'undefined') {
554 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
556 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
557 //TODO: refresh opac display
562 function open_mfhd_editor(sre_id) {
564 var r = g.network.simple_request(
568 if (typeof r.ilsevent != 'undefined') {
571 open_marc_editor(r, 'MFHD');
573 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
577 function open_marc_editor(rec, label) {
578 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
581 record : {marc : rec.marc()},
583 label: 'Save ' + label,
584 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
585 var method = 'open-ils.permacrud.update.' + rec.classname;
588 'open-ils.permacrud', method,
596 function bib_in_new_tab() {
598 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
599 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
600 content_params.url_prefix = xulG.url_prefix;
601 content_params.new_tab = xulG.new_tab;
602 content_params.set_tab = xulG.set_tab;
603 content_params.close_tab = xulG.close_tab;
604 content_params.lock_tab = xulG.lock_tab;
605 content_params.unlock_tab = xulG.unlock_tab;
606 content_params.inspect_tab = xulG.inspect_tab;
607 content_params.new_patron_tab = xulG.new_patron_tab;
608 content_params.set_patron_tab = xulG.set_patron_tab;
609 content_params.volume_item_creator = xulG.volume_item_creator;
610 content_params.get_new_session = xulG.get_new_session;
611 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
612 content_params.set_tab_name = xulG.set_tab_name;
613 content_params.open_chrome_window = xulG.open_chrome_window;
614 content_params.url_prefix = xulG.url_prefix;
615 content_params.network_meter = xulG.network_meter;
616 content_params.page_meter = xulG.page_meter;
617 content_params.set_statusbar = xulG.set_statusbar;
618 content_params.set_help_context = xulG.set_help_context;
620 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
622 g.error.sdump('D_ERROR',E);
626 function batch_receive_in_new_tab() {
628 var content_params = {"session": ses(), "authtime": ses("authtime")};
630 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
631 "set_patron_tab", "volume_item_creator", "get_new_session",
632 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
633 "url_prefix", "network_meter", "page_meter", "set_statusbar",
635 ].forEach(function(k) { content_params[k] = xulG[k]; });
638 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
639 "?docid=" + window.escape(docid), {
640 "tab_name": $("offlineStrings").getString(
641 "menu.cmd_serial_batch_receive.tab"
646 g.error.sdump("D_ERROR", E);
650 function remove_me() {
651 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
652 dump('removing ' + url + '\n');
653 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
654 $('nav').setAttribute('hidden','true');
657 function add_to_bucket() {
658 JSAN.use('util.window'); var win = new util.window();
660 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
662 'chrome,resizable,modal,centerscreen',
664 record_ids: [ docid ]
669 function mark_for_overlay() {
670 g.data.marked_record = docid;
671 g.data.stash('marked_record');
672 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
673 if (typeof robj.ilsevent == 'undefined') {
674 g.data.marked_record_mvr = robj;
676 g.data.marked_record_mvr = null;
677 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
679 g.data.stash('marked_record_mvr');
680 if (g.data.marked_record_mvr) {
681 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
684 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
685 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
686 gen_statusbar_click_handler('marked_record')
689 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
692 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
694 gen_statusbar_click_handler('marked_record')
699 function mark_for_hold_transfer() {
700 g.data.marked_record_for_hold_transfer = docid;
701 g.data.stash('marked_record_for_hold_transfer');
702 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
703 if (typeof robj.ilsevent == 'undefined') {
704 g.data.marked_record_for_hold_transfer_mvr = robj;
706 g.data.marked_record_for_hold_transfer_mvr = null;
707 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
709 g.data.stash('marked_record_for_hold_transfer_mvr');
710 if (g.data.marked_record_mvr) {
711 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
717 gen_statusbar_click_handler('marked_record_for_hold_transfer')
720 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
726 gen_statusbar_click_handler('marked_record_for_hold_transfer')
731 function transfer_title_holds() {
732 g.data.stash_retrieve();
733 var target = g.data.marked_record_for_hold_transfer;
735 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
739 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
741 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
744 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
747 hold_browser_reset = true;
748 if (g.view == 'hold_browser') { set_hold_browser(); };
751 function delete_record() {
752 if (g.error.yns_alert(
753 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
754 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
755 document.getElementById('offlineStrings').getString('cat.opac.delete'),
756 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
758 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
759 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
760 if (typeof robj.ilsevent != 'undefined') {
761 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
763 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
764 refresh_display(docid);
769 function undelete_record() {
770 if (g.error.yns_alert(
771 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
772 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
773 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
774 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
776 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
778 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
779 if (typeof robj.ilsevent != 'undefined') {
780 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
782 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
783 refresh_display(docid);
788 function refresh_display(id) {
790 marc_view_reset = true;
791 marc_edit_reset = true;
792 copy_browser_reset = true;
793 hold_browser_reset = true;
794 manage_parts_reset = true;
795 manage_multi_home_reset = true;
796 serctrl_view_reset = true;
797 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
798 var children = bottom_pane.node.childNodes;
799 for (var i = 0; i < children.length; i++) {
800 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
804 $('nav').setAttribute('hidden','false');
805 var settings = g.network.simple_request(
807 [ ses(), g.data.list.au[0].id() ]
809 var view = settings['staff_client.catalog.record_view.default'];
810 if (g.view_override) {
811 view = g.view_override;
812 g.view_override = null;
815 case 'marc_view' : set_marc_view(); break;
816 case 'marc_edit' : set_marc_edit(); break;
817 case 'copy_browser' : set_copy_browser(); break;
818 case 'hold_browser' : set_hold_browser(); break;
819 case 'serctrl_view' : set_serctrl_view(); break;
821 default: set_opac(); break;
823 opac_wrapper_set_help_context();
825 g.error.standard_unexpected_error_alert('in refresh_display',E);
829 function set_default() {
830 var robj = g.network.simple_request(
832 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
834 if (typeof robj.ilsevent != 'undefined') {
835 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
839 function add_volumes() {
843 edit = g.network.request(
844 api.PERM_MULTI_ORG_CHECK.app,
845 api.PERM_MULTI_ORG_CHECK.method,
850 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
852 ).length == 0 ? 1 : 0;
854 g.error.sdump('D_ERROR','batch permission check: ' + E);
858 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
859 return; // no read-only view for this interface
862 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
864 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
865 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
866 var w = xulG.new_tab(
868 { 'tab_name' : title },
869 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
872 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
876 function manage_parts() {
878 g.view = 'manage_parts';
879 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
880 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
882 if (manage_parts_reset) {
883 bottom_pane.reset_iframe( loc,{},xulG);
884 manage_parts_reset =false;
886 bottom_pane.set_iframe( loc,{},xulG);
888 opac_wrapper_set_help_context();
889 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
891 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
895 function manage_multi_home_items() {
897 g.view = 'manage_multi_home';
898 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
899 if (manage_multi_home_reset) {
900 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
901 manage_multi_home_reset =false;
903 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
905 opac_wrapper_set_help_context();
906 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
908 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
912 function mark_for_multi_home() {
913 g.data.marked_multi_home_record = docid;
914 g.data.stash('marked_multi_home_record');
915 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
916 if (typeof robj.ilsevent == 'undefined') {
917 g.data.marked_multi_home_record_mvr = robj;
919 g.data.marked_multi_home_record_mvr = null;
920 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
922 g.data.stash('marked_multi_home_record_mvr');
924 if (g.data.marked_multi_home_record_mvr) {
925 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
928 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
929 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
930 gen_statusbar_click_handler('marked_multi_home_record')
933 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
936 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
938 gen_statusbar_click_handler('marked_multi_home_record')
943 function gen_statusbar_click_handler(data_key) {
944 return function (ev) {
946 if (! g.data[data_key]) {
950 if (ev.button == 0 /* left click, spawn opac */) {
951 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + g.data[data_key];
952 var content_params = {
954 'authtime' : ses('authtime'),
955 'opac_url' : opac_url,
958 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
959 {'tab_name':'Retrieving title...'},
964 if (ev.button == 2 /* right click, remove mark */) {
965 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
966 g.data[data_key] = null;
967 g.data.stash(data_key);
968 ev.target.setAttribute('label','');
969 if (ev.target.hasAttribute('tooltiptext')) {
970 ev.target.removeAttribute('tooltiptext');