1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame; var opac_url;
3 var marc_view_reset = true;
4 var marc_edit_reset = true;
5 var copy_browser_reset = true;
6 var manage_parts_reset = true;
7 var manage_multi_home_reset = true;
8 var hold_browser_reset = true;
9 var serctrl_view_reset = true;
11 function $(id) { return document.getElementById(id); }
15 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
16 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
17 JSAN.errorLevel = "die"; // none, warn, or die
18 JSAN.addRepository('..');
19 JSAN.use('util.error'); g.error = new util.error();
20 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
22 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
23 XML_HTTP_SERVER = g.data.server_unadorned;
25 // Pull in local customizations
26 var r = new XMLHttpRequest();
27 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
29 if (r.status == 200) {
30 dump('Evaluating /xul/server/skin/custom.js\n');
31 eval( r.responseText );
34 window.help_context_set_locally = true;
36 JSAN.use('util.network'); g.network = new util.network();
39 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
41 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
42 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
44 JSAN.use('util.deck');
45 top_pane = new util.deck('top_pane');
46 bottom_pane = new util.deck('bottom_pane');
51 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
52 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
57 function default_focus() {
58 opac_wrapper_set_help_context();
61 function opac_wrapper_set_help_context() {
63 dump('Entering opac.js, opac_wrapper_set_help_context\n');
64 var cw = bottom_pane.get_contentWindow();
65 if (cw && typeof cw['location'] != 'undefined') {
66 if (typeof cw.help_context_set_locally == 'undefined') {
68 'protocol' : cw.location.protocol,
69 'hostname' : cw.location.hostname,
70 'port' : cw.location.port,
71 'pathname' : cw.location.pathname,
74 xulG.set_help_context(help_params);
76 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
77 if (typeof cw.default_focus == 'function') {
82 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
83 dump('\tcw.location = ' + cw.location + '\n');
86 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
87 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
91 function set_brief_view() {
92 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
93 dump('spawning ' + url + '\n');
95 var content_params = {
96 'set_tab_name' : function(n) {
97 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
98 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
100 dump('no set_tab_name\n');
105 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
106 "set_patron_tab", "volume_item_creator", "get_new_session",
107 "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
108 "network_meter", "page_meter", "set_statusbar", "set_help_context",
110 ].forEach(function(k) { content_params[k] = xulG[k]; });
119 function set_marc_view() {
120 g.view = 'marc_view';
121 if (marc_view_reset) {
122 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
123 marc_view_reset = false;
125 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
127 opac_wrapper_set_help_context();
128 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
131 function set_marc_edit() {
132 g.view = 'marc_edit';
133 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
136 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
137 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
138 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
140 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
141 cat.util.spawn_copy_editor = function(params) {
143 if (!params.copy_ids && !params.copies) return;
144 if (params.copy_ids && params.copy_ids.length == 0) return;
145 if (params.copies && params.copies.length == 0) return;
146 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
147 if (!params.caller_handles_update) params.handle_update = 1; // legacy
150 JSAN.use('util.network'); obj.network = new util.network();
151 JSAN.use('util.error'); obj.error = new util.error();
154 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
155 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
156 else if(params.copies && params.copies.length > 1 && params.edit == 1)
157 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
158 else if(params.copy_ids && params.copy_ids.length == 1)
159 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
161 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
163 JSAN.use('util.window'); var win = new util.window();
164 var my_xulG = win.open(
165 (urls.XUL_COPY_EDITOR),
167 'chrome,modal,resizable',
170 if (!my_xulG.copies && params.edit) {
172 return my_xulG.copies;
176 JSAN.use('util.error'); var error = new util.error();
177 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
180 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
184 JSAN.use('util.error'); error = new util.error();
185 JSAN.use('util.network'); var network = new util.network();
187 var acn_blob = network.simple_request(
188 'FM_ACN_FIND_OR_CREATE',
189 [ ses(), cn_label, doc_id, ses('ws_ou') ]
192 if (typeof acn_blob.ilsevent != 'undefined') {
193 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
197 // Get the default copy status; default to available if unset, per 1.6
198 var fast_ccs = g.data.hash.aous['cat.default_copy_status_fast'] || 0;
200 var copy_obj = new acp();
203 copy_obj.barcode( cp_barcode );
204 copy_obj.call_number( acn_blob.acn_id );
205 copy_obj.circ_lib( ses('ws_ou') );
206 /* FIXME -- use constants */
209 copy_obj.deposit_amount(0);
210 copy_obj.fine_level(2); // Normal
211 copy_obj.loan_duration(2); // Normal
212 copy_obj.location(1); // Stacks
213 copy_obj.status(fast_ccs);
214 copy_obj.circulate(get_db_true());
215 copy_obj.holdable(get_db_true());
216 copy_obj.opac_visible(get_db_true());
217 copy_obj.ref(get_db_false());
219 JSAN.use('util.window'); var win = new util.window();
221 var unified_interface = String( data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
222 if (unified_interface) {
223 var horizontal_interface = String( data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
224 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
225 var w = xulG.set_tab(
228 'tab_name' : document.getElementById('offlineStrings').getFormattedString(
235 'existing_copies' : [ copy_obj ],
236 'load_opac_when_done' : true,
237 'labels_in_new_tab' : true
242 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
246 if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E);
249 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
251 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
255 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
256 'func' : function (new_marcxml) {
258 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
259 marc_view_reset = true;
260 copy_browser_reset = true;
261 hold_browser_reset = true;
262 if (typeof r.ilsevent != 'undefined') {
267 'oncomplete' : function() {}
271 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
275 'lock_tab' : xulG.lock_tab,
276 'unlock_tab' : xulG.unlock_tab
278 if (marc_edit_reset) {
279 bottom_pane.reset_iframe( a,b,c );
280 marc_edit_reset = false;
282 bottom_pane.set_iframe( a,b,c );
284 opac_wrapper_set_help_context();
285 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
288 function set_copy_browser() {
289 g.view = 'copy_browser';
290 if (copy_browser_reset) {
291 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
292 copy_browser_reset =false;
294 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
296 opac_wrapper_set_help_context();
297 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
300 function set_hold_browser() {
301 g.view = 'hold_browser';
302 if (hold_browser_reset) {
303 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
304 hold_browser_reset = false;
306 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
308 opac_wrapper_set_help_context();
309 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
313 function open_acq_orders() {
315 var content_params = {
317 "authtime": ses("authtime"),
319 "show_nav_buttons": true,
320 "show_print_button": false
323 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
324 "set_patron_tab", "volume_item_creator", "get_new_session",
325 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
326 "url_prefix", "network_meter", "page_meter", "set_statusbar",
327 "set_help_context", "get_barcode"
328 ].forEach(function(k) { content_params[k] = xulG[k]; });
330 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
331 xulG.url_prefix("/eg/acq/lineitem/related/") +
332 docid + "?target=bib"
336 "tab_name": $("offlineStrings").getString(
337 "staff.cat.opac.related_items"
343 g.error.sdump("D_ERROR", E);
347 function open_alt_serial_mgmt() {
349 var content_params = {
351 "authtime": ses("authtime"),
352 "show_nav_buttons": true,
354 "show_print_button": false
357 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
358 "set_patron_tab", "volume_item_creator", "get_new_session",
359 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
360 "url_prefix", "network_meter", "page_meter", "set_statusbar",
361 "set_help_context", "get_barcode"
362 ].forEach(function(k) { content_params[k] = xulG[k]; });
364 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
365 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
370 "tab_name": $("offlineStrings").getString(
371 "staff.cat.opac.serial_alt_mgmt"
377 g.error.sdump("D_ERROR", E);
381 function set_opac() {
384 var content_params = {
385 'show_nav_buttons' : true,
386 'show_print_button' : true,
387 'passthru_content_params' : {
389 'authtime' : ses('authtime'),
390 'window_open' : function(a,b,c) {
392 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
393 return window.open(a,b,c);
395 g.error.standard_unexpected_error_alert('window_open',E);
398 'get_barcode' : xulG.get_barcode
400 'on_url_load' : function(f) {
401 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
404 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
405 win = f.contentWindow.wrappedJSObject;
407 win = f.contentWindow;
410 win = f.contentWindow;
412 win.attachEvt("rdetail", "recordRetrieved",
415 if (docid == id) return;
419 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
424 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
425 $('record_start').disabled = true; $('record_next').disabled = true;
426 $('record_prev').disabled = true; $('record_end').disabled = true;
427 $('record_pos').setAttribute('value','');
429 win.attachEvt("rdetail", "nextPrevDrawn",
430 function(rIndex,rCount){
431 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
432 if (win.rdetailNext) {
433 g.f_record_next = function() {
434 g.view_override = g.view;
437 $('record_next').disabled = false;
439 if (win.rdetailPrev) {
440 g.f_record_prev = function() {
441 g.view_override = g.view;
444 $('record_prev').disabled = false;
446 if (win.rdetailStart) {
447 g.f_record_start = function() {
448 g.view_override = g.view;
451 $('record_start').disabled = false;
453 if (win.rdetailEnd) {
454 g.f_record_end = function() {
455 g.view_override = g.view;
458 $('record_end').disabled = false;
463 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
464 var mfhd_edit_menu = $('mfhd_edit');
465 var mfhd_delete_menu = $('mfhd_delete');
467 // clear menus on subsequent loads
468 if (mfhd_edit_menu.firstChild) {
469 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
470 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
473 mfhd_edit_menu.disabled = true;
474 mfhd_delete_menu.disabled = true;
476 win.attachEvt("rdetail", "MFHDDrawn",
478 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
480 g.mfhd.details = win.mfhdDetails;
481 mfhd_edit_menu.disabled = false;
482 mfhd_delete_menu.disabled = false;
483 for (var i = 0; i < win.mfhdDetails.length; i++) {
484 var mfhd_details = win.mfhdDetails[i];
485 var num = mfhd_details.entryNum;
487 var label = mfhd_details.label + ' (' + num + ')';
488 var item = mfhd_edit_menu.appendItem(label);
489 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
490 item = mfhd_delete_menu.appendItem(label);
491 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
497 'url_prefix' : xulG.url_prefix,
499 content_params.new_tab = xulG.new_tab;
500 content_params.set_tab = xulG.set_tab;
501 content_params.close_tab = xulG.close_tab;
502 content_params.lock_tab = xulG.lock_tab;
503 content_params.unlock_tab = xulG.unlock_tab;
504 content_params.inspect_tab = xulG.inspect_tab;
505 content_params.new_patron_tab = xulG.new_patron_tab;
506 content_params.set_patron_tab = xulG.set_patron_tab;
507 content_params.volume_item_creator = xulG.volume_item_creator;
508 content_params.get_new_session = xulG.get_new_session;
509 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
510 content_params.set_tab_name = xulG.set_tab_name;
511 content_params.open_chrome_window = xulG.open_chrome_window;
512 content_params.url_prefix = xulG.url_prefix;
513 content_params.network_meter = xulG.network_meter;
514 content_params.page_meter = xulG.page_meter;
515 content_params.set_statusbar = xulG.set_statusbar;
516 content_params.set_help_context = xulG.set_help_context;
517 content_params.get_barcode = xulG.get_barcode;
519 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
520 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
521 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
522 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
525 g.error.sdump('D_ERROR','set_opac: ' + E);
527 opac_wrapper_set_help_context();
528 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
531 function set_serctrl_view() {
532 g.view = 'serctrl_view';
533 if (serctrl_view_reset) {
534 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
535 serctrl_view_reset =false;
537 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
541 function create_mfhd() {
543 JSAN.use('util.window'); var win = new util.window();
544 var select_aou_window = win.open(
545 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
547 'chrome,resizable,modal,centerscreen',
548 {'server_unadorned' : g.data.server_unadorned}
550 if (!select_aou_window.create_mfhd_aou) {
553 var r = g.network.simple_request(
554 'MFHD_XML_RECORD_CREATE',
555 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
557 if (typeof r.ilsevent != 'undefined') {
560 alert("MFHD record created."); //TODO: better success message
561 //TODO: refresh opac display
563 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
567 function delete_mfhd(sre_id) {
568 if (g.error.yns_alert(
569 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
570 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
571 document.getElementById('offlineStrings').getString('cat.opac.delete'),
572 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
574 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
575 var robj = g.network.request(
576 'open-ils.permacrud',
577 'open-ils.permacrud.delete.sre',
579 if (typeof robj.ilsevent != 'undefined') {
580 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
582 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
583 //TODO: refresh opac display
588 function open_mfhd_editor(sre_id) {
590 var r = g.network.simple_request(
594 if (typeof r.ilsevent != 'undefined') {
597 open_marc_editor(r, 'MFHD');
599 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
603 function open_marc_editor(rec, label) {
604 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
607 record : {marc : rec.marc()},
609 label: 'Save ' + label,
610 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
611 var method = 'open-ils.permacrud.update.' + rec.classname;
614 'open-ils.permacrud', method,
622 function bib_in_new_tab() {
624 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
625 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
626 content_params.url_prefix = xulG.url_prefix;
627 content_params.new_tab = xulG.new_tab;
628 content_params.set_tab = xulG.set_tab;
629 content_params.close_tab = xulG.close_tab;
630 content_params.lock_tab = xulG.lock_tab;
631 content_params.unlock_tab = xulG.unlock_tab;
632 content_params.inspect_tab = xulG.inspect_tab;
633 content_params.new_patron_tab = xulG.new_patron_tab;
634 content_params.set_patron_tab = xulG.set_patron_tab;
635 content_params.volume_item_creator = xulG.volume_item_creator;
636 content_params.get_new_session = xulG.get_new_session;
637 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
638 content_params.set_tab_name = xulG.set_tab_name;
639 content_params.open_chrome_window = xulG.open_chrome_window;
640 content_params.url_prefix = xulG.url_prefix;
641 content_params.network_meter = xulG.network_meter;
642 content_params.page_meter = xulG.page_meter;
643 content_params.set_statusbar = xulG.set_statusbar;
644 content_params.set_help_context = xulG.set_help_context;
645 content_params.get_barcode = xulG.get_barcode;
647 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
649 g.error.sdump('D_ERROR',E);
653 function batch_receive_in_new_tab() {
655 var content_params = {"session": ses(), "authtime": ses("authtime")};
657 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
658 "set_patron_tab", "volume_item_creator", "get_new_session",
659 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
660 "url_prefix", "network_meter", "page_meter", "set_statusbar",
661 "set_help_context", "get_barcode"
662 ].forEach(function(k) { content_params[k] = xulG[k]; });
665 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
666 "?docid=" + window.escape(docid), {
667 "tab_name": $("offlineStrings").getString(
668 "menu.cmd_serial_batch_receive.tab"
673 g.error.sdump("D_ERROR", E);
677 function remove_me() {
678 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
679 dump('removing ' + url + '\n');
680 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
681 $('nav').setAttribute('hidden','true');
684 function add_to_bucket() {
685 JSAN.use('util.window'); var win = new util.window();
687 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
689 'chrome,resizable,modal,centerscreen',
691 record_ids: [ docid ]
696 function mark_for_overlay() {
697 g.data.marked_record = docid;
698 g.data.stash('marked_record');
699 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
700 if (typeof robj.ilsevent == 'undefined') {
701 g.data.marked_record_mvr = robj;
703 g.data.marked_record_mvr = null;
704 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
706 g.data.stash('marked_record_mvr');
707 if (g.data.marked_record_mvr) {
708 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
711 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]),
712 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
713 gen_statusbar_click_handler('marked_record')
716 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
719 $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]),
721 gen_statusbar_click_handler('marked_record')
726 function mark_for_hold_transfer() {
727 g.data.marked_record_for_hold_transfer = docid;
728 g.data.stash('marked_record_for_hold_transfer');
729 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
730 if (typeof robj.ilsevent == 'undefined') {
731 g.data.marked_record_for_hold_transfer_mvr = robj;
733 g.data.marked_record_for_hold_transfer_mvr = null;
734 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
736 g.data.stash('marked_record_for_hold_transfer_mvr');
737 if (g.data.marked_record_mvr) {
738 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
744 gen_statusbar_click_handler('marked_record_for_hold_transfer')
747 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
753 gen_statusbar_click_handler('marked_record_for_hold_transfer')
758 function transfer_title_holds() {
759 g.data.stash_retrieve();
760 var target = g.data.marked_record_for_hold_transfer;
762 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
766 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
768 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
771 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
774 hold_browser_reset = true;
775 if (g.view == 'hold_browser') { set_hold_browser(); };
778 function delete_record() {
779 if (g.error.yns_alert(
780 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
781 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
782 document.getElementById('offlineStrings').getString('cat.opac.delete'),
783 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
785 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
786 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
787 if (typeof robj.ilsevent != 'undefined') {
788 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
790 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
791 refresh_display(docid);
796 function undelete_record() {
797 if (g.error.yns_alert(
798 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
799 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
800 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
801 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
803 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
805 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
806 if (typeof robj.ilsevent != 'undefined') {
807 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
809 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
810 refresh_display(docid);
815 function refresh_display(id) {
817 marc_view_reset = true;
818 marc_edit_reset = true;
819 copy_browser_reset = true;
820 hold_browser_reset = true;
821 manage_parts_reset = true;
822 manage_multi_home_reset = true;
823 serctrl_view_reset = true;
824 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
825 var children = bottom_pane.node.childNodes;
826 for (var i = 0; i < children.length; i++) {
827 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
831 $('nav').setAttribute('hidden','false');
832 var settings = g.network.simple_request(
834 [ ses(), g.data.list.au[0].id() ]
836 var view = settings['staff_client.catalog.record_view.default'];
837 if (g.view_override) {
838 view = g.view_override;
839 g.view_override = null;
842 case 'marc_view' : set_marc_view(); break;
843 case 'marc_edit' : set_marc_edit(); break;
844 case 'copy_browser' : set_copy_browser(); break;
845 case 'hold_browser' : set_hold_browser(); break;
846 case 'serctrl_view' : set_serctrl_view(); break;
848 default: set_opac(); break;
850 opac_wrapper_set_help_context();
852 g.error.standard_unexpected_error_alert('in refresh_display',E);
856 function set_default() {
857 var robj = g.network.simple_request(
859 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
861 if (typeof robj.ilsevent != 'undefined') {
862 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
866 function add_volumes() {
870 edit = g.network.request(
871 api.PERM_MULTI_ORG_CHECK.app,
872 api.PERM_MULTI_ORG_CHECK.method,
877 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
879 ).length == 0 ? 1 : 0;
881 g.error.sdump('D_ERROR','batch permission check: ' + E);
885 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
886 return; // no read-only view for this interface
889 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
892 var unified_interface = String( g.data.hash.aous['ui.unified_volume_copy_editor'] ) == 'true';
893 if (unified_interface) {
894 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
895 url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
897 url = window.xulG.url_prefix( urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL );
900 var w = xulG.new_tab(
902 { 'tab_name' : title },
903 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
906 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
910 function manage_parts() {
912 g.view = 'manage_parts';
913 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
914 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
916 if (manage_parts_reset) {
917 bottom_pane.reset_iframe( loc,{},xulG);
918 manage_parts_reset =false;
920 bottom_pane.set_iframe( loc,{},xulG);
922 opac_wrapper_set_help_context();
923 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
925 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);
929 function manage_multi_home_items() {
931 g.view = 'manage_multi_home';
932 var loc = window.xulG.url_prefix(urls.MANAGE_MULTI_HOME_ITEMS);
933 if (manage_multi_home_reset) {
934 bottom_pane.reset_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
935 manage_multi_home_reset =false;
937 bottom_pane.set_iframe( loc,{},{'docid':docid,'no_bib_summary':true,'url_prefix':xulG.url_prefix,'new_tab':xulG.new_tab});
939 opac_wrapper_set_help_context();
940 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
942 alert('Error in chrome/content/cat/opac.js, manage_multi_home_items(): ' + E);
946 function mark_for_multi_home() {
947 g.data.marked_multi_home_record = docid;
948 g.data.stash('marked_multi_home_record');
949 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
950 if (typeof robj.ilsevent == 'undefined') {
951 g.data.marked_multi_home_record_mvr = robj;
953 g.data.marked_multi_home_record_mvr = null;
954 g.error.standard_unexpected_error_alert('in mark_for_multi_home',robj);
956 g.data.stash('marked_multi_home_record_mvr');
958 if (g.data.marked_multi_home_record_mvr) {
959 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.tcn.alert',[ g.data.marked_multi_home_record_mvr.tcn() ]));
962 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.tcn.label',[g.data.marked_multi_home_record_mvr.tcn()]),
963 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
964 gen_statusbar_click_handler('marked_multi_home_record')
967 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_multi_home.record_id.alert',[ g.data.marked_multi_home_record ]));
970 $("offlineStrings").getFormattedString('staff.cat.copy_browser.marked_record_for_multi_home_indicator.record_id.label',[g.data.marked_multi_home_record]),
972 gen_statusbar_click_handler('marked_multi_home_record')
977 function gen_statusbar_click_handler(data_key) {
978 return function (ev) {
980 if (! g.data[data_key]) {
984 if (ev.button == 0 /* left click, spawn opac */) {
985 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + g.data[data_key];
986 var content_params = {
988 'authtime' : ses('authtime'),
989 'opac_url' : opac_url,
992 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
993 {'tab_name':'Retrieving title...'},
998 if (ev.button == 2 /* right click, remove mark */) {
999 if ( window.confirm( document.getElementById('offlineStrings').getString('cat.opac.clear_statusbar') ) ) {
1000 g.data[data_key] = null;
1001 g.data.stash(data_key);
1002 ev.target.setAttribute('label','');
1003 if (ev.target.hasAttribute('tooltiptext')) {
1004 ev.target.removeAttribute('tooltiptext');