From: dbs Date: Thu, 12 Aug 2010 03:41:57 +0000 (+0000) Subject: Update for 1.6.1 migration X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8b50c4993b738bb9d210118335c6ddb502209c54;p=contrib%2FConifer.git Update for 1.6.1 migration git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_0@956 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/tools/patch_conifer.sh b/tools/patch_conifer.sh index c9077fd502..cec9f37771 100644 --- a/tools/patch_conifer.sh +++ b/tools/patch_conifer.sh @@ -1,13 +1,13 @@ #!/bin/bash -REMOTE_CANONICAL_SVN_DIR=svn://svn.open-ils.org/ILS/branches/rel_1_6_0 -CANONICAL_SVN_DIR=/home/opensrf/Evergreen-rel_1_6_0 -CANONICAL_EXPORT_DIR=/home/opensrf/EG_1_6_0-export +REMOTE_CANONICAL_SVN_DIR=svn://svn.open-ils.org/ILS/branches/rel_1_6_1 +CANONICAL_SVN_DIR=/home/opensrf/Evergreen-rel_1_6_1 +CANONICAL_EXPORT_DIR=/home/opensrf/EG_1_6_1-export REMOTE_SVN_DIR=svn://svn.open-ils.org/ILS-Contrib/conifer LOCAL_SVN_DIR=/home/opensrf/conifer-svn LOCAL_EXPORT_DIR=/home/opensrf/conifer-export INSTALL_DIR=/openils -BRANCH=branches/rel_1_6_0 +BRANCH=branches/rel_1_6_1 update_repository() { diff --git a/xul/server/cat/spine_labels.js b/xul/server/cat/spine_labels.js index 7cca1e88df..2d16945bd8 100644 --- a/xul/server/cat/spine_labels.js +++ b/xul/server/cat/spine_labels.js @@ -1,298 +1,298 @@ - function my_init() { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); } - JSAN.errorLevel = "die"; // none, warn, or die - JSAN.addRepository('/xul/server/'); - JSAN.use('util.error'); g.error = new util.error(); - g.error.sdump('D_TRACE','my_init() for spine_labels.xul'); + function my_init() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); g.error = new util.error(); + g.error.sdump('D_TRACE','my_init() for spine_labels.xul'); - JSAN.use('util.network'); g.network = new util.network(); + JSAN.use('util.network'); g.network = new util.network(); - g.cgi = new CGI(); + g.cgi = new CGI(); - g.barcodes = []; - if (g.cgi.param('barcodes')) { - g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) ); - } - JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); - if (g.data.temp_barcodes_for_labels) { - g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels ); - g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels'); - } + g.barcodes = []; + if (g.cgi.param('barcodes')) { + g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) ); + } + JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); + if (g.data.temp_barcodes_for_labels) { + g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels ); + g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels'); + } - JSAN.use('circ.util'); - g.cols = circ.util.columns( {} ); - g.col_map = {}; - for (var i = 0; i < g.cols.length; i++) { - g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render }; - } + JSAN.use('circ.util'); + g.cols = circ.util.columns( {} ); + g.col_map = {}; + for (var i = 0; i < g.cols.length; i++) { + g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render }; + } - g.volumes = {}; + g.volumes = {}; - for (var i = 0; i < g.barcodes.length; i++) { - var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] ); - if (typeof copy.ilsevent != 'undefined') throw(copy); - if (!g.volumes[ copy.call_number() ]) { - var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] ); - if (typeof volume.ilsevent != 'undefined') throw(volume); - var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]); - volume.record( record ); - g.volumes[ volume.id() ] = volume; - } - if (g.volumes[ copy.call_number() ].copies()) { - var copies = g.volumes[ copy.call_number() ].copies(); - copies.push( copy ); - g.volumes[ copy.call_number() ].copies( copies ); - } else { - g.volumes[ copy.call_number() ].copies( [ copy ] ); - } - } + for (var i = 0; i < g.barcodes.length; i++) { + var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] ); + if (typeof copy.ilsevent != 'undefined') throw(copy); + if (!g.volumes[ copy.call_number() ]) { + var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] ); + if (typeof volume.ilsevent != 'undefined') throw(volume); + var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]); + volume.record( record ); + g.volumes[ volume.id() ] = volume; + } + if (g.volumes[ copy.call_number() ].copies()) { + var copies = g.volumes[ copy.call_number() ].copies(); + copies.push( copy ); + g.volumes[ copy.call_number() ].copies( copies ); + } else { + g.volumes[ copy.call_number() ].copies( [ copy ] ); + } + } - generate(); + generate(); - if (typeof xulG != 'undefined') $('close').hidden = true; + if (typeof xulG != 'undefined') $('close').hidden = true; - } catch(E) { - try { - g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E); - } catch(F) { - alert('FIXME: ' + js2JSON(E)); - } - } - } + } catch(E) { + try { + g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E); + } catch(F) { + alert('FIXME: ' + js2JSON(E)); + } + } + } - function show_macros() { - JSAN.use('util.functional'); - alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") ); - } + function show_macros() { + JSAN.use('util.functional'); + alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") ); + } - function $(id) { return document.getElementById(id); } + function $(id) { return document.getElementById(id); } - function generate() { - try { - var idx = 0; - JSAN.use('util.text'); JSAN.use('util.money'); - JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false; - var lw = Number($('lw').value) || 8; /* spine label width */ - var ll = Number($('ll').value) || 9; /* spine label length */ - var plw = Number($('plw').value) || 28; /* pocket label width */ - var pll = Number($('pll').value) || 9; /* pocket label length */ - for (var i in g.volumes) { - var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id()); - var ds = document.createElement('description'); vb.appendChild(ds); - ds.appendChild( document.createTextNode( g.volumes[i].label() ) ); - var ds2 = document.createElement('description'); vb.appendChild(ds2); - ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + ( - g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) ); - ds2.setAttribute('style','color: green'); - var hb = document.createElement('hbox'); vb.appendChild(hb); + function generate() { + try { + var idx = 0; + JSAN.use('util.text'); JSAN.use('util.money'); + JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false; + var lw = Number($('lw').value) || 8; /* spine label width */ + var ll = Number($('ll').value) || 9; /* spine label length */ + var plw = Number($('plw').value) || 28; /* pocket label width */ + var pll = Number($('pll').value) || 9; /* pocket label length */ + for (var i in g.volumes) { + var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id()); + var ds = document.createElement('description'); vb.appendChild(ds); + ds.appendChild( document.createTextNode( g.volumes[i].label() ) ); + var ds2 = document.createElement('description'); vb.appendChild(ds2); + ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + ( + g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) ); + ds2.setAttribute('style','color: green'); + var hb = document.createElement('hbox'); vb.appendChild(hb); - var gb = document.createElement('groupbox'); hb.appendChild(gb); - /* take the call number and split it on whitespace */ - var names = String(g.volumes[i].label()).split(/\s+/); - var j = 0; - while (j < ll || j < pll) { - var hb2 = document.createElement('hbox'); gb.appendChild(hb2); - - /* spine */ - if (j < ll) { - var tb = document.createElement('textbox'); hb2.appendChild(tb); - tb.value = ''; + var gb = document.createElement('groupbox'); hb.appendChild(gb); + /* take the call number and split it on whitespace */ + var names = String(g.volumes[i].label()).split(/\s+/); + var j = 0; + while (j < ll || j < pll) { + var hb2 = document.createElement('hbox'); gb.appendChild(hb2); + + /* spine */ + if (j < ll) { + var tb = document.createElement('textbox'); hb2.appendChild(tb); + tb.value = ''; tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: Arial, Helvetica, sans-serif'); tb.setAttribute('font-weight','bold'); - tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw); - tb.setAttribute('name','spine'); - var name = names.shift(); if (name) { - name = String( name ); - /* if the name is greater than the label width... */ - if (name.length > lw) { - /* then try to split it on periods */ - var sname = name.split(/\./); - if (sname.length > 1) { - /* if we can, then put the periods back in on each splitted element */ - if (name.match(/^\./)) sname[0] = '.' + sname[0]; - for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k]; - /* and put all but the first one back into the names array */ - names = sname.slice(1).concat( names ); - /* if the name fragment is still greater than the label width... */ - if (sname[0].length > lw) { - /* then just truncate and throw the rest back into the names array */ - tb.value = sname[0].substr(0,lw); - names = [ sname[0].substr(lw) ].concat( names ); - } else { - /* otherwise we're set */ - tb.value = sname[0]; - } - } else { - /* if we can't split on periods, then just truncate and throw the rest back into the names array */ - tb.value = name.substr(0,lw); - names = [ name.substr(lw) ].concat( names ); - } - } else { - /* otherwise we're set */ - tb.value = name; - } - } - } + tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw); + tb.setAttribute('name','spine'); + var name = names.shift(); if (name) { + name = String( name ); + /* if the name is greater than the label width... */ + if (name.length > lw) { + /* then try to split it on periods */ + var sname = name.split(/\./); + if (sname.length > 1) { + /* if we can, then put the periods back in on each splitted element */ + if (name.match(/^\./)) sname[0] = '.' + sname[0]; + for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k]; + /* and put all but the first one back into the names array */ + names = sname.slice(1).concat( names ); + /* if the name fragment is still greater than the label width... */ + if (sname[0].length > lw) { + /* then just truncate and throw the rest back into the names array */ + tb.value = sname[0].substr(0,lw); + names = [ sname[0].substr(lw) ].concat( names ); + } else { + /* otherwise we're set */ + tb.value = sname[0]; + } + } else { + /* if we can't split on periods, then just truncate and throw the rest back into the names array */ + tb.value = name.substr(0,lw); + names = [ name.substr(lw) ].concat( names ); + } + } else { + /* otherwise we're set */ + tb.value = name; + } + } + } - /* pocket */ - if ($('pl').checked && j < pll) { - var tb2 = document.createElement('textbox'); hb2.appendChild(tb2); - tb2.value = ''; + /* pocket */ + if ($('pl').checked && j < pll) { + var tb2 = document.createElement('textbox'); hb2.appendChild(tb2); + tb2.value = ''; tb2.setAttribute('class','plain'); tb2.setAttribute('style','font-family: Arial, Helvetica, sans-serif'); tb2.setAttribute('font-weight','bold'); - tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw); - tb2.setAttribute('name','pocket'); - if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().title()) { - tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0]; - } else { - tb2.value = ''; - } - } - if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().title()) { - tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw); - } else { - tb2.value = ''; - } - } - if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { - if (g.volumes[i].record().author()) { - tb2.value = g.volumes[i].record().author().substr(0,plw); - } else { - tb2.value = ''; - } - } - if ($('call_number').checked && $('call_number_line').value == j + 1) { - tb2.value = g.volumes[i].label().substr(0,plw); - } - if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) { - var lib = g.volumes[i].owning_lib(); - if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; - tb2.value = lib.shortname().substr(0,plw); - } - if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) { - var lib = g.volumes[i].owning_lib(); - if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; - tb2.value = lib.name().substr(0,plw); - } - if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) { - tb2.value = '%location%'; - } - if ($('barcode').checked && $('barcode_line').value == j + 1) { - tb2.value = '%barcode%'; - } - if ($('custom1').checked && $('custom1_line').value == j + 1) { - tb2.value = $('custom1_tb').value; - } - if ($('custom2').checked && $('custom2_line').value == j + 1) { - tb2.value = $('custom2_tb').value; - } - if ($('custom3').checked && $('custom3_line').value == j + 1) { - tb2.value = $('custom3_tb').value; - } - if ($('custom4').checked && $('custom4_line').value == j + 1) { - tb2.value = $('custom4_tb').value; - } - } + tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw); + tb2.setAttribute('name','pocket'); + if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { + if (g.volumes[i].record().title()) { + tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0]; + } else { + tb2.value = ''; + } + } + if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { + if (g.volumes[i].record().title()) { + tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw); + } else { + tb2.value = ''; + } + } + if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) { + if (g.volumes[i].record().author()) { + tb2.value = g.volumes[i].record().author().substr(0,plw); + } else { + tb2.value = ''; + } + } + if ($('call_number').checked && $('call_number_line').value == j + 1) { + tb2.value = g.volumes[i].label().substr(0,plw); + } + if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) { + var lib = g.volumes[i].owning_lib(); + if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; + tb2.value = lib.shortname().substr(0,plw); + } + if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) { + var lib = g.volumes[i].owning_lib(); + if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ]; + tb2.value = lib.name().substr(0,plw); + } + if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) { + tb2.value = '%location%'; + } + if ($('barcode').checked && $('barcode_line').value == j + 1) { + tb2.value = '%barcode%'; + } + if ($('custom1').checked && $('custom1_line').value == j + 1) { + tb2.value = $('custom1_tb').value; + } + if ($('custom2').checked && $('custom2_line').value == j + 1) { + tb2.value = $('custom2_tb').value; + } + if ($('custom3').checked && $('custom3_line').value == j + 1) { + tb2.value = $('custom3_tb').value; + } + if ($('custom4').checked && $('custom4_line').value == j + 1) { + tb2.value = $('custom4_tb').value; + } + } - j++; - } + j++; + } - idx++; - } - } catch(E) { - g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E); - } - } + idx++; + } + } catch(E) { + g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E); + } + } - function expand_macros(text,copy,volume,record) { - var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record }; - var obj = { 'data' : g.data }; - for (var i in g.col_map) { - var re = g.col_map[i].regex; - if (text.match(re)) { - try { - text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) ); - } catch(E) { - g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E); - } - } - } - return text; - } + function expand_macros(text,copy,volume,record) { + var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record }; + var obj = { 'data' : g.data }; + for (var i in g.col_map) { + var re = g.col_map[i].regex; + if (text.match(re)) { + try { + text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) ); + } catch(E) { + g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E); + } + } + } + return text; + } - function preview(idx) { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var pt = Number( $('pt').value ) || 10; /* font size */ - var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */ - var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */ - var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */ - var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */ - var html = ""; + function preview(idx) { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + var pt = Number( $('pt').value ) || 10; /* font size */ + var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */ + var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */ + var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */ + var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */ + var html = ""; html += "" html += ""; html += "Spine Labels\n"; - var nl = document.getElementsByAttribute('name','template'); - for (var i = 0; i < nl.length; i++) { - if (typeof idx == 'undefined' || idx == null) { } else { - if (idx != i) continue; - } - var volume = g.volumes[ nl[i].getAttribute('acn_id') ]; + var nl = document.getElementsByAttribute('name','template'); + for (var i = 0; i < nl.length; i++) { + if (typeof idx == 'undefined' || idx == null) { } else { + if (idx != i) continue; + } + var volume = g.volumes[ nl[i].getAttribute('acn_id') ]; - for (var j = 0; j < volume.copies().length; j++) { - var copy = volume.copies()[j]; + for (var j = 0; j < volume.copies().length; j++) { + var copy = volume.copies()[j]; if (i == 0) { - html += '
\n';
+                                html += '
\n';
                             } else {
-    							html += '
\n';
+                                html += '
\n';
+                            }
+                            var gb = nl[i].getElementsByTagName('groupbox')[0];
+                            var nl2 = gb.getElementsByAttribute('name','spine');
+                            for (var k = 0; k < nl2.length; k++) {
+                                for (var m = 0; m < lm; m++) html += ' ';
+                                html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
+                                if ($('pl').checked) {
+                                    var sib = nl2[k].nextSibling;
+                                    if (sib) {
+                                        for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
+                                        for (var m = 0; m < mm; m++) html += ' ';
+                                        html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
+                                    }
+                                }
+                                html += '\n';
+                            }
+                            html += '
\n'; + } + } + html += ''; + JSAN.use('util.window'); var win = new util.window(); + var loc = ( urls.XUL_REMOTE_BROWSER ); + //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels'); + var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550'); + w.xulG = { + 'url' : 'about:blank', + 'show_print_button' : 1, + 'alternate_print' : 1, + 'no_xulG' : 1, + 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'), + 'on_url_load' : function(b) { + try { + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + if (typeof w.xulG.written == 'undefined') { + w.xulG.written = true; + w.g.browser.get_content().document.write(html); + w.g.browser.get_content().document.close(); + } + } catch(E) { + alert(E); } - var gb = nl[i].getElementsByTagName('groupbox')[0]; - var nl2 = gb.getElementsByAttribute('name','spine'); - for (var k = 0; k < nl2.length; k++) { - for (var m = 0; m < lm; m++) html += ' '; - html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw)); - if ($('pl').checked) { - var sib = nl2[k].nextSibling; - if (sib) { - for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' '; - for (var m = 0; m < mm; m++) html += ' '; - html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw)); - } - } - html += '\n'; - } - html += '
\n'; - } - } - html += ''; - JSAN.use('util.window'); var win = new util.window(); - var loc = ( urls.XUL_REMOTE_BROWSER ); - //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels'); - var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550'); - w.xulG = { - 'url' : 'about:blank', - 'show_print_button' : 1, - 'alternate_print' : 1, - 'no_xulG' : 1, - 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'), - 'on_url_load' : function(b) { - try { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - if (typeof w.xulG.written == 'undefined') { - w.xulG.written = true; - w.g.browser.get_content().document.write(html); - w.g.browser.get_content().document.close(); - } - } catch(E) { - alert(E); - } - } - }; - } catch(E) { - g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E); - } - } + } + }; + } catch(E) { + g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E); + } + } diff --git a/xul/server/cat/z3950.js b/xul/server/cat/z3950.js deleted file mode 100644 index b1ac1b025b..0000000000 --- a/xul/server/cat/z3950.js +++ /dev/null @@ -1,1059 +0,0 @@ -dump('entering cat.z3950.js\n'); - -function $(id) { return document.getElementById(id); } - -if (typeof cat == 'undefined') cat = {}; -cat.z3950 = function (params) { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - JSAN.use('util.error'); this.error = new util.error(); - JSAN.use('util.network'); this.network = new util.network(); - } catch(E) { - dump('cat.z3950: ' + E + '\n'); - } -} - -cat.z3950.prototype = { - - 'creds_version' : 2, - - 'number_of_result_sets' : 0, - - 'result_set' : [], - - 'limit' : 10, - - 'init' : function( params ) { - - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - JSAN.use('util.widgets'); - - var obj = this; - - JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'}); - - obj.load_creds(); - - JSAN.use('circ.util'); - var columns = circ.util.columns( - { - 'tcn' : { 'hidden' : false }, - 'isbn' : { 'hidden' : false }, - 'title' : { 'hidden' : false, 'flex' : '1' }, - 'author' : { 'hidden' : false }, - 'edition' : { 'hidden' : false }, - 'pubdate' : { 'hidden' : false }, - 'publisher' : { 'hidden' : false }, - 'service' : { 'hidden' : false } - } - ); - - JSAN.use('util.list'); obj.list = new util.list('results'); - obj.list.init( - { - 'columns' : columns, - 'map_row_to_columns' : circ.util.std_map_row_to_columns(), - 'on_select' : function(ev) { - try { - JSAN.use('util.functional'); - var sel = obj.list.retrieve_selection(); - document.getElementById('sel_clip').setAttribute('disabled', sel.length < 1); - var list = util.functional.map_list( - sel, - function(o) { return o.getAttribute('retrieve_id'); } - ); - obj.error.sdump('D_TRACE','cat/z3950: selection list = ' + js2JSON(list) ); - obj.controller.view.marc_import.disabled = false; - obj.controller.view.marc_import.setAttribute('retrieve_id',list[0]); - obj.data.init({'via':'stash'}); - if (obj.data.marked_record) { - obj.controller.view.marc_import_overlay.disabled = false; - } else { - obj.controller.view.marc_import_overlay.disabled = true; - } - obj.controller.view.marc_import_overlay.setAttribute('retrieve_id',list[0]); - obj.controller.view.marc_view_btn.disabled = false; - obj.controller.view.marc_view_btn.setAttribute('retrieve_id',list[0]); - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_list_init.list_construction_error'),E); - } - }, - } - ); - - JSAN.use('util.controller'); obj.controller = new util.controller(); - obj.controller.init( - { - control_map : { - 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ], - 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ], - 'cmd_z3950_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ], - 'cmd_z3950_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ], - 'cmd_z3950_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'z3950_results.txt' } ); } ], - 'cmd_broken' : [ - ['command'], - function() { alert('Not Yet Implemented'); } - ], - 'result_message' : [['render'],function(e){return function(){};}], - 'clear' : [ - ['command'], - function() { - obj.clear(); - } - ], - 'save_creds' : [ - ['command'], - function() { - obj.save_creds(); - setTimeout( function() { obj.focus(); }, 0 ); - } - ], - 'marc_view_btn' : [ - ['render'], - function(e) { - e.setAttribute('label', $("catStrings").getString('staff.cat.z3950.marc_view.label')); - e.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.marc_view.accesskey')); - } - ], - 'marc_view' : [ - ['command'], - function(ev) { - try { - var n = obj.controller.view.marc_view_btn; - if (n.getAttribute('toggle') == '1') { - document.getElementById('deck').selectedIndex = 0; - n.setAttribute('toggle','0'); - n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.marc_view.label')); - n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.marc_view.accesskey')); - document.getElementById('results').focus(); - } else { - document.getElementById('deck').selectedIndex = 1; - n.setAttribute('toggle','1'); - n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.results_view.label')); - n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.results_view.accesskey')); - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - var f = get_contentWindow(document.getElementById('marc_frame')); - var retrieve_id = n.getAttribute('retrieve_id'); - var result_idx = retrieve_id.split('-')[0]; - var record_idx = retrieve_id.split('-')[1]; - f.xulG = { 'marcxml' : obj.result_set[result_idx].records[ record_idx ].marcxml }; - f.my_init(); - f.document.body.firstChild.focus(); - } - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_view_error'),E); - } - }, - ], - 'marc_import' : [ - ['command'], - function() { - try { - var retrieve_id = obj.controller.view.marc_import.getAttribute('retrieve_id'); - var result_idx = retrieve_id.split('-')[0]; - var record_idx = retrieve_id.split('-')[1]; - obj.spawn_marc_editor( - obj.result_set[ result_idx ].records[ record_idx ].marcxml, - obj.result_set[ result_idx ].records[ record_idx ].service /* FIXME: we want biblio_source here */ - ); - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_error'),E); - } - }, - ], - 'marc_import_overlay' : [ - ['command'], - function() { - try { - var retrieve_id = obj.controller.view.marc_import_overlay.getAttribute('retrieve_id'); - var result_idx = retrieve_id.split('-')[0]; - var record_idx = retrieve_id.split('-')[1]; - obj.spawn_marc_editor_for_overlay( - obj.result_set[ result_idx ].records[ record_idx ].marcxml, - obj.result_set[ result_idx ].records[ record_idx ].service /* FIXME: we want biblio_source here */ - ); - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_overlay_error'),E); - } - }, - ], - 'search' : [ - ['command'], - function() { - obj.initial_search(); - }, - ], - 'raw_search' : [ - ['command'], - function() { - var raw = window.prompt( - $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.msg'), - $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.default_value'), - $("catStrings").getString('staff.cat.z3950.initial_search.raw_prompt.title') - ); - if (raw) obj.initial_raw_search(raw); - } - ], - 'page_next' : [ - ['command'], - function() { - obj.page_next(); - }, - ], - 'toggle_form_btn' : [ - ['render'], - function(e) { - e.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif"); - e.setAttribute('label',$("catStrings").getString('staff.cat.z3950.hide_top_pane.label')); - e.setAttribute('accesskey',$("catStrings").getString('staff.cat.z3950.hide_top_pane.accesskey')); - } - ], - 'toggle_form' : [ - ['command'], - function() { - var x = document.getElementById('top_pane'); - document.getElementById('splitter_grippy2').doCommand(); - var n = obj.controller.view.toggle_form_btn; - if (x.collapsed) { - n.setAttribute('image',"/xul/server/skin/media/images/down_arrow.gif"); - n.setAttribute('label',$("catStrings").getString('staff.cat.z3950.unhide_top_pane.label')); - n.setAttribute('accesskey',$("catStrings").getString('staff.cat.z3950.unhide_top_pane.accesskey')); - } else { - n.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif"); - n.setAttribute('label',$("catStrings").getString('staff.cat.z3950.hide_top_pane.label')); - n.setAttribute('accesskey',$("catStrings").getString('staff.cat.z3950.hide_top_pane.accesskey')); - } - }, - ], - 'splitter_grippy2' : [ - ['click'], - function() { - var x = document.getElementById('top_pane'); - var n = obj.controller.view.toggle_form_btn; - if (x.collapsed) { - n.setAttribute('image',"/xul/server/skin/media/images/down_arrow.gif"); - n.setAttribute('label',$("catStrings").getString('staff.cat.z3950.unhide_top_pane.label')); - n.setAttribute('accesskey',$("catStrings").getString('staff.cat.z3950.unhide_top_pane.accesskey')); - } else { - n.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif"); - n.setAttribute('label',$("catStrings").getString('staff.cat.z3950.hide_top_pane.label')); - n.setAttribute('accesskey',$("catStrings").getString('staff.cat.z3950.hide_top_pane.accesskey')); - } - } - ], - 'service_rows' : [ - ['render'], - function(e) { - return function() { - try { - - function handle_switch(node) { - try { - $('search').setAttribute('disabled','true'); $('raw_search').setAttribute('disabled','true'); - obj.active_services = []; - var snl = document.getElementsByAttribute('mytype','service_class'); - for (var i = 0; i < snl.length; i++) { - var n = snl[i]; - if (n.nodeName == 'checkbox') { - if (n.checked) obj.active_services.push( n.getAttribute('service') ); - } - } - if (obj.active_services.length > 0) { - $('search').setAttribute('disabled','false'); - } - if (obj.active_services.length == 1) { - if (obj.active_services[0] != 'native-evergreen-catalog') { - $('raw_search').setAttribute('disabled','false'); - } - } - var nl = document.getElementsByAttribute('mytype','search_class'); - for (var i = 0; i < nl.length; i++) { nl[i].disabled = true; } - var attrs = {}; - for (var j = 0; j < obj.active_services.length; j++) { - if (obj.services[obj.active_services[j]]) for (var i in obj.services[obj.active_services[j]].attrs) { - var attr = obj.services[obj.active_services[j]].attrs[i]; - if (! attrs[i]) { - attrs[i] = { 'labels' : {} }; - } - if (attr.label) { - attrs[i].labels[ attr.label ] = true; - } else if (document.getElementById('commonStrings').testString('staff.z39_50.search_class.' + i)) { - attrs[i].labels[ document.getElementById('commonStrings').getString('staff.z39_50.search_class.' + i) ] = true; - } else if (attr.name) { - attrs[i].labels[ attr.name ] = true; - } else { - attrs[i].labels[ i ] = true; - } - - } - - } - - function set_label(x,attr) { - var labels = []; - for (var j in attrs[attr].labels) { - labels.push(j); - } - if (labels.length > 0) { - x.setAttribute('value',labels[0]); - x.setAttribute('tooltiptext',labels.join(',')); - if (labels.length > 1) x.setAttribute('class','multiple_labels'); - } - } - - for (var i in attrs) { - var x = document.getElementById(i + '_input'); - if (x) { - x.disabled = false; - var y = document.getElementById(i + '_label',i); - if (y) set_label(y,i); - } else { - var rows = document.getElementById('query_inputs'); - var row = document.createElement('row'); rows.appendChild(row); - var label = document.createElement('label'); - label.setAttribute('id',i+'_label'); - label.setAttribute('control',i+'_input'); - label.setAttribute('search_class',i); - label.setAttribute('style','-moz-user-focus: ignore'); - row.appendChild(label); - set_label(label,i); - label.addEventListener('click',function(ev){ - var a = ev.target.getAttribute('search_class'); - if (a) obj.default_attr = a; - },false - ); - var tb = document.createElement('textbox'); - tb.setAttribute('id',i+'_input'); - tb.setAttribute('mytype','search_class'); - tb.setAttribute('search_class',i); - row.appendChild(tb); - tb.addEventListener('keypress',function(ev) { return obj.handle_enter(ev); },false); - } - } - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.search_fields_error'),E); - } - } - - document.getElementById('native-evergreen-catalog_service').addEventListener('command',handle_switch,false); - - var robj = obj.network.simple_request( - 'RETRIEVE_Z3950_SERVICES', - [ ses() ] - ); - if (typeof robj.ilsevent != 'undefined') throw(robj); - obj.services = robj; - var x = document.getElementById('service_rows'); - var services = new Array(); - for (var i in obj.services) { - var label; - if (obj.services[i].label) { - label = obj.services[i].label; - } else if (obj.services[i].name) { - label = obj.services[i].name; - } else { - label = i; - } - var j = [label, i]; - services.push(j); - } - services.sort(); - for (var j=0; j < services.length; j++) { - var i = services[j][1]; - try { - if (i == 'native-evergreen-catalog') continue; - var r = document.createElement('row'); x.appendChild(r); - var cb = document.createElement('checkbox'); - cb.setAttribute('label',services[j][0]); - cb.setAttribute('tooltiptext',i + ' : ' + obj.services[i].db + '@' + obj.services[i].host + ':' + obj.services[i].port); - cb.setAttribute('mytype','service_class'); cb.setAttribute('service',i); - cb.setAttribute('id',i+'_service'); r.appendChild(cb); - cb.addEventListener('command',handle_switch,false); - var username = document.createElement('textbox'); username.setAttribute('id',i+'_username'); - if (obj.creds.hosts[ obj.data.server_unadorned ] && obj.creds.hosts[ obj.data.server_unadorned ].services[i]) username.setAttribute('value',obj.creds.hosts[ obj.data.server_unadorned ].services[i].username); - r.appendChild(username); - if (typeof obj.services[i].auth != 'undefined') username.hidden = ! get_bool( obj.services[i].auth ); - var password = document.createElement('textbox'); password.setAttribute('id',i+'_password'); - if (obj.creds.hosts[ obj.data.server_unadorned ] && obj.creds.hosts[ obj.data.server_unadorned ].services[i]) password.setAttribute('value',obj.creds.hosts[ obj.data.server_unadorned ].services[i].password); - password.setAttribute('type','password'); r.appendChild(password); - if (typeof obj.services[i].auth != 'undefined') password.hidden = ! get_bool( obj.services[i].auth ); - } catch(E) { - alert(E); - } - } - //obj.services[ 'native-evergreen-catalog' ] = { 'attrs' : { 'author' : {}, 'title' : {} } }; - setTimeout( - function() { - if (obj.creds.hosts[ obj.data.server_unadorned ]) { - for (var i = 0; i < obj.creds.hosts[ obj.data.server_unadorned ].default_services.length; i++) { - var x = document.getElementById(obj.creds.hosts[ obj.data.server_unadorned ].default_services[i]+'_service'); - if (x) x.checked = true; - } - } else if (obj.creds.default_service) { - var x = document.getElementById(obj.creds.default_service+'_service'); - if (x) x.checked = true; - } - handle_switch(); - },0 - ); - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.z39_service_error'),E); - } - } - } - ], - } - } - ); - - obj.controller.render(); - - setTimeout( function() { obj.focus(); }, 0 ); - - setInterval( - function() { - obj.data.init({'via':'stash'}); - if (obj.data.marked_record) { - var sel = obj.list.retrieve_selection(); - if (sel.length > 0) { obj.controller.view.marc_import_overlay.disabled = false; } - if ($("overlay_tcn_indicator")) { - if (obj.data.marked_record_mvr) { - $("overlay_tcn_indicator").setAttribute('value',$("catStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[obj.data.marked_record_mvr.tcn()])); - } else { - $("overlay_tcn_indicator").setAttribute('value',$("catStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[obj.data.marked_record])); - } - } - } else { - obj.controller.view.marc_import_overlay.disabled = true; - if ($("overlay_tcn_indicator")) { - $("overlay_tcn_indicator").setAttribute('value',$("catStrings").getString('staff.cat.z3950.marked_record_for_overlay_indicator.no_record.label')); - } - } - }, 2000 - ); - - } catch(E) { - this.error.sdump('D_ERROR','cat.z3950.init: ' + E + '\n'); - } - }, - - 'focus' : function() { - var obj = this; - var focus_me; var or_focus_me; - for (var i = 0; i < obj.active_services.length; i++) { - if (obj.creds.hosts[ obj.data.server_unadorned ] && obj.creds.hosts[ obj.data.server_unadorned ].services[ obj.active_services[i] ]) { - var x = obj.creds.hosts[ obj.data.server_unadorned ].services[ obj.active_services[i] ].default_attr; - if (x) { focus_me = x; break; } - } - if (obj.services[ obj.active_services[i] ]) for (var i in obj.services[ obj.active_services[i] ].attr) { or_focus_me = i; } - } - if (! focus_me) focus_me = or_focus_me; - var xx = document.getElementById(focus_me+'_input'); if (xx) xx.focus(); - }, - - 'clear' : function() { - var obj = this; - var nl = document.getElementsByAttribute('mytype','search_class'); - for (var i = 0; i < nl.length; i++) { nl[i].value = ''; nl[i].setAttribute('value',''); } - obj.focus(); - }, - - 'search_params' : {}, - - 'initial_search' : function() { - try { - var obj = this; - obj.result_set = []; obj.number_of_result_sets = 0; - JSAN.use('util.widgets'); - util.widgets.remove_children( obj.controller.view.result_message ); - var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - if (obj.active_services.length < 1) { - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection'))); - return; - } - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching'))); - obj.search_params = {}; obj.list.clear(); - obj.controller.view.page_next.disabled = true; - obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true'); - obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true'); - obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true'); - - obj.search_params.service_array = []; - obj.search_params.username_array = []; - obj.search_params.password_array = []; - for (var i = 0; i < obj.active_services.length; i++) { - obj.search_params.service_array.push( obj.active_services[i] ); - obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value ); - obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value ); - } - obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length ); - obj.search_params.offset = 0; - - obj.search_params.search = {}; - var nl = document.getElementsByAttribute('mytype','search_class'); - var count = 0; - for (var i = 0; i < nl.length; i++) { - if (nl[i].disabled) continue; - if (nl[i].value == '') continue; - count++; - obj.search_params.search[ nl[i].getAttribute('search_class') ] = nl[i].value; - } - if (count>0) { - obj.search(); - } else { - util.widgets.remove_children( obj.controller.view.result_message ); - } - } catch(E) { - this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E); - } - }, - - 'initial_raw_search' : function(raw) { - try { - var obj = this; - obj.result_set = []; obj.number_of_result_sets = 0; - JSAN.use('util.widgets'); - util.widgets.remove_children( obj.controller.view.result_message ); - var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - if (obj.active_services.length < 1) { - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection'))); - return; - } - if (obj.active_services.length > 1) { - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.too_many_selections'))); - return; - } - if (obj.active_services[0] == 'native-evergreen-catalog') { - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.raw_search_unsupported_for_native_catalog'))); - return; - } - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching'))); - obj.search_params = {}; obj.list.clear(); - obj.controller.view.page_next.disabled = true; - obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true'); - obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true'); - obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true'); - - obj.search_params.service_array = []; - obj.search_params.username_array = []; - obj.search_params.password_array = []; - for (var i = 0; i < obj.active_services.length; i++) { - obj.search_params.service_array.push( obj.active_services[i] ); - obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value ); - obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value ); - } - obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length ); - obj.search_params.offset = 0; - - obj.search_params.query = raw; - - obj.search(); - } catch(E) { - this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E); - } - }, - - 'page_next' : function() { - try { - var obj = this; - JSAN.use('util.widgets'); - util.widgets.remove_children( obj.controller.view.result_message ); - var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.page_next.more_results'))); - obj.search_params.offset += obj.search_params.limit; - obj.search(); - } catch(E) { - this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.page_next.subsequent_search_error'),E); - } - }, - - 'search' : function() { - try { - var obj = this; - var method; - if (typeof obj.search_params.query == 'undefined') { - method = 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH'; - obj.search_params.service = obj.search_params.service_array; - obj.search_params.username = obj.search_params.username_array; - obj.search_params.password = obj.search_params.password_array; - } else { - method = 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH'; - obj.search_params.service = obj.search_params.service_array[0]; - obj.search_params.username = obj.search_params.username_array[0]; - obj.search_params.password = obj.search_params.password_array[0]; - } - obj.network.simple_request( - method, - [ ses(), obj.search_params ], - function(req) { - obj.handle_results(req.getResultObject()) - } - ); - document.getElementById('deck').selectedIndex = 0; - } catch(E) { - this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.search.search_error'),E); - } - }, - - 'handle_results' : function(results) { - var obj = this; - try { - JSAN.use('util.widgets'); - util.widgets.remove_children( obj.controller.view.result_message ); var x; - if (results == null) { - x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.handle_results.null_server_error'))); - return; - } - if (typeof results.ilsevent != 'undefined') { - x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - x.appendChild( document.createTextNode($("catStrings").getFormattedString('staff.cat.z3950.handle_results.server_error', [results.textcode, results.desc]))); - return; - } - obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','false'); - obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','false'); - obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','false'); - if (typeof results.length == 'undefined') results = [ results ]; - - var total_showing = 0; - var total_count = 0; - var tooltip_msg = ''; - - for (var i = 0; i < results.length; i++) { - if (results[i].query) { - tooltip_msg += $("catStrings").getFormattedString('staff.cat.z3950.handle_results.raw_query', [results[i].query]) + '\n'; - } - if (results[i].count) { - if (results[i].records) { - var showing = obj.search_params.offset + results[i].records.length; - total_showing += obj.search_params.offset + results[i].records.length; - total_count += results[i].count; - tooltip_msg += $("catStrings").getFormattedString('staff.cat.z3950.handle_results.showing_results', [(showing > results[i].count ? results[i].count : showing), results[i].count, results[i].service]) + '\n'; - } - if (obj.search_params.offset + obj.search_params.limit <= results[i].count) { - obj.controller.view.page_next.disabled = false; - } - } else { - tooltip_msg += $("catStrings").getFormattedString('staff.cat.z3950.handle_results.num_of_results', [(results[i].count ? results[i].count : 0)]) + '\n'; - } - if (results[i].records) { - obj.result_set[ ++obj.number_of_result_sets ] = results[i]; - obj.controller.view.marc_import.disabled = true; - obj.controller.view.marc_import_overlay.disabled = true; - var x = obj.controller.view.marc_view_btn; - if (x.getAttribute('toggle') == '0') x.disabled = true; - for (var j = 0; j < obj.result_set[ obj.number_of_result_sets ].records.length; j++) { - var f; - var n = obj.list.append( - { - 'retrieve_id' : String( obj.number_of_result_sets ) + '-' + String( j ), - 'row' : { - 'my' : { - 'mvr' : function(a){return a;}(obj.result_set[ obj.number_of_result_sets ].records[j].mvr), - 'service' : results[i].service - } - } - } - ); - if (!f) { n.my_node.parentNode.focus(); f = n; } - } - } else { - x = document.createElement('description'); obj.controller.view.result_message.appendChild(x); - x.appendChild( - document.createTextNode($("catStrings").getString('staff.cat.z3950.handle_results.result_error')) - ); - } - } - if (total_showing) { - x = document.createElement('description'); - x.setAttribute('crop','end'); - x.setAttribute('tooltiptext',tooltip_msg); - obj.controller.view.result_message.appendChild(x); - x.appendChild( - document.createTextNode($("catStrings").getFormattedString('staff.cat.z3950.handle_results.showing_total_results', - [(total_showing > total_count ? total_count : total_showing), total_count])) - ); - } else { - x = document.createElement('description'); - x.setAttribute('crop','end'); - x.setAttribute('tooltiptext',tooltip_msg); - obj.controller.view.result_message.appendChild(x); - x.appendChild( - document.createTextNode($("catStrings").getFormattedString('staff.cat.z3950.handle_results.num_of_results', [(total_count ? total_count : 0)])) - ); - } - - } catch(E) { - this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.handle_results.search_result_error'),E); - } - }, - - 'replace_tab_with_opac' : function(doc_id) { - var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id; - var content_params = { - 'session' : ses(), - 'authtime' : ses('authtime'), - 'opac_url' : opac_url, - }; - xulG.set_tab( - xulG.url_prefix(urls.XUL_OPAC_WRAPPER), - {'tab_name': $("catStrings").getString('staff.cat.z3950.replace_tab_with_opac.tab_name')}, - content_params - ); - }, - - 'spawn_marc_editor' : function(my_marcxml,biblio_source) { - var obj = this; - xulG.new_tab( - xulG.url_prefix(urls.XUL_MARC_EDIT), - { 'tab_name' : 'MARC Editor' }, - { - 'record' : { 'marc' : my_marcxml }, - 'fast_add_item' : function(doc_id,cn_label,cp_barcode) { - try { - JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode); - } catch(E) { - alert(E); - } - }, - 'save' : { - 'label' : 'Import Record', - 'func' : function (new_marcxml) { - try { - var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]); - if (typeof r.ilsevent != 'undefined') { - switch(Number(r.ilsevent)) { - case 1704 /* TCN_EXISTS */ : - var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.same_tcn', [r.payload.tcn]); - var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.title'); - var btn1 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn1_overlay'); - var btn2 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.btn2_import', [r.payload.new_tcn]); - if (btn2) { - obj.data.init({'via':'stash'}); - var robj = obj.network.simple_request( - 'PERM_CHECK',[ - ses(), - obj.data.list.au[0].id(), - obj.data.list.au[0].ws_ou(), - [ 'ALLOW_ALT_TCN' ] - ] - ); - if (typeof robj.ilsevent != 'undefined') { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.permission_error'),E); - } - if (robj.length != 0) btn2 = null; - } - var btn3 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn3_cancel_import'); - var p = obj.error.yns_alert(msg,title,btn1,btn2,btn3,$("catStrings").getString('staff.cat.z3950.spawn_marc_editor.confirm_action')); - obj.error.sdump('D_ERROR','option ' + p + 'chosen'); - switch(p) { - case 0: - var r3 = obj.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), r.payload.dup_record, new_marcxml, biblio_source ]); - if (typeof r3.ilsevent != 'undefined') { - throw(r3); - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_overlay')); - return { - 'id' : r3.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r3.id()); - } catch(E) { - alert(E); - } - } - }; - } - break; - case 1: - var r2 = obj.network.request( - api.MARC_XML_RECORD_IMPORT.app, - api.MARC_XML_RECORD_IMPORT.method + '.override', - [ ses(), new_marcxml, biblio_source ] - ); - if (typeof r2.ilsevent != 'undefined') { - throw(r2); - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import_with_new_tcn')); - return { - 'id' : r2.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r2.id()); - } catch(E) { - alert(E); - } - } - }; - } - break; - case 2: - default: - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_cancelled')); - break; - } - break; - default: - throw(r); - break; - } - } else { - alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import')); - return { - 'id' : r.id(), - 'on_complete' : function() { - try { - obj.replace_tab_with_opac(r.id()); - } catch(E) { - alert(E); - } - } - }; - } - } catch(E) { - obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_error'),E); - } - } - } - } - ); - }, - - 'confirm_overlay' : function(record_ids) { - var obj = this; // JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite'); - var top_xml = ''; - top_xml += ''+$("catStrings").getString('staff.cat.z3950.confirm_overlay.description')+''; - top_xml += '