]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/cat/opac.js
wrong URL
[working/Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / cat / opac.js
1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame; var opac_url;
2
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
9 function $(id) { return document.getElementById(id); }
10
11 function my_init() {
12     try {
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');
19
20         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
21         XML_HTTP_SERVER = g.data.server_unadorned;
22
23         // Pull in local customizations
24         var r = new XMLHttpRequest();
25         r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
26         r.send(null);
27         if (r.status == 200) {
28             dump('Evaluating /xul/server/skin/custom.js\n');
29             eval( r.responseText );
30         }
31
32         window.help_context_set_locally = true;
33
34         JSAN.use('util.network'); g.network = new util.network();
35
36         g.cgi = new CGI();
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); }
41
42         JSAN.use('util.deck');
43         top_pane = new util.deck('top_pane');
44         bottom_pane = new util.deck('bottom_pane');
45
46         set_opac();
47
48     } catch(E) {
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); }
51         alert(err_msg);
52     }
53 }
54
55 function default_focus() {
56     opac_wrapper_set_help_context(); 
57 }
58
59 function opac_wrapper_set_help_context() {
60     try {
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') {
65                 var help_params = {
66                     'protocol' : cw.location.protocol,
67                     'hostname' : cw.location.hostname,
68                     'port' : cw.location.port,
69                     'pathname' : cw.location.pathname,
70                     'src' : ''
71                 };
72                 xulG.set_help_context(help_params);
73             } else {
74                 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
75                 if (typeof cw.default_focus == 'function') {
76                     cw.default_focus();
77                 }
78             }
79         } else {
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');
82         }
83     } catch(E) {
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');
86     }
87 }
88
89 function set_brief_view() {
90     var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid); 
91     dump('spawning ' + url + '\n');
92     top_pane.set_iframe( 
93         url,
94         {}, 
95         { 
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); }
99                 } else {
100                     dump('no set_tab_name\n');
101                 }
102             }
103         }  
104     );
105 }
106
107 function set_marc_view() {
108     g.view = 'marc_view';
109     if (marc_view_reset) {
110         bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
111         marc_view_reset = false;
112     } else {
113         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
114     }
115     opac_wrapper_set_help_context(); 
116     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
117 }
118
119 function set_marc_edit() {
120     g.view = 'marc_edit';
121     var a =    xulG.url_prefix( urls.XUL_MARC_EDIT );
122     var b =    {};
123     var c =    {
124             'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
125             'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
126                 try {
127                     var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
128                     cat.util.spawn_copy_editor = function(params) {
129                         try {
130                             if (!params.copy_ids && !params.copies) return;
131                             if (params.copy_ids && params.copy_ids.length == 0) return;
132                             if (params.copies && params.copies.length == 0) return;
133                             if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
134                             if (!params.caller_handles_update) params.handle_update = 1; // legacy
135
136                             var obj = {};
137                             JSAN.use('util.network'); obj.network = new util.network();
138                             JSAN.use('util.error'); obj.error = new util.error();
139                         
140                             var title = '';
141                             if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
142                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
143                             else if(params.copies && params.copies.length > 1 && params.edit == 1)
144                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
145                             else if(params.copy_ids && params.copy_ids.length == 1)
146                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
147                             else
148                                 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
149
150                             JSAN.use('util.window'); var win = new util.window();
151                             var my_xulG = win.open(
152                                 (urls.XUL_COPY_EDITOR),
153                                 title,
154                                 'chrome,modal,resizable',
155                                 params
156                             );
157                             if (!my_xulG.copies && params.edit) {
158                             } else {
159                                 return my_xulG.copies;
160                             }
161                             return [];
162                         } catch(E) {
163                             JSAN.use('util.error'); var error = new util.error();
164                             error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
165                         }
166                     }
167                     cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
168                         var error;
169                         try {
170
171                             JSAN.use('util.error'); error = new util.error();
172                             JSAN.use('util.network'); var network = new util.network();
173
174                             var acn_id = network.simple_request(
175                                 'FM_ACN_FIND_OR_CREATE',
176                                 [ ses(), cn_label, doc_id, ses('ws_ou') ]
177                             );
178
179                             if (typeof acn_id.ilsevent != 'undefined') {
180                                 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_id);
181                                 return;
182                             }
183
184                             var copy_obj = new acp();
185                             copy_obj.id( -1 );
186                             copy_obj.isnew('1');
187                             copy_obj.barcode( cp_barcode );
188                             copy_obj.call_number( acn_id );
189                             copy_obj.circ_lib( ses('ws_ou') );
190                             /* FIXME -- use constants */
191                             copy_obj.deposit(0);
192                             copy_obj.price(0);
193                             copy_obj.deposit_amount(0);
194                             copy_obj.fine_level(2);
195                             copy_obj.loan_duration(2);
196                             copy_obj.location(1);
197                             copy_obj.status(0);
198                             copy_obj.circulate(get_db_true());
199                             copy_obj.holdable(get_db_true());
200                             copy_obj.opac_visible(get_db_true());
201                             copy_obj.ref(get_db_false());
202
203                             JSAN.use('util.window'); var win = new util.window();
204                             return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
205
206                         } catch(E) {
207                             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);
208                         }
209                     }
210                     return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
211                 } catch(E) {
212                     alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
213                 }
214             },
215             'save' : {
216                 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
217                 'func' : function (new_marcxml) {
218                     try {
219                         var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
220                         marc_view_reset = true;
221                         copy_browser_reset = true;
222                         hold_browser_reset = true;
223                         if (typeof r.ilsevent != 'undefined') {
224                             throw(r);
225                         } else {
226                             return {
227                                 'id' : r.id(),
228                                 'oncomplete' : function() {}
229                             };
230                         }
231                     } catch(E) {
232                             g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
233                     }
234                 }
235             }
236         };
237     if (marc_edit_reset) {
238         bottom_pane.reset_iframe( a,b,c );
239         marc_edit_reset = false;
240     } else {
241         bottom_pane.set_iframe( a,b,c );
242     }
243     opac_wrapper_set_help_context(); 
244     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
245 }
246
247 function set_copy_browser() {
248     g.view = 'copy_browser';
249     if (copy_browser_reset) {
250         bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
251         copy_browser_reset =false;
252     } else {
253         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
254     }
255     opac_wrapper_set_help_context(); 
256     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
257 }
258
259 function set_hold_browser() {
260     g.view = 'hold_browser';
261     if (hold_browser_reset) {
262         bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
263         hold_browser_reset = false;
264     } else {
265         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
266     }
267     opac_wrapper_set_help_context(); 
268     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
269 }
270
271 function set_acq_orders() {
272     g.view = 'acq_orders';
273     var url = xulG.url_prefix( '/eg/acq/lineitem/related/' ) + window.escape(docid) + '?target=bib';
274     if (acq_orders_reset) {
275         bottom_pane.reset_iframe(url,{},xulG);
276         acq_orders_reset = false;
277     } else {
278         bottom_pane.set_iframe(url,{},xulG);
279     }
280     opac_wrapper_set_help_context(); 
281     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
282 }
283
284 function set_opac() {
285     g.view = 'opac';
286     try {
287         var content_params = { 
288             'show_nav_buttons' : true,
289             'show_print_button' : true,
290             'passthru_content_params' : { 
291                 'authtoken' : ses(), 
292                 'authtime' : ses('authtime'),
293                 'window_open' : function(a,b,c) {
294                     try {
295                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
296                         return window.open(a,b,c);
297                     } catch(E) {
298                         g.error.standard_unexpected_error_alert('window_open',E);
299                     }
300                 }
301             },
302             'on_url_load' : function(f) {
303                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
304                 var win;
305                 try {
306                     if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
307                         win = f.contentWindow.wrappedJSObject;
308                     } else {
309                         win = f.contentWindow;
310                     }
311                 } catch(E) {
312                     win = f.contentWindow;
313                 }
314                 win.attachEvt("rdetail", "recordRetrieved",
315                     function(id){
316                         try {
317                             if (docid == id) return;
318                             docid = id;
319                             refresh_display(id);
320                         } catch(E) {
321                             g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
322                         }
323                     }
324                 );
325                 
326                 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
327                 $('record_start').disabled = true; $('record_next').disabled = true;
328                 $('record_prev').disabled = true; $('record_end').disabled = true;
329                 $('record_pos').setAttribute('value','');
330
331                 win.attachEvt("rdetail", "nextPrevDrawn",
332                     function(rIndex,rCount){
333                         $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
334                         if (win.rdetailNext) {
335                             g.f_record_next = function() { 
336                                 g.view_override = g.view; 
337                                 win.rdetailNext(); 
338                             }
339                             $('record_next').disabled = false;
340                         }
341                         if (win.rdetailPrev) {
342                             g.f_record_prev = function() { 
343                                 g.view_override = g.view; 
344                                 win.rdetailPrev(); 
345                             }
346                             $('record_prev').disabled = false;
347                         }
348                         if (win.rdetailStart) {
349                             g.f_record_start = function() { 
350                                 g.view_override = g.view; 
351                                 win.rdetailStart(); 
352                             }
353                             $('record_start').disabled = false;
354                         }
355                         if (win.rdetailEnd) {
356                             g.f_record_end = function() { 
357                                 g.view_override = g.view; 
358                                 win.rdetailEnd(); 
359                             }
360                             $('record_end').disabled = false;
361                         }
362                     }
363                 );
364             },
365             'url_prefix' : xulG.url_prefix,
366         };
367         content_params.new_tab = xulG.new_tab;
368         content_params.set_tab = xulG.set_tab;
369         content_params.close_tab = xulG.close_tab;
370         content_params.new_patron_tab = xulG.new_patron_tab;
371         content_params.set_patron_tab = xulG.set_patron_tab;
372         content_params.volume_item_creator = xulG.volume_item_creator;
373         content_params.get_new_session = xulG.get_new_session;
374         content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
375         content_params.set_tab_name = xulG.set_tab_name;
376         content_params.open_chrome_window = xulG.open_chrome_window;
377         content_params.url_prefix = xulG.url_prefix;
378         content_params.network_meter = xulG.network_meter;
379         content_params.page_meter = xulG.page_meter;
380         content_params.set_statusbar = xulG.set_statusbar;
381         content_params.set_help_context = xulG.set_help_context;
382
383         if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
384         browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
385         /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
386         browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
387         */
388     } catch(E) {
389         g.error.sdump('D_ERROR','set_opac: ' + E);
390     }
391     opac_wrapper_set_help_context(); 
392     bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
393 }
394
395 function bib_in_new_tab() {
396     try {
397         var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
398         var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
399         content_params.url_prefix = xulG.url_prefix;
400         content_params.new_tab = xulG.new_tab;
401         content_params.set_tab = xulG.set_tab;
402         content_params.close_tab = xulG.close_tab;
403         content_params.new_patron_tab = xulG.new_patron_tab;
404         content_params.set_patron_tab = xulG.set_patron_tab;
405         content_params.volume_item_creator = xulG.volume_item_creator;
406         content_params.get_new_session = xulG.get_new_session;
407         content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
408         content_params.set_tab_name = xulG.set_tab_name;
409         content_params.open_chrome_window = xulG.open_chrome_window;
410         content_params.url_prefix = xulG.url_prefix;
411         content_params.network_meter = xulG.network_meter;
412         content_params.page_meter = xulG.page_meter;
413         content_params.set_statusbar = xulG.set_statusbar;
414         content_params.set_help_context = xulG.set_help_context;
415
416         xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
417     } catch(E) {
418         g.error.sdump('D_ERROR',E);
419     }
420 }
421
422 function remove_me() {
423     var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
424     dump('removing ' + url + '\n');
425     try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
426     $('nav').setAttribute('hidden','true');
427 }
428
429 function add_to_bucket() {
430     JSAN.use('util.window'); var win = new util.window();
431     win.open(
432         xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
433         'sel_bucket_win' + win.window_name_increment(),
434         'chrome,resizable,modal,center',
435         {
436             record_ids: [ docid ]
437         }
438     );
439 }
440
441 function mark_for_overlay() {
442     g.data.marked_record = docid;
443     g.data.stash('marked_record');
444     var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
445     if (typeof robj.ilsevent == 'undefined') {
446         g.data.marked_record_mvr = robj;
447     } else {
448         g.data.marked_record_mvr = null;
449         g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
450     }
451     g.data.stash('marked_record_mvr');
452     if (g.data.marked_record_mvr) {
453         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
454         xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]) );
455     } else {
456         alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record  ]));
457         xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]) );
458     }
459 }
460
461 function mark_for_hold_transfer() {
462     g.data.marked_record_for_hold_transfer = docid;
463     g.data.stash('marked_record_for_hold_transfer');
464     var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
465     if (typeof robj.ilsevent == 'undefined') {
466         g.data.marked_record_for_hold_transfer_mvr = robj;
467     } else {
468         g.data.marked_record_for_hold_transfer_mvr = null;
469         g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
470     }
471     g.data.stash('marked_record_for_hold_transfer_mvr');
472     if (g.data.marked_record_mvr) {
473         var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
474         alert(m); xulG.set_statusbar(1, m );
475     } else {
476         var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
477         alert(m); xulG.set_statusbar(1, m );
478     }
479 }
480
481 function transfer_title_holds() {
482     g.data.stash_retrieve();
483     var target = g.data.marked_record_for_hold_transfer;
484     if (!target) {
485         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
486         alert(m);
487         return;
488     }
489     var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
490     if (robj == 1) {
491         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
492         alert(m);
493     } else {
494         var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
495         alert(m);
496     }
497     hold_browser_reset = true;
498     if (g.view == 'hold_browser') { set_hold_browser(); };
499 }
500
501 function delete_record() {
502     if (g.error.yns_alert(
503         document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
504         document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
505         document.getElementById('offlineStrings').getString('cat.opac.delete'),
506         document.getElementById('offlineStrings').getString('cat.opac.cancel'),
507         null,
508         document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
509         var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
510         if (typeof robj.ilsevent != 'undefined') {
511             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
512         } else {
513             alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
514             refresh_display(docid);
515         }
516     }
517 }
518
519 function undelete_record() {
520     if (g.error.yns_alert(
521         document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
522         document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
523         document.getElementById('offlineStrings').getString('cat.opac.undelete'),
524         document.getElementById('offlineStrings').getString('cat.opac.cancel'),
525         null,
526         document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
527
528         var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
529         if (typeof robj.ilsevent != 'undefined') {
530             alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error',  [docid, robj.textcode, robj.desc]) + '\n');
531         } else {
532             alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
533             refresh_display(docid);
534         }
535     }
536 }
537
538 function refresh_display(id) {
539     try { 
540         marc_view_reset = true;
541         marc_edit_reset = true;
542         copy_browser_reset = true;
543         hold_browser_reset = true;
544         acq_orders_reset = true;
545         while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
546         var children = bottom_pane.node.childNodes;
547         for (var i = 0; i < children.length; i++) {
548             if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
549         }
550
551         set_brief_view();
552         $('nav').setAttribute('hidden','false');
553         var settings = g.network.simple_request(
554             'FM_AUS_RETRIEVE',
555             [ ses(), g.data.list.au[0].id() ]
556         );
557         var view = settings['staff_client.catalog.record_view.default'];
558         if (g.view_override) {
559             view = g.view_override;
560             g.view_override = null;
561         }
562         switch(view) {
563             case 'marc_view' : set_marc_view(); break;
564             case 'marc_edit' : set_marc_edit(); break;
565             case 'copy_browser' : set_copy_browser(); break;
566             case 'hold_browser' : set_hold_browser(); break;
567             case 'acq_orders' : set_acq_orders(); break;
568             case 'opac' :
569             default: set_opac(); break;
570         }
571         opac_wrapper_set_help_context(); 
572     } catch(E) {
573         g.error.standard_unexpected_error_alert('in refresh_display',E);
574     }
575 }
576
577 function set_default() {
578     var robj = g.network.simple_request(
579         'FM_AUS_UPDATE',
580         [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
581     )
582     if (typeof robj.ilsevent != 'undefined') {
583         if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
584     }
585 }
586
587 function add_volumes() {
588     try {
589         var edit = 0;
590         try {
591             edit = g.network.request(
592                 api.PERM_MULTI_ORG_CHECK.app,
593                 api.PERM_MULTI_ORG_CHECK.method,
594                 [ 
595                     ses(), 
596                     ses('staff_id'), 
597                     [ ses('ws_ou') ],
598                     [ 'CREATE_VOLUME', 'CREATE_COPY' ]
599                 ]
600             ).length == 0 ? 1 : 0;
601         } catch(E) {
602             g.error.sdump('D_ERROR','batch permission check: ' + E);
603         }
604
605         if (edit==0) {
606             alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
607             return; // no read-only view for this interface
608         }
609
610         var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
611
612         JSAN.use('util.window'); var win = new util.window();
613         var w = win.open(
614             window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
615             title,
616             'chrome,resizable',
617             { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
618         );
619     } catch(E) {
620         alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);
621     }
622 }