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;
8 function $(id) { return document.getElementById(id); }
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');
19 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
20 XML_HTTP_SERVER = g.data.server_unadorned;
22 //JSAN.addRepository('http://' + g.data.server_unadorned + '/xul/server/');
23 //JSAN._loadJSFromUrl('http://' + g.data.server_unadorned + '/xul/server/cat/util.js');
25 JSAN.use('util.network'); g.network = new util.network();
28 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
29 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
30 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
32 JSAN.use('util.deck');
33 top_pane = new util.deck('top_pane');
34 bottom_pane = new util.deck('bottom_pane');
39 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
40 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
45 function set_brief_view() {
46 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
47 dump('spawning ' + url + '\n');
52 'set_tab_name' : function(n) {
53 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
54 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
56 dump('no set_tab_name\n');
63 function set_marc_view() {
65 if (marc_view_reset) {
66 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
67 marc_view_reset = false;
69 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
73 function set_marc_edit() {
75 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
78 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
79 /* // FIXME - disable this until we find a good way of pulling remote JSAN libraries into chrome
80 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
82 JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
89 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
90 'func' : function (new_marcxml) {
92 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
93 marc_view_reset = true;
94 copy_browser_reset = true;
95 hold_browser_reset = true;
96 if (typeof r.ilsevent != 'undefined') {
99 alert(document.getElementById('offlineStrings').getString("cat.save.success"));
102 'oncomplete' : function() {}
106 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
111 if (marc_edit_reset) {
112 bottom_pane.reset_iframe( a,b,c );
113 marc_edit_reset = false;
115 bottom_pane.set_iframe( a,b,c );
119 function set_copy_browser() {
120 g.view = 'copy_browser';
121 if (copy_browser_reset) {
122 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
123 copy_browser_reset =false;
125 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
129 function set_hold_browser() {
130 g.view = 'hold_browser';
131 if (hold_browser_reset) {
132 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
133 hold_browser_reset = false;
135 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
139 function set_opac() {
142 var content_params = {
143 'show_nav_buttons' : true,
144 'show_print_button' : true,
145 'passthru_content_params' : {
147 'authtime' : ses('authtime'),
148 'window_open' : function(a,b,c) {
150 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
151 return window.open(a,b,c);
153 g.error.standard_unexpected_error_alert('window_open',E);
157 'on_url_load' : function(f) {
158 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
161 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
162 win = f.contentWindow.wrappedJSObject;
164 win = f.contentWindow;
167 win = f.contentWindow;
169 win.attachEvt("rdetail", "recordRetrieved",
172 if (docid == id) return;
176 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
181 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
182 $('record_start').disabled = true; $('record_next').disabled = true;
183 $('record_prev').disabled = true; $('record_end').disabled = true;
184 $('record_pos').setAttribute('value','');
186 win.attachEvt("rdetail", "nextPrevDrawn",
187 function(rIndex,rCount){
188 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
189 if (win.rdetailNext) {
190 g.f_record_next = function() {
191 g.view_override = g.view;
194 $('record_next').disabled = false;
196 if (win.rdetailPrev) {
197 g.f_record_prev = function() {
198 g.view_override = g.view;
201 $('record_prev').disabled = false;
203 if (win.rdetailStart) {
204 g.f_record_start = function() {
205 g.view_override = g.view;
208 $('record_start').disabled = false;
210 if (win.rdetailEnd) {
211 g.f_record_end = function() {
212 g.view_override = g.view;
215 $('record_end').disabled = false;
220 'url_prefix' : xulG.url_prefix,
222 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
223 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
224 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
225 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
228 g.error.sdump('D_ERROR','set_opac: ' + E);
232 function bib_in_new_tab() {
234 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
235 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
236 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
238 g.error.sdump('D_ERROR',E);
242 function remove_me() {
243 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
244 dump('removing ' + url + '\n');
245 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
246 $('nav').setAttribute('hidden','true');
249 function add_to_bucket() {
250 JSAN.use('util.window'); var win = new util.window();
252 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
253 'sel_bucket_win' + win.window_name_increment(),
254 'chrome,resizable,modal,center',
256 record_ids: [ docid ]
261 function mark_for_overlay() {
262 g.data.marked_record = docid;
263 g.data.stash('marked_record');
264 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
265 if (typeof robj.ilsevent == 'undefined') {
266 g.data.marked_record_mvr = robj;
268 g.data.marked_record_mvr = null;
269 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
271 g.data.stash('marked_record_mvr');
272 if (g.data.marked_record_mvr) {
273 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
275 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
279 function delete_record() {
280 if (g.error.yns_alert(
281 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
282 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
283 document.getElementById('offlineStrings').getString('cat.opac.delete'),
284 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
286 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
287 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
288 if (typeof robj.ilsevent != 'undefined') {
289 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
291 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
292 refresh_display(docid);
297 function undelete_record() {
298 if (g.error.yns_alert(
299 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
300 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
301 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
302 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
304 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
306 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
307 if (typeof robj.ilsevent != 'undefined') {
308 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
310 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
311 refresh_display(docid);
316 function refresh_display(id) {
318 marc_view_reset = true;
319 marc_edit_reset = true;
320 copy_browser_reset = true;
321 hold_browser_reset = true;
322 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
323 var children = bottom_pane.node.childNodes;
324 for (var i = 0; i < children.length; i++) {
325 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
329 $('nav').setAttribute('hidden','false');
330 var settings = g.network.simple_request(
332 [ ses(), g.data.list.au[0].id() ]
334 var view = settings['staff_client.catalog.record_view.default'];
335 if (g.view_override) {
336 view = g.view_override;
337 g.view_override = null;
340 case 'marc_view' : set_marc_view(); break;
341 case 'marc_edit' : set_marc_edit(); break;
342 case 'copy_browser' : set_copy_browser(); break;
343 case 'hold_browser' : set_hold_browser(); break;
345 default: set_opac(); break;
348 g.error.standard_unexpected_error_alert('in refresh_display',E);
352 function set_default() {
353 var robj = g.network.simple_request(
355 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
357 if (typeof robj.ilsevent != 'undefined') {
358 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);