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();
220 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
223 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);
226 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
228 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
232 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
233 'func' : function (new_marcxml) {
235 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
236 marc_view_reset = true;
237 copy_browser_reset = true;
238 hold_browser_reset = true;
239 if (typeof r.ilsevent != 'undefined') {
244 'oncomplete' : function() {}
248 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
252 'lock_tab' : xulG.lock_tab,
253 'unlock_tab' : xulG.unlock_tab
255 if (marc_edit_reset) {
256 bottom_pane.reset_iframe( a,b,c );
257 marc_edit_reset = false;
259 bottom_pane.set_iframe( a,b,c );
261 opac_wrapper_set_help_context();
262 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
265 function set_copy_browser() {
266 g.view = 'copy_browser';
267 if (copy_browser_reset) {
268 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
269 copy_browser_reset =false;
271 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
273 opac_wrapper_set_help_context();
274 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
277 function set_hold_browser() {
278 g.view = 'hold_browser';
279 if (hold_browser_reset) {
280 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
281 hold_browser_reset = false;
283 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
285 opac_wrapper_set_help_context();
286 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
290 function open_acq_orders() {
292 var content_params = {
294 "authtime": ses("authtime"),
296 "show_nav_buttons": true,
297 "show_print_button": false
300 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
301 "set_patron_tab", "volume_item_creator", "get_new_session",
302 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
303 "url_prefix", "network_meter", "page_meter", "set_statusbar",
304 "set_help_context", "get_barcode"
305 ].forEach(function(k) { content_params[k] = xulG[k]; });
307 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
308 xulG.url_prefix("/eg/acq/lineitem/related/") +
309 docid + "?target=bib"
313 "tab_name": $("offlineStrings").getString(
314 "staff.cat.opac.related_items"
320 g.error.sdump("D_ERROR", E);
324 function open_alt_serial_mgmt() {
326 var content_params = {
328 "authtime": ses("authtime"),
329 "show_nav_buttons": true,
331 "show_print_button": false
334 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
335 "set_patron_tab", "volume_item_creator", "get_new_session",
336 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
337 "url_prefix", "network_meter", "page_meter", "set_statusbar",
338 "set_help_context", "get_barcode"
339 ].forEach(function(k) { content_params[k] = xulG[k]; });
341 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
342 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
347 "tab_name": $("offlineStrings").getString(
348 "staff.cat.opac.serial_alt_mgmt"
354 g.error.sdump("D_ERROR", E);
358 function set_opac() {
361 var content_params = {
362 'show_nav_buttons' : true,
363 'show_print_button' : true,
364 'passthru_content_params' : {
366 'authtime' : ses('authtime'),
367 'window_open' : function(a,b,c) {
369 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
370 return window.open(a,b,c);
372 g.error.standard_unexpected_error_alert('window_open',E);
375 'get_barcode' : xulG.get_barcode
377 'on_url_load' : function(f) {
378 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
381 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
382 win = f.contentWindow.wrappedJSObject;
384 win = f.contentWindow;
387 win = f.contentWindow;
389 win.attachEvt("rdetail", "recordRetrieved",
392 if (docid == id) return;
396 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
401 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
402 $('record_start').disabled = true; $('record_next').disabled = true;
403 $('record_prev').disabled = true; $('record_end').disabled = true;
404 $('record_pos').setAttribute('value','');
406 win.attachEvt("rdetail", "nextPrevDrawn",
407 function(rIndex,rCount){
408 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
409 if (win.rdetailNext) {
410 g.f_record_next = function() {
411 g.view_override = g.view;
414 $('record_next').disabled = false;
416 if (win.rdetailPrev) {
417 g.f_record_prev = function() {
418 g.view_override = g.view;
421 $('record_prev').disabled = false;
423 if (win.rdetailStart) {
424 g.f_record_start = function() {
425 g.view_override = g.view;
428 $('record_start').disabled = false;
430 if (win.rdetailEnd) {
431 g.f_record_end = function() {
432 g.view_override = g.view;
435 $('record_end').disabled = false;
440 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
441 var mfhd_edit_menu = $('mfhd_edit');
442 var mfhd_delete_menu = $('mfhd_delete');
444 // clear menus on subsequent loads
445 if (mfhd_edit_menu.firstChild) {
446 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
447 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
450 mfhd_edit_menu.disabled = true;
451 mfhd_delete_menu.disabled = true;
453 win.attachEvt("rdetail", "MFHDDrawn",
455 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
457 g.mfhd.details = win.mfhdDetails;
458 mfhd_edit_menu.disabled = false;
459 mfhd_delete_menu.disabled = false;
460 for (var i = 0; i < win.mfhdDetails.length; i++) {
461 var mfhd_details = win.mfhdDetails[i];
462 var num = mfhd_details.entryNum;
464 var label = mfhd_details.label + ' (' + num + ')';
465 var item = mfhd_edit_menu.appendItem(label);
466 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
467 item = mfhd_delete_menu.appendItem(label);
468 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
474 'url_prefix' : xulG.url_prefix,
476 content_params.new_tab = xulG.new_tab;
477 content_params.set_tab = xulG.set_tab;
478 content_params.close_tab = xulG.close_tab;
479 content_params.lock_tab = xulG.lock_tab;
480 content_params.unlock_tab = xulG.unlock_tab;
481 content_params.inspect_tab = xulG.inspect_tab;
482 content_params.new_patron_tab = xulG.new_patron_tab;
483 content_params.set_patron_tab = xulG.set_patron_tab;
484 content_params.volume_item_creator = xulG.volume_item_creator;
485 content_params.get_new_session = xulG.get_new_session;
486 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
487 content_params.set_tab_name = xulG.set_tab_name;
488 content_params.open_chrome_window = xulG.open_chrome_window;
489 content_params.url_prefix = xulG.url_prefix;
490 content_params.network_meter = xulG.network_meter;
491 content_params.page_meter = xulG.page_meter;
492 content_params.set_statusbar = xulG.set_statusbar;
493 content_params.set_help_context = xulG.set_help_context;
494 content_params.get_barcode = xulG.get_barcode;
496 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
497 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
498 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
499 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
502 g.error.sdump('D_ERROR','set_opac: ' + E);
504 opac_wrapper_set_help_context();
505 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
508 function set_serctrl_view() {
509 g.view = 'serctrl_view';
510 if (serctrl_view_reset) {
511 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
512 serctrl_view_reset =false;
514 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
518 function create_mfhd() {
520 JSAN.use('util.window'); var win = new util.window();
521 var select_aou_window = win.open(
522 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
524 'chrome,resizable,modal,centerscreen',
525 {'server_unadorned' : g.data.server_unadorned}
527 if (!select_aou_window.create_mfhd_aou) {
530 var r = g.network.simple_request(
531 'MFHD_XML_RECORD_CREATE',
532 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
534 if (typeof r.ilsevent != 'undefined') {
537 alert("MFHD record created."); //TODO: better success message
538 //TODO: refresh opac display
540 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
544 function delete_mfhd(sre_id) {
545 if (g.error.yns_alert(
546 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
547 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
548 document.getElementById('offlineStrings').getString('cat.opac.delete'),
549 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
551 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
552 var robj = g.network.request(
553 'open-ils.permacrud',
554 'open-ils.permacrud.delete.sre',
556 if (typeof robj.ilsevent != 'undefined') {
557 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
559 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
560 //TODO: refresh opac display
565 function open_mfhd_editor(sre_id) {
567 var r = g.network.simple_request(
571 if (typeof r.ilsevent != 'undefined') {
574 open_marc_editor(r, 'MFHD');
576 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
580 function open_marc_editor(rec, label) {
581 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
584 record : {marc : rec.marc()},
586 label: 'Save ' + label,
587 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
588 var method = 'open-ils.permacrud.update.' + rec.classname;
591 'open-ils.permacrud', method,
599 function bib_in_new_tab() {
601 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
602 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
603 content_params.url_prefix = xulG.url_prefix;
604 content_params.new_tab = xulG.new_tab;
605 content_params.set_tab = xulG.set_tab;
606 content_params.close_tab = xulG.close_tab;
607 content_params.lock_tab = xulG.lock_tab;
608 content_params.unlock_tab = xulG.unlock_tab;
609 content_params.inspect_tab = xulG.inspect_tab;
610 content_params.new_patron_tab = xulG.new_patron_tab;
611 content_params.set_patron_tab = xulG.set_patron_tab;
612 content_params.volume_item_creator = xulG.volume_item_creator;
613 content_params.get_new_session = xulG.get_new_session;
614 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
615 content_params.set_tab_name = xulG.set_tab_name;
616 content_params.open_chrome_window = xulG.open_chrome_window;
617 content_params.url_prefix = xulG.url_prefix;
618 content_params.network_meter = xulG.network_meter;
619 content_params.page_meter = xulG.page_meter;
620 content_params.set_statusbar = xulG.set_statusbar;
621 content_params.set_help_context = xulG.set_help_context;
622 content_params.get_barcode = xulG.get_barcode;
624 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
626 g.error.sdump('D_ERROR',E);
630 function batch_receive_in_new_tab() {
632 var content_params = {"session": ses(), "authtime": ses("authtime")};
634 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
635 "set_patron_tab", "volume_item_creator", "get_new_session",
636 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
637 "url_prefix", "network_meter", "page_meter", "set_statusbar",
638 "set_help_context", "get_barcode"
639 ].forEach(function(k) { content_params[k] = xulG[k]; });
642 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
643 "?docid=" + window.escape(docid), {
644 "tab_name": $("offlineStrings").getString(
645 "menu.cmd_serial_batch_receive.tab"
650 g.error.sdump("D_ERROR", E);
654 function remove_me() {
655 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
656 dump('removing ' + url + '\n');
657 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
658 $('nav').setAttribute('hidden','true');
661 function add_to_bucket() {
662 JSAN.use('util.window'); var win = new util.window();
664 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
666 'chrome,resizable,modal,centerscreen',
668 record_ids: [ docid ]
673 function mark_for_overlay() {
674 g.data.marked_record = docid;
675 g.data.stash('marked_record');
676 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
677 if (typeof robj.ilsevent == 'undefined') {
678 g.data.marked_record_mvr = robj;
680 g.data.marked_record_mvr = null;
681 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
683 g.data.stash('marked_record_mvr');
684 if (g.data.marked_record_mvr) {
685 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
688 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
689 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
690 gen_statusbar_click_handler('marked_record')
693 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
696 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
698 gen_statusbar_click_handler('marked_record')
703 function mark_for_hold_transfer() {
704 g.data.marked_record_for_hold_transfer = docid;
705 g.data.stash('marked_record_for_hold_transfer');
706 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
707 if (typeof robj.ilsevent == 'undefined') {
708 g.data.marked_record_for_hold_transfer_mvr = robj;
710 g.data.marked_record_for_hold_transfer_mvr = null;
711 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
713 g.data.stash('marked_record_for_hold_transfer_mvr');
714 if (g.data.marked_record_mvr) {
715 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
721 gen_statusbar_click_handler('marked_record_for_hold_transfer')
724 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
730 gen_statusbar_click_handler('marked_record_for_hold_transfer')
735 function transfer_title_holds() {
736 g.data.stash_retrieve();
737 var target = g.data.marked_record_for_hold_transfer;
739 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
743 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
745 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
748 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
751 hold_browser_reset = true;
752 if (g.view == 'hold_browser') { set_hold_browser(); };
755 function delete_record() {
756 if (g.error.yns_alert(
757 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
758 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
759 document.getElementById('offlineStrings').getString('cat.opac.delete'),
760 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
762 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
763 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
764 if (typeof robj.ilsevent != 'undefined') {
765 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
767 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
768 refresh_display(docid);
773 function undelete_record() {
774 if (g.error.yns_alert(
775 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
776 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
777 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
778 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
780 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
782 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
783 if (typeof robj.ilsevent != 'undefined') {
784 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
786 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
787 refresh_display(docid);
792 function refresh_display(id) {
794 marc_view_reset = true;
795 marc_edit_reset = true;
796 copy_browser_reset = true;
797 hold_browser_reset = true;
798 manage_parts_reset = true;
799 manage_multi_home_reset = true;
800 serctrl_view_reset = true;
801 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
802 var children = bottom_pane.node.childNodes;
803 for (var i = 0; i < children.length; i++) {
804 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
808 $('nav').setAttribute('hidden','false');
809 var settings = g.network.simple_request(
811 [ ses(), g.data.list.au[0].id() ]
813 var view = settings['staff_client.catalog.record_view.default'];
814 if (g.view_override) {
815 view = g.view_override;
816 g.view_override = null;
819 case 'marc_view' : set_marc_view(); break;
820 case 'marc_edit' : set_marc_edit(); break;
821 case 'copy_browser' : set_copy_browser(); break;
822 case 'hold_browser' : set_hold_browser(); break;
823 case 'serctrl_view' : set_serctrl_view(); break;
825 default: set_opac(); break;
827 opac_wrapper_set_help_context();
829 g.error.standard_unexpected_error_alert('in refresh_display',E);
833 function set_default() {
834 var robj = g.network.simple_request(
836 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
838 if (typeof robj.ilsevent != 'undefined') {
839 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
843 function add_volumes() {
847 edit = g.network.request(
848 api.PERM_MULTI_ORG_CHECK.app,
849 api.PERM_MULTI_ORG_CHECK.method,
854 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
856 ).length == 0 ? 1 : 0;
858 g.error.sdump('D_ERROR','batch permission check: ' + E);
862 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
863 return; // no read-only view for this interface
866 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
869 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
870 if (unified_interface) {
871 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
872 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
874 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
877 var w = xulG.new_tab(
879 { 'tab_name' : title },
880 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
883 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
887 function manage_parts() {
889 g.view = 'manage_parts';
890 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
891 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
893 if (manage_parts_reset) {
894 bottom_pane.reset_iframe( loc,{},xulG);
895 manage_parts_reset =false;
897 bottom_pane.set_iframe( loc,{},xulG);
899 opac_wrapper_set_help_context();
900 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
902 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
906 function manage_multi_home_items() {
908 g.view = 'manage_multi_home';
909 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
910 if (manage_multi_home_reset) {
911 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
912 manage_multi_home_reset =false;
914 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
916 opac_wrapper_set_help_context();
917 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
919 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
923 function mark_for_multi_home() {
924 g.data.marked_multi_home_record = docid;
925 g.data.stash('marked_multi_home_record');
926 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
927 if (typeof robj.ilsevent == 'undefined') {
928 g.data.marked_multi_home_record_mvr = robj;
930 g.data.marked_multi_home_record_mvr = null;
931 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
933 g.data.stash('marked_multi_home_record_mvr');
935 if (g.data.marked_multi_home_record_mvr) {
936 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
939 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
940 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
941 gen_statusbar_click_handler('marked_multi_home_record')
944 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
947 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
949 gen_statusbar_click_handler('marked_multi_home_record')
954 function gen_statusbar_click_handler(data_key) {
955 return function (ev) {
957 if (! g.data[data_key]) {
961 if (ev.button == 0 /* left click, spawn opac */) {
962 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + g.data[data_key];
963 var content_params = {
965 'authtime' : ses('authtime'),
966 'opac_url' : opac_url,
969 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
970 {'tab_name':'Retrieving title...'},
975 if (ev.button == 2 /* right click, remove mark */) {
976 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
977 g.data[data_key] = null;
978 g.data.stash(data_key);
979 ev.target.setAttribute('label','');
980 if (ev.target.hasAttribute('tooltiptext')) {
981 ev.target.removeAttribute('tooltiptext');