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 hold_browser_reset = true;
7 var acq_orders_reset = true;
8 var serctrl_view_reset = true;
10 function $(id) { return document.getElementById(id); }
14 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
15 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
16 JSAN.errorLevel = "die"; // none, warn, or die
17 JSAN.addRepository('..');
18 JSAN.use('util.error'); g.error = new util.error();
19 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
21 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
22 XML_HTTP_SERVER = g.data.server_unadorned;
24 // Pull in local customizations
25 var r = new XMLHttpRequest();
26 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
28 if (r.status == 200) {
29 dump('Evaluating /xul/server/skin/custom.js\n');
30 eval( r.responseText );
33 window.help_context_set_locally = true;
35 JSAN.use('util.network'); g.network = new util.network();
38 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
39 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
41 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
43 JSAN.use('util.deck');
44 top_pane = new util.deck('top_pane');
45 bottom_pane = new util.deck('bottom_pane');
50 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
51 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
56 function default_focus() {
57 opac_wrapper_set_help_context();
60 function opac_wrapper_set_help_context() {
62 dump('Entering opac.js, opac_wrapper_set_help_context\n');
63 var cw = bottom_pane.get_contentWindow();
64 if (cw && typeof cw['location'] != 'undefined') {
65 if (typeof cw.help_context_set_locally == 'undefined') {
67 'protocol' : cw.location.protocol,
68 'hostname' : cw.location.hostname,
69 'port' : cw.location.port,
70 'pathname' : cw.location.pathname,
73 xulG.set_help_context(help_params);
75 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
76 if (typeof cw.default_focus == 'function') {
81 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
82 dump('\tcw.location = ' + cw.location + '\n');
85 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
86 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
90 function set_brief_view() {
91 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
92 dump('spawning ' + url + '\n');
97 'set_tab_name' : function(n) {
98 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
99 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
101 dump('no set_tab_name\n');
108 function set_marc_view() {
109 g.view = 'marc_view';
110 if (marc_view_reset) {
111 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
112 marc_view_reset = false;
114 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
116 opac_wrapper_set_help_context();
117 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
120 function set_marc_edit() {
121 g.view = 'marc_edit';
122 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
125 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
126 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
128 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
129 cat.util.spawn_copy_editor = function(params) {
131 if (!params.copy_ids && !params.copies) return;
132 if (params.copy_ids && params.copy_ids.length == 0) return;
133 if (params.copies && params.copies.length == 0) return;
134 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
135 if (!params.caller_handles_update) params.handle_update = 1; // legacy
138 JSAN.use('util.network'); obj.network = new util.network();
139 JSAN.use('util.error'); obj.error = new util.error();
142 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
143 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
144 else if(params.copies && params.copies.length > 1 && params.edit == 1)
145 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
146 else if(params.copy_ids && params.copy_ids.length == 1)
147 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
149 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
151 JSAN.use('util.window'); var win = new util.window();
152 var my_xulG = win.open(
153 (urls.XUL_COPY_EDITOR),
155 'chrome,modal,resizable',
158 if (!my_xulG.copies && params.edit) {
160 return my_xulG.copies;
164 JSAN.use('util.error'); var error = new util.error();
165 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
168 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
172 JSAN.use('util.error'); error = new util.error();
173 JSAN.use('util.network'); var network = new util.network();
175 var acn_id = network.simple_request(
176 'FM_ACN_FIND_OR_CREATE',
177 [ ses(), cn_label, doc_id, ses('ws_ou') ]
180 if (typeof acn_id.ilsevent != 'undefined') {
181 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_id);
185 var copy_obj = new acp();
188 copy_obj.barcode( cp_barcode );
189 copy_obj.call_number( acn_id );
190 copy_obj.circ_lib( ses('ws_ou') );
191 /* FIXME -- use constants */
194 copy_obj.deposit_amount(0);
195 copy_obj.fine_level(2);
196 copy_obj.loan_duration(2);
197 copy_obj.location(1);
199 copy_obj.circulate(get_db_true());
200 copy_obj.holdable(get_db_true());
201 copy_obj.opac_visible(get_db_true());
202 copy_obj.ref(get_db_false());
204 JSAN.use('util.window'); var win = new util.window();
205 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
208 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);
211 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
213 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
217 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
218 'func' : function (new_marcxml) {
220 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
221 marc_view_reset = true;
222 copy_browser_reset = true;
223 hold_browser_reset = true;
224 if (typeof r.ilsevent != 'undefined') {
229 'oncomplete' : function() {}
233 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
238 if (marc_edit_reset) {
239 bottom_pane.reset_iframe( a,b,c );
240 marc_edit_reset = false;
242 bottom_pane.set_iframe( a,b,c );
244 opac_wrapper_set_help_context();
245 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
248 function set_copy_browser() {
249 g.view = 'copy_browser';
250 if (copy_browser_reset) {
251 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
252 copy_browser_reset =false;
254 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
256 opac_wrapper_set_help_context();
257 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
260 function set_hold_browser() {
261 g.view = 'hold_browser';
262 if (hold_browser_reset) {
263 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
264 hold_browser_reset = false;
266 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
268 opac_wrapper_set_help_context();
269 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
272 function set_acq_orders() {
273 g.view = 'acq_orders';
274 var url = xulG.url_prefix( '/eg/acq/lineitem/related/' ) + window.escape(docid) + '?target=bib';
275 if (acq_orders_reset) {
276 bottom_pane.reset_iframe(url,{},xulG);
277 acq_orders_reset = false;
279 bottom_pane.set_iframe(url,{},xulG);
281 opac_wrapper_set_help_context();
282 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
285 function set_opac() {
288 var content_params = {
289 'show_nav_buttons' : true,
290 'show_print_button' : true,
291 'passthru_content_params' : {
293 'authtime' : ses('authtime'),
294 'window_open' : function(a,b,c) {
296 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
297 return window.open(a,b,c);
299 g.error.standard_unexpected_error_alert('window_open',E);
303 'on_url_load' : function(f) {
304 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
307 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
308 win = f.contentWindow.wrappedJSObject;
310 win = f.contentWindow;
313 win = f.contentWindow;
315 win.attachEvt("rdetail", "recordRetrieved",
318 if (docid == id) return;
322 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
327 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
328 $('record_start').disabled = true; $('record_next').disabled = true;
329 $('record_prev').disabled = true; $('record_end').disabled = true;
330 $('record_pos').setAttribute('value','');
332 win.attachEvt("rdetail", "nextPrevDrawn",
333 function(rIndex,rCount){
334 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
335 if (win.rdetailNext) {
336 g.f_record_next = function() {
337 g.view_override = g.view;
340 $('record_next').disabled = false;
342 if (win.rdetailPrev) {
343 g.f_record_prev = function() {
344 g.view_override = g.view;
347 $('record_prev').disabled = false;
349 if (win.rdetailStart) {
350 g.f_record_start = function() {
351 g.view_override = g.view;
354 $('record_start').disabled = false;
356 if (win.rdetailEnd) {
357 g.f_record_end = function() {
358 g.view_override = g.view;
361 $('record_end').disabled = false;
366 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
367 var mfhd_edit_menu = $('mfhd_edit');
368 var mfhd_delete_menu = $('mfhd_delete');
370 // clear menus on subsequent loads
371 if (mfhd_edit_menu.firstChild) {
372 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
373 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
376 mfhd_edit_menu.disabled = true;
377 mfhd_delete_menu.disabled = true;
379 win.attachEvt("rdetail", "MFHDDrawn",
381 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
383 g.mfhd.details = win.mfhdDetails;
384 mfhd_edit_menu.disabled = false;
385 mfhd_delete_menu.disabled = false;
386 for (var i = 0; i < win.mfhdDetails.length; i++) {
387 var mfhd_details = win.mfhdDetails[i];
388 var num = mfhd_details.entryNum;
390 var label = mfhd_details.label + ' (' + num + ')';
391 var item = mfhd_edit_menu.appendItem(label);
392 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
393 item = mfhd_delete_menu.appendItem(label);
394 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
400 'url_prefix' : xulG.url_prefix,
402 content_params.new_tab = xulG.new_tab;
403 content_params.set_tab = xulG.set_tab;
404 content_params.close_tab = xulG.close_tab;
405 content_params.new_patron_tab = xulG.new_patron_tab;
406 content_params.set_patron_tab = xulG.set_patron_tab;
407 content_params.volume_item_creator = xulG.volume_item_creator;
408 content_params.get_new_session = xulG.get_new_session;
409 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
410 content_params.set_tab_name = xulG.set_tab_name;
411 content_params.open_chrome_window = xulG.open_chrome_window;
412 content_params.url_prefix = xulG.url_prefix;
413 content_params.network_meter = xulG.network_meter;
414 content_params.page_meter = xulG.page_meter;
415 content_params.set_statusbar = xulG.set_statusbar;
416 content_params.set_help_context = xulG.set_help_context;
418 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
419 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
420 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
421 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
424 g.error.sdump('D_ERROR','set_opac: ' + E);
426 opac_wrapper_set_help_context();
427 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
430 function set_serctrl_view() {
431 g.view = 'serctrl_view';
432 if (serctrl_view_reset) {
433 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
434 serctrl_view_reset =false;
436 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
440 function create_mfhd() {
442 g.data.create_mfhd_aou = '';
443 JSAN.use('util.window'); var win = new util.window();
445 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
446 'sel_bucket_win' + win.window_name_increment(),
447 'chrome,resizable,modal,centerscreen'
449 if (!g.data.create_mfhd_aou) {
452 var r = g.network.simple_request(
453 'MFHD_XML_RECORD_CREATE',
454 [ ses(), 1, g.data.create_mfhd_aou, docid ]
456 if (typeof r.ilsevent != 'undefined') {
459 alert("MFHD record created."); //TODO: better success message
460 //TODO: refresh opac display
462 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
466 function delete_mfhd(sre_id) {
467 if (g.error.yns_alert(
468 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
469 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
470 document.getElementById('offlineStrings').getString('cat.opac.delete'),
471 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
473 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
474 var robj = g.network.request(
475 'open-ils.permacrud',
476 'open-ils.permacrud.delete.sre',
478 if (typeof robj.ilsevent != 'undefined') {
479 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
481 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
482 //TODO: refresh opac display
487 function open_mfhd_editor(sre_id) {
489 var r = g.network.simple_request(
493 if (typeof r.ilsevent != 'undefined') {
496 open_marc_editor(r, 'MFHD');
498 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
502 function open_marc_editor(rec, label) {
503 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
506 record : {marc : rec.marc()},
508 label: 'Save ' + label,
509 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
510 var method = 'open-ils.permacrud.update.' + rec.classname;
513 'open-ils.permacrud', method,
521 function bib_in_new_tab() {
523 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
524 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
525 content_params.url_prefix = xulG.url_prefix;
526 content_params.new_tab = xulG.new_tab;
527 content_params.set_tab = xulG.set_tab;
528 content_params.close_tab = xulG.close_tab;
529 content_params.new_patron_tab = xulG.new_patron_tab;
530 content_params.set_patron_tab = xulG.set_patron_tab;
531 content_params.volume_item_creator = xulG.volume_item_creator;
532 content_params.get_new_session = xulG.get_new_session;
533 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
534 content_params.set_tab_name = xulG.set_tab_name;
535 content_params.open_chrome_window = xulG.open_chrome_window;
536 content_params.url_prefix = xulG.url_prefix;
537 content_params.network_meter = xulG.network_meter;
538 content_params.page_meter = xulG.page_meter;
539 content_params.set_statusbar = xulG.set_statusbar;
540 content_params.set_help_context = xulG.set_help_context;
542 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
544 g.error.sdump('D_ERROR',E);
548 function remove_me() {
549 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
550 dump('removing ' + url + '\n');
551 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
552 $('nav').setAttribute('hidden','true');
555 function add_to_bucket() {
556 JSAN.use('util.window'); var win = new util.window();
558 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
559 'sel_bucket_win' + win.window_name_increment(),
560 'chrome,resizable,modal,centerscreen',
562 record_ids: [ docid ]
567 function mark_for_overlay() {
568 g.data.marked_record = docid;
569 g.data.stash('marked_record');
570 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
571 if (typeof robj.ilsevent == 'undefined') {
572 g.data.marked_record_mvr = robj;
574 g.data.marked_record_mvr = null;
575 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
577 g.data.stash('marked_record_mvr');
578 if (g.data.marked_record_mvr) {
579 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
580 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]) );
582 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
583 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]) );
587 function mark_for_hold_transfer() {
588 g.data.marked_record_for_hold_transfer = docid;
589 g.data.stash('marked_record_for_hold_transfer');
590 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
591 if (typeof robj.ilsevent == 'undefined') {
592 g.data.marked_record_for_hold_transfer_mvr = robj;
594 g.data.marked_record_for_hold_transfer_mvr = null;
595 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
597 g.data.stash('marked_record_for_hold_transfer_mvr');
598 if (g.data.marked_record_mvr) {
599 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
600 alert(m); xulG.set_statusbar(1, m );
602 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
603 alert(m); xulG.set_statusbar(1, m );
607 function transfer_title_holds() {
608 g.data.stash_retrieve();
609 var target = g.data.marked_record_for_hold_transfer;
611 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
615 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
617 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
620 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
623 hold_browser_reset = true;
624 if (g.view == 'hold_browser') { set_hold_browser(); };
627 function delete_record() {
628 if (g.error.yns_alert(
629 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
630 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
631 document.getElementById('offlineStrings').getString('cat.opac.delete'),
632 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
634 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
635 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
636 if (typeof robj.ilsevent != 'undefined') {
637 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
639 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
640 refresh_display(docid);
645 function undelete_record() {
646 if (g.error.yns_alert(
647 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
648 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
649 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
650 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
652 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
654 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
655 if (typeof robj.ilsevent != 'undefined') {
656 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
658 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
659 refresh_display(docid);
664 function refresh_display(id) {
666 marc_view_reset = true;
667 marc_edit_reset = true;
668 copy_browser_reset = true;
669 hold_browser_reset = true;
670 acq_orders_reset = true;
671 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
672 var children = bottom_pane.node.childNodes;
673 for (var i = 0; i < children.length; i++) {
674 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
678 $('nav').setAttribute('hidden','false');
679 var settings = g.network.simple_request(
681 [ ses(), g.data.list.au[0].id() ]
683 var view = settings['staff_client.catalog.record_view.default'];
684 if (g.view_override) {
685 view = g.view_override;
686 g.view_override = null;
689 case 'marc_view' : set_marc_view(); break;
690 case 'marc_edit' : set_marc_edit(); break;
691 case 'copy_browser' : set_copy_browser(); break;
692 case 'hold_browser' : set_hold_browser(); break;
693 case 'acq_orders' : set_acq_orders(); break;
694 case 'serctrl_view' : set_serctrl_view(); break;
696 default: set_opac(); break;
698 opac_wrapper_set_help_context();
700 g.error.standard_unexpected_error_alert('in refresh_display',E);
704 function set_default() {
705 var robj = g.network.simple_request(
707 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
709 if (typeof robj.ilsevent != 'undefined') {
710 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
714 function add_volumes() {
718 edit = g.network.request(
719 api.PERM_MULTI_ORG_CHECK.app,
720 api.PERM_MULTI_ORG_CHECK.method,
725 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
727 ).length == 0 ? 1 : 0;
729 g.error.sdump('D_ERROR','batch permission check: ' + E);
733 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
734 return; // no read-only view for this interface
737 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
739 JSAN.use('util.window'); var win = new util.window();
741 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
744 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
747 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);