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