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 serctrl_view_reset = true;
9 function $(id) { return document.getElementById(id); }
13 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
14 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
15 JSAN.errorLevel = "die"; // none, warn, or die
16 JSAN.addRepository('..');
17 JSAN.use('util.error'); g.error = new util.error();
18 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
20 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
21 XML_HTTP_SERVER = g.data.server_unadorned;
23 // Pull in local customizations
24 var r = new XMLHttpRequest();
25 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
27 if (r.status == 200) {
28 dump('Evaluating /xul/server/skin/custom.js\n');
29 eval( r.responseText );
32 window.help_context_set_locally = true;
34 JSAN.use('util.network'); g.network = new util.network();
37 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
38 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
39 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
42 JSAN.use('util.deck');
43 top_pane = new util.deck('top_pane');
44 bottom_pane = new util.deck('bottom_pane');
49 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
50 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
55 function default_focus() {
56 opac_wrapper_set_help_context();
59 function opac_wrapper_set_help_context() {
61 dump('Entering opac.js, opac_wrapper_set_help_context\n');
62 var cw = bottom_pane.get_contentWindow();
63 if (cw && typeof cw['location'] != 'undefined') {
64 if (typeof cw.help_context_set_locally == 'undefined') {
66 'protocol' : cw.location.protocol,
67 'hostname' : cw.location.hostname,
68 'port' : cw.location.port,
69 'pathname' : cw.location.pathname,
72 xulG.set_help_context(help_params);
74 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
75 if (typeof cw.default_focus == 'function') {
80 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
81 dump('\tcw.location = ' + cw.location + '\n');
84 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
85 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
89 function set_brief_view() {
90 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
91 dump('spawning ' + url + '\n');
93 var content_params = {
94 'set_tab_name' : function(n) {
95 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
96 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
98 dump('no set_tab_name\n');
103 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
104 "set_patron_tab", "volume_item_creator", "get_new_session",
105 "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
106 "network_meter", "page_meter", "set_statusbar", "set_help_context"
107 ].forEach(function(k) { content_params[k] = xulG[k]; });
116 function set_marc_view() {
117 g.view = 'marc_view';
118 if (marc_view_reset) {
119 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
120 marc_view_reset = false;
122 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
124 opac_wrapper_set_help_context();
125 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
128 function set_marc_edit() {
129 g.view = 'marc_edit';
130 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
133 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
134 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
135 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
137 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
138 cat.util.spawn_copy_editor = function(params) {
140 if (!params.copy_ids && !params.copies) return;
141 if (params.copy_ids && params.copy_ids.length == 0) return;
142 if (params.copies && params.copies.length == 0) return;
143 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
144 if (!params.caller_handles_update) params.handle_update = 1; // legacy
147 JSAN.use('util.network'); obj.network = new util.network();
148 JSAN.use('util.error'); obj.error = new util.error();
151 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
152 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
153 else if(params.copies && params.copies.length > 1 && params.edit == 1)
154 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
155 else if(params.copy_ids && params.copy_ids.length == 1)
156 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
158 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
160 JSAN.use('util.window'); var win = new util.window();
161 var my_xulG = win.open(
162 (urls.XUL_COPY_EDITOR),
164 'chrome,modal,resizable',
167 if (!my_xulG.copies && params.edit) {
169 return my_xulG.copies;
173 JSAN.use('util.error'); var error = new util.error();
174 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
177 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
181 JSAN.use('util.error'); error = new util.error();
182 JSAN.use('util.network'); var network = new util.network();
184 var acn_blob = network.simple_request(
185 'FM_ACN_FIND_OR_CREATE',
186 [ ses(), cn_label, doc_id, ses('ws_ou') ]
189 if (typeof acn_blob.ilsevent != 'undefined') {
190 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_blob);
194 var copy_obj = new acp();
197 copy_obj.barcode( cp_barcode );
198 copy_obj.call_number( acn_blob.acn_id );
199 copy_obj.circ_lib( ses('ws_ou') );
200 /* FIXME -- use constants */
203 copy_obj.deposit_amount(0);
204 copy_obj.fine_level(2); // Normal
205 copy_obj.loan_duration(2); // Normal
206 copy_obj.location(1); // Stacks
207 copy_obj.status(5); // In Process
208 copy_obj.circulate(get_db_true());
209 copy_obj.holdable(get_db_true());
210 copy_obj.opac_visible(get_db_true());
211 copy_obj.ref(get_db_false());
213 JSAN.use('util.window'); var win = new util.window();
214 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
217 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);
220 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
222 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
226 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
227 'func' : function (new_marcxml) {
229 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
230 marc_view_reset = true;
231 copy_browser_reset = true;
232 hold_browser_reset = true;
233 if (typeof r.ilsevent != 'undefined') {
238 'oncomplete' : function() {}
242 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
246 'lock_tab' : xulG.lock_tab,
247 'unlock_tab' : xulG.unlock_tab
249 if (marc_edit_reset) {
250 bottom_pane.reset_iframe( a,b,c );
251 marc_edit_reset = false;
253 bottom_pane.set_iframe( a,b,c );
255 opac_wrapper_set_help_context();
256 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
259 function set_copy_browser() {
260 g.view = 'copy_browser';
261 if (copy_browser_reset) {
262 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
263 copy_browser_reset =false;
265 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
267 opac_wrapper_set_help_context();
268 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
271 function set_hold_browser() {
272 g.view = 'hold_browser';
273 if (hold_browser_reset) {
274 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
275 hold_browser_reset = false;
277 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
279 opac_wrapper_set_help_context();
280 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
284 function open_acq_orders() {
286 var content_params = {
288 "authtime": ses("authtime"),
290 "show_nav_buttons": true,
291 "show_print_button": false
294 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
295 "set_patron_tab", "volume_item_creator", "get_new_session",
296 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
297 "url_prefix", "network_meter", "page_meter", "set_statusbar",
299 ].forEach(function(k) { content_params[k] = xulG[k]; });
301 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
302 xulG.url_prefix("/eg/acq/lineitem/related/") +
303 docid + "?target=bib"
307 "tab_name": $("offlineStrings").getString(
308 "staff.cat.opac.related_items"
314 g.error.sdump("D_ERROR", E);
318 function open_alt_serial_mgmt() {
320 var content_params = {
322 "authtime": ses("authtime"),
323 "show_nav_buttons": true,
325 "show_print_button": false
328 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
329 "set_patron_tab", "volume_item_creator", "get_new_session",
330 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
331 "url_prefix", "network_meter", "page_meter", "set_statusbar",
333 ].forEach(function(k) { content_params[k] = xulG[k]; });
335 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
336 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
341 "tab_name": $("offlineStrings").getString(
342 "staff.cat.opac.serial_alt_mgmt"
348 g.error.sdump("D_ERROR", E);
352 function set_opac() {
355 var content_params = {
356 'show_nav_buttons' : true,
357 'show_print_button' : true,
358 'passthru_content_params' : {
360 'authtime' : ses('authtime'),
361 'window_open' : function(a,b,c) {
363 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
364 return window.open(a,b,c);
366 g.error.standard_unexpected_error_alert('window_open',E);
370 'on_url_load' : function(f) {
371 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
374 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
375 win = f.contentWindow.wrappedJSObject;
377 win = f.contentWindow;
380 win = f.contentWindow;
382 win.attachEvt("rdetail", "recordRetrieved",
385 if (docid == id) return;
389 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
394 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
395 $('record_start').disabled = true; $('record_next').disabled = true;
396 $('record_prev').disabled = true; $('record_end').disabled = true;
397 $('record_pos').setAttribute('value','');
399 win.attachEvt("rdetail", "nextPrevDrawn",
400 function(rIndex,rCount){
401 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
402 if (win.rdetailNext) {
403 g.f_record_next = function() {
404 g.view_override = g.view;
407 $('record_next').disabled = false;
409 if (win.rdetailPrev) {
410 g.f_record_prev = function() {
411 g.view_override = g.view;
414 $('record_prev').disabled = false;
416 if (win.rdetailStart) {
417 g.f_record_start = function() {
418 g.view_override = g.view;
421 $('record_start').disabled = false;
423 if (win.rdetailEnd) {
424 g.f_record_end = function() {
425 g.view_override = g.view;
428 $('record_end').disabled = false;
433 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
434 var mfhd_edit_menu = $('mfhd_edit');
435 var mfhd_delete_menu = $('mfhd_delete');
437 // clear menus on subsequent loads
438 if (mfhd_edit_menu.firstChild) {
439 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
440 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
443 mfhd_edit_menu.disabled = true;
444 mfhd_delete_menu.disabled = true;
446 win.attachEvt("rdetail", "MFHDDrawn",
448 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
450 g.mfhd.details = win.mfhdDetails;
451 mfhd_edit_menu.disabled = false;
452 mfhd_delete_menu.disabled = false;
453 for (var i = 0; i < win.mfhdDetails.length; i++) {
454 var mfhd_details = win.mfhdDetails[i];
455 var num = mfhd_details.entryNum;
457 var label = mfhd_details.label + ' (' + num + ')';
458 var item = mfhd_edit_menu.appendItem(label);
459 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
460 item = mfhd_delete_menu.appendItem(label);
461 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
467 'url_prefix' : xulG.url_prefix,
469 content_params.new_tab = xulG.new_tab;
470 content_params.set_tab = xulG.set_tab;
471 content_params.close_tab = xulG.close_tab;
472 content_params.lock_tab = xulG.lock_tab;
473 content_params.unlock_tab = xulG.unlock_tab;
474 content_params.inspect_tab = xulG.inspect_tab;
475 content_params.new_patron_tab = xulG.new_patron_tab;
476 content_params.set_patron_tab = xulG.set_patron_tab;
477 content_params.volume_item_creator = xulG.volume_item_creator;
478 content_params.get_new_session = xulG.get_new_session;
479 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
480 content_params.set_tab_name = xulG.set_tab_name;
481 content_params.open_chrome_window = xulG.open_chrome_window;
482 content_params.url_prefix = xulG.url_prefix;
483 content_params.network_meter = xulG.network_meter;
484 content_params.page_meter = xulG.page_meter;
485 content_params.set_statusbar = xulG.set_statusbar;
486 content_params.set_help_context = xulG.set_help_context;
488 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
489 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
490 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
491 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
494 g.error.sdump('D_ERROR','set_opac: ' + E);
496 opac_wrapper_set_help_context();
497 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
500 function set_serctrl_view() {
501 g.view = 'serctrl_view';
502 if (serctrl_view_reset) {
503 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
504 serctrl_view_reset =false;
506 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
510 function create_mfhd() {
512 JSAN.use('util.window'); var win = new util.window();
513 var select_aou_window = win.open(
514 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
516 'chrome,resizable,modal,centerscreen',
517 {'server_unadorned' : g.data.server_unadorned}
519 if (!select_aou_window.create_mfhd_aou) {
522 var r = g.network.simple_request(
523 'MFHD_XML_RECORD_CREATE',
524 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
526 if (typeof r.ilsevent != 'undefined') {
529 alert("MFHD record created."); //TODO: better success message
530 //TODO: refresh opac display
532 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
536 function delete_mfhd(sre_id) {
537 if (g.error.yns_alert(
538 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
539 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
540 document.getElementById('offlineStrings').getString('cat.opac.delete'),
541 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
543 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
544 var robj = g.network.request(
545 'open-ils.permacrud',
546 'open-ils.permacrud.delete.sre',
548 if (typeof robj.ilsevent != 'undefined') {
549 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
551 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
552 //TODO: refresh opac display
557 function open_mfhd_editor(sre_id) {
559 var r = g.network.simple_request(
563 if (typeof r.ilsevent != 'undefined') {
566 open_marc_editor(r, 'MFHD');
568 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
572 function open_marc_editor(rec, label) {
573 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
576 record : {marc : rec.marc()},
578 label: 'Save ' + label,
579 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
580 var method = 'open-ils.permacrud.update.' + rec.classname;
583 'open-ils.permacrud', method,
591 function bib_in_new_tab() {
593 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
594 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
595 content_params.url_prefix = xulG.url_prefix;
596 content_params.new_tab = xulG.new_tab;
597 content_params.set_tab = xulG.set_tab;
598 content_params.close_tab = xulG.close_tab;
599 content_params.lock_tab = xulG.lock_tab;
600 content_params.unlock_tab = xulG.unlock_tab;
601 content_params.inspect_tab = xulG.inspect_tab;
602 content_params.new_patron_tab = xulG.new_patron_tab;
603 content_params.set_patron_tab = xulG.set_patron_tab;
604 content_params.volume_item_creator = xulG.volume_item_creator;
605 content_params.get_new_session = xulG.get_new_session;
606 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
607 content_params.set_tab_name = xulG.set_tab_name;
608 content_params.open_chrome_window = xulG.open_chrome_window;
609 content_params.url_prefix = xulG.url_prefix;
610 content_params.network_meter = xulG.network_meter;
611 content_params.page_meter = xulG.page_meter;
612 content_params.set_statusbar = xulG.set_statusbar;
613 content_params.set_help_context = xulG.set_help_context;
615 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
617 g.error.sdump('D_ERROR',E);
621 function batch_receive_in_new_tab() {
623 var content_params = {"session": ses(), "authtime": ses("authtime")};
625 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
626 "set_patron_tab", "volume_item_creator", "get_new_session",
627 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
628 "url_prefix", "network_meter", "page_meter", "set_statusbar",
630 ].forEach(function(k) { content_params[k] = xulG[k]; });
633 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
634 "?docid=" + window.escape(docid), {
635 "tab_name": $("offlineStrings").getString(
636 "menu.cmd_serial_batch_receive.tab"
641 g.error.sdump("D_ERROR", E);
645 function remove_me() {
646 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
647 dump('removing ' + url + '\n');
648 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
649 $('nav').setAttribute('hidden','true');
652 function add_to_bucket() {
653 JSAN.use('util.window'); var win = new util.window();
655 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
657 'chrome,resizable,modal,centerscreen',
659 record_ids: [ docid ]
664 function mark_for_overlay() {
665 g.data.marked_record = docid;
666 g.data.stash('marked_record');
667 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
668 if (typeof robj.ilsevent == 'undefined') {
669 g.data.marked_record_mvr = robj;
671 g.data.marked_record_mvr = null;
672 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
674 g.data.stash('marked_record_mvr');
675 if (g.data.marked_record_mvr) {
676 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
677 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]) );
679 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
680 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]) );
684 function mark_for_hold_transfer() {
685 g.data.marked_record_for_hold_transfer = docid;
686 g.data.stash('marked_record_for_hold_transfer');
687 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
688 if (typeof robj.ilsevent == 'undefined') {
689 g.data.marked_record_for_hold_transfer_mvr = robj;
691 g.data.marked_record_for_hold_transfer_mvr = null;
692 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
694 g.data.stash('marked_record_for_hold_transfer_mvr');
695 if (g.data.marked_record_mvr) {
696 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
697 alert(m); xulG.set_statusbar(1, m );
699 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
700 alert(m); xulG.set_statusbar(1, m );
704 function transfer_title_holds() {
705 g.data.stash_retrieve();
706 var target = g.data.marked_record_for_hold_transfer;
708 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
712 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
714 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
717 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
720 hold_browser_reset = true;
721 if (g.view == 'hold_browser') { set_hold_browser(); };
724 function delete_record() {
725 if (g.error.yns_alert(
726 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
727 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
728 document.getElementById('offlineStrings').getString('cat.opac.delete'),
729 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
731 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
732 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
733 if (typeof robj.ilsevent != 'undefined') {
734 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
736 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
737 refresh_display(docid);
742 function undelete_record() {
743 if (g.error.yns_alert(
744 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
745 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
746 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
747 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
749 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
751 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
752 if (typeof robj.ilsevent != 'undefined') {
753 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
755 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
756 refresh_display(docid);
761 function refresh_display(id) {
763 marc_view_reset = true;
764 marc_edit_reset = true;
765 copy_browser_reset = true;
766 hold_browser_reset = true;
767 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
768 var children = bottom_pane.node.childNodes;
769 for (var i = 0; i < children.length; i++) {
770 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
774 $('nav').setAttribute('hidden','false');
775 var settings = g.network.simple_request(
777 [ ses(), g.data.list.au[0].id() ]
779 var view = settings['staff_client.catalog.record_view.default'];
780 if (g.view_override) {
781 view = g.view_override;
782 g.view_override = null;
785 case 'marc_view' : set_marc_view(); break;
786 case 'marc_edit' : set_marc_edit(); break;
787 case 'copy_browser' : set_copy_browser(); break;
788 case 'hold_browser' : set_hold_browser(); break;
789 case 'serctrl_view' : set_serctrl_view(); break;
791 default: set_opac(); break;
793 opac_wrapper_set_help_context();
795 g.error.standard_unexpected_error_alert('in refresh_display',E);
799 function set_default() {
800 var robj = g.network.simple_request(
802 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
804 if (typeof robj.ilsevent != 'undefined') {
805 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
809 function add_volumes() {
813 edit = g.network.request(
814 api.PERM_MULTI_ORG_CHECK.app,
815 api.PERM_MULTI_ORG_CHECK.method,
820 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
822 ).length == 0 ? 1 : 0;
824 g.error.sdump('D_ERROR','batch permission check: ' + E);
828 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
829 return; // no read-only view for this interface
832 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
834 var horizontal_interface = String( g.data.hash.aous['ui.cat.volume_copy_editor.horizontal'] ) == 'true';
835 var url = window.xulG.url_prefix( horizontal_interface ? urls.XUL_VOLUME_COPY_CREATOR_HORIZONTAL : urls.XUL_VOLUME_COPY_CREATOR );
836 var w = xulG.new_tab(
838 { 'tab_name' : title },
839 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
842 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
846 function manage_parts() {
848 var title = document.getElementById('offlineStrings').getFormattedString('staff.cat.manage_parts.title', [docid]);
849 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
850 window.xulG.url_prefix(urls.CONIFY_MANAGE_PARTS) + '?r=' + docid
852 var w = xulG.new_tab(
854 { 'tab_name' : title },
858 alert('Error in chrome/content/cat/opac.js, manage_parts(): ' + E);