]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/spine_labels.js
35d5d28cdefecb0055573a3ae8a918042342d04a
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / cat / spine_labels.js
1         function my_init() {
2             try {
3                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
4                 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
5                 JSAN.errorLevel = "die"; // none, warn, or die
6                 JSAN.addRepository('/xul/server/');
7                 JSAN.use('util.error'); g.error = new util.error();
8                 g.error.sdump('D_TRACE','my_init() for spine_labels.xul');
9
10                 JSAN.use('util.network'); g.network = new util.network();
11
12                 g.cgi = new CGI();
13
14                 g.barcodes = [];
15                 if (g.cgi.param('barcodes')) {
16                     g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) );
17                 }
18                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
19                 if (g.data.temp_barcodes_for_labels) {
20                     g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels );
21                     g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels');
22                 }
23                 if (xulG.barcodes) {
24                     g.barcodes = g.barcodes.concat( xulG.barcodes );
25                 }
26
27                 JSAN.use('circ.util');
28                 g.cols = circ.util.columns( {} );
29                 g.col_map = {};
30                 for (var i = 0; i < g.cols.length; i++) {
31                     g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render };
32                 }
33
34                 g.volumes = {};
35
36                 for (var i = 0; i < g.barcodes.length; i++) {
37                     var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
38                     if (typeof copy.ilsevent != 'undefined') throw(copy);
39                     var label_prefix = copy.location().label_prefix() || '';
40                     var label_suffix = copy.location().label_suffix() || '';
41                     if (!g.volumes[ copy.call_number() ]) {
42                         var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
43                         if (typeof volume.ilsevent != 'undefined') throw(volume);
44                         var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
45                         volume.record( record );
46
47                         /* Jam the prefixes and suffixes into the volume object */
48                         volume.prefix = label_prefix;
49                         volume.suffix = label_suffix;
50
51                         g.volumes[ volume.id() ] = volume;
52                     }
53                     if (g.volumes[ copy.call_number() ].copies()) {
54                         var copies = g.volumes[ copy.call_number() ].copies();
55                         copies.push( copy );
56                         g.volumes[ copy.call_number() ].copies( copies );
57                     } else {
58                         g.volumes[ copy.call_number() ].copies( [ copy ] );
59                     }
60                 }
61
62                 generate();
63
64                 if (typeof xulG != 'undefined') $('close').hidden = true;
65
66             } catch(E) {
67                 try {
68                     g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E);
69                 } catch(F) {
70                     alert('FIXME: ' + js2JSON(E));
71                 }
72             }
73         }
74
75         function show_macros() {
76             JSAN.use('util.functional');
77             alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") );
78         }
79
80         function $(id) { return dojo.byId(id); }
81
82         function generate(override) {
83             try {
84                 var idx = 0;
85                 JSAN.use('util.text');
86                 JSAN.use('util.money');
87                 JSAN.use('util.widgets');
88                 var pn = $('panel');
89                 $('preview').disabled = false;
90
91                 /* Grab from OU settings, then fall back to hardcoded defaults */
92                 var label_cfg = {};
93                 label_cfg.spine_width = Number($('lw').value); /* spine label width */
94                 if (!label_cfg.spine_width) {
95                     label_cfg.spine_width = g.data.hash.aous['cat.spine.line.width'] || 8;
96                     $('lw').value = label_cfg.spine_width;
97                 }
98                 label_cfg.spine_length = Number($('ll').value); /* spine label length */
99                 if (!label_cfg.spine_length) {
100                     label_cfg.spine_length = g.data.hash.aous['cat.spine.line.height'] || 9;
101                     $('ll').value = label_cfg.spine_length;
102                 }
103                 label_cfg.spine_left_margin = Number($('lm').value); /* left margin */
104                 if (!label_cfg.spine_left_margin) {
105                     label_cfg.spine_left_margin = g.data.hash.aous['cat.spine.line.margin'] || 0;
106                     $('lm').value = label_cfg.spine_left_margin;
107                 }
108                 label_cfg.font_size = Number( $('pt').value );  /* font size */
109                 if (!label_cfg.font_size) {
110                     label_cfg.font_size = g.data.hash.aous['cat.label.font.size'] || 10;
111                     $('pt').value = label_cfg.font_size;
112                 }
113                 label_cfg.font_weight = $('font_weight').value;  /* font weight */
114                 if (!label_cfg.font_weight) {
115                     label_cfg.font_weight = g.data.hash.aous['cat.label.font.weight'] || 'normal';
116                     $('font_weight').value = label_cfg.font_weight;
117                 }
118                 label_cfg.font_family = g.data.hash.aous['cat.label.font.family'] || 'monospace';
119                 label_cfg.pocket_width = Number($('plw').value) || 28; /* pocket label width */
120                 label_cfg.pocket_length = Number($('pll').value) || 9; /* pocket label length */
121
122                 if (override) {
123                     var gb = $('acn_' + g.volumes[override.acn].id());
124                     util.widgets.remove_children('acn_' + g.volumes[override.acn].id());
125                     generate_labels(g.volumes[override.acn], gb, label_cfg, override);
126                 } else {
127                     util.widgets.remove_children('panel');
128                     for (var i in g.volumes) {
129                         var vb = document.createElement('vbox'); pn.appendChild(vb);
130                         vb.setAttribute('name','template');
131                         vb.setAttribute('acn_id',g.volumes[i].id());
132                         var ds = document.createElement('description'); vb.appendChild(ds);
133                         ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
134                         var ds2 = document.createElement('description'); vb.appendChild(ds2);
135                         ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + ' ' + (
136                             g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) );
137                         ds2.setAttribute('style','color: green');
138                         var hb = document.createElement('hbox'); vb.appendChild(hb);
139
140                         var gb = document.createElement('groupbox');
141                         hb.appendChild(gb); 
142                         gb.setAttribute('id','acn_' + g.volumes[i].id());
143                         gb.setAttribute('style','border: solid black 2px');
144
145                         generate_labels(g.volumes[i], gb, label_cfg, override);
146
147                         idx++;
148                     }
149                 }
150             } catch(E) {
151                 g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E);
152             }
153         }
154
155         function generate_labels(volume, label_node, label_cfg, override) {
156             var names;
157             var callnum;
158
159             if (override && volume.id() == override.acn) {
160                 /* If we're calling ourself, we'll have an altered label */
161                 callnum = String(override.label);
162             } else {
163                 /* take the call number and split it on whitespace */
164                 callnum = String(volume.label());
165             }
166
167             /* for LC, split between classification subclass letters and numbers */
168             var lc_class_re = /^([A-Z]{1,3})([0-9]+.*?)$/i;
169             var lc_class_match = lc_class_re.exec(callnum);
170             if (lc_class_match && lc_class_match.length > 1) {
171                 callnum = lc_class_match[1] + ' ' + lc_class_match[2];
172             }
173
174             /* for LC, split between Cutter numbers */
175             var lc_cutter_re = /^(.*)(\.[A-Z]{1}[0-9]+.*?)$/ig;
176             var lc_cutter_match = lc_cutter_re.exec(callnum);
177             if (lc_cutter_match && lc_cutter_match.length > 1) {
178                 callnum = '';
179                 for (var i = 1; i < lc_cutter_match.length; i++) {
180                     callnum += lc_cutter_match[i] + ' ';
181                 }
182             }
183
184             /* Only add the prefixes and suffixes once */
185             if (!override || volume.id() != override.acn) {
186                 if (volume.prefix) {
187                     callnum = volume.prefix + ' ' + callnum;
188                 }
189                 if (volume.suffix) {
190                     callnum += ' ' + volume.suffix;
191                 }
192             }
193
194             names = callnum.split(/\s+/);
195             var j = 0;
196             while (j < label_cfg.spine_length || j < label_cfg.pocket_length) {
197                 var hb2 = document.createElement('hbox'); label_node.appendChild(hb2);
198                 
199                 /* spine */
200                 if (j < label_cfg.spine_length) {
201                     var tb = document.createElement('textbox'); hb2.appendChild(tb); 
202                     tb.value = '';
203                     tb.setAttribute('class','plain');
204                     tb.setAttribute('style',
205                         'font-family: ' + label_cfg.font_family
206                         + '; font-size: ' + label_cfg.font_size
207                         + '; font-weight: ' + label_cfg.font_weight
208                     );
209                     tb.setAttribute('size',label_cfg.spine_width+1);
210                     tb.setAttribute('maxlength',label_cfg.spine_width);
211                     tb.setAttribute('name','spine');
212                     var spine_row_id = 'acn_' + volume.id() + '_spine_' + j;
213                     tb.setAttribute('id',spine_row_id);
214
215                     var name = names.shift();
216                     if (name) {
217                         name = String( name );
218
219                         /* if the name is greater than the label width... */
220                         if (name.length > label_cfg.spine_width) {
221                             /* then try to split it on periods */
222                             var sname = name.split(/\./);
223                             if (sname.length > 1) {
224                                 /* if we can, then put the periods back in on each splitted element */
225                                 if (name.match(/^\./)) sname[0] = '.' + sname[0];
226                                 for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
227                                 /* and put all but the first one back into the names array */
228                                 names = sname.slice(1).concat( names );
229                                 /* if the name fragment is still greater than the label width... */
230                                 if (sname[0].length > label_cfg.spine_width) {
231                                     /* then just truncate and throw the rest back into the names array */
232                                     tb.value = sname[0].substr(0,label_cfg.spine_width);
233                                     names = [ sname[0].substr(label_cfg.spine_width) ].concat( names );
234                                 } else {
235                                     /* otherwise we're set */
236                                     tb.value = sname[0];
237                                 }
238                             } else {
239                                 /* if we can't split on periods, then just truncate and throw the rest back into the names array */
240                                 tb.value = name.substr(0,label_cfg.spine_width);
241                                 names = [ name.substr(label_cfg.spine_width) ].concat( names );
242                             }
243                         } else {
244                             /* otherwise we're set */
245                             tb.value = name;
246                         }
247                     }
248                     dojo.connect($(spine_row_id), 'onkeypress', 'spine_label_key_events');
249                 }
250
251                 /* pocket */
252                 if ($('pl').checked && j < label_cfg.pocket_length) {
253                     var tb2 = document.createElement('textbox'); hb2.appendChild(tb2); 
254                     tb2.value = '';
255                     tb2.setAttribute('class','plain');
256                     tb2.setAttribute('style',
257                         'font-family: ' + label_cfg.font_family
258                         + '; font-size: ' + label_cfg.font_size
259                         + '; font-weight: ' + label_cfg.font_weight
260                     );
261                     tb2.setAttribute('size',label_cfg.pocket_width+1); tb2.setAttribute('maxlength',label_cfg.pocket_width);
262                     tb2.setAttribute('name','pocket');
263                     if ($('title').checked && $('title_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
264                         if (volume.record().title()) {
265                             tb2.value = util.text.wrap_on_space( volume.record().title(), label_cfg.pocket_width )[0];
266                         } else {
267                             tb2.value = '';
268                         }
269                     }
270                     if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
271                         if (volume.record().title()) {
272                             tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( volume.record().title(), label_cfg.pocket_width )[1]).substr(0,label_cfg.pocket_width);
273                         } else {
274                             tb2.value = '';
275                         }
276                     }
277                     if ($('author').checked && $('author_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
278                         if (volume.record().author()) {
279                             tb2.value = volume.record().author().substr(0,label_cfg.pocket_width);
280                         } else {
281                             tb2.value = '';
282                         }
283                     }
284                     if ($('call_number').checked && $('call_number_line').value == j + 1) {
285                         tb2.value = volume.label().substr(0,label_cfg.pocket_width);
286                     }
287                     if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) {
288                         var lib = volume.owning_lib();
289                         if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
290                         tb2.value = lib.shortname().substr(0,label_cfg.pocket_width);
291                     }
292                     if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) {
293                         var lib = volume.owning_lib();
294                         if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
295                         tb2.value = lib.name().substr(0,label_cfg.pocket_width);
296                     }
297                     if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) {
298                         tb2.value = '%location%';
299                     }
300                     if ($('barcode').checked && $('barcode_line').value == j + 1) {
301                         tb2.value = '%barcode%';
302                     }
303                     if ($('custom1').checked && $('custom1_line').value == j + 1) {
304                         tb2.value = $('custom1_tb').value;
305                     }
306                     if ($('custom2').checked && $('custom2_line').value == j + 1) {
307                         tb2.value = $('custom2_tb').value;
308                     }
309                     if ($('custom3').checked && $('custom3_line').value == j + 1) {
310                         tb2.value = $('custom3_tb').value;
311                     }
312                     if ($('custom4').checked && $('custom4_line').value == j + 1) {
313                         tb2.value = $('custom4_tb').value;
314                     }
315                 }
316
317                 j++;
318             }
319         }
320
321         function spine_label_key_events (event) {
322
323             /* Current value of the inpux box */
324             var line_value = event.target.value;
325
326             /* Cursor positions */
327             var sel_start = event.target.selectionStart;
328             var sel_end = event.target.selectionEnd;
329
330             /* Identifiers for this row: "acn_ID_spine_ROW" */
331             var atts = event.target.id.split('_');
332             var row_id = {
333                 "acn": atts[1],
334                 "spine": atts[3],
335                 "prefix": 'acn_' + atts[1] + '_spine_'
336             };
337
338             switch (event.charOrCode) {
339                 case dojo.keys.ENTER : {
340                     /* Create a new row by inserting a space at the
341                      * current cursor point, then regenerating the
342                      * label
343                      */
344                     if (sel_start == sel_end) {
345                         if (sel_start == 0) {
346                             /* If the cursor is at the start of the line:
347                              * insert new line
348                              */
349                             line_value = ' ' + line_value;
350                         } else if (sel_start == line_value.length) {
351                             /* Special case if the cursor is at the end of the line:
352                              * move to next line
353                              */
354                             var next_row = $(row_id.prefix + (parseInt(row_id.spine) + 1));
355                             if (next_row) {
356                                 next_row.focus();
357                             }
358                             break;
359                         } else {
360                             line_value = line_value.substr(0, sel_start) + ' ' + line_value.substr(sel_end);
361                         }
362                     } else {
363                         line_value = line_value.substr(0, sel_start) + ' ' + line_value.substr(sel_end);
364                     }
365                     event.target.value = line_value;
366
367                     /* Recreate the label */
368                     var new_label = '';
369                     var chunk;
370                     var x = 0;
371                     while (chunk = $(row_id.prefix + x)) {
372                         if (x > 0) {
373                             new_label += ' ' + chunk.value;
374                         } else {
375                             new_label = chunk.value;
376                         }
377                         x++;
378                     }
379                     generate({"acn": row_id.acn, "label": new_label});
380                     $(row_id.prefix + row_id.spine).focus();
381                     break;
382                 }
383
384                 case dojo.keys.BACKSPACE : {
385                     /* Delete line if at the start of an input box */
386                     if (sel_start == 0 && sel_end == sel_start) {
387                         var new_label = '';
388                         var chunk;
389                         var x = 0;
390                         while (x <= (row_id.spine - 1) && (chunk = $(row_id.prefix + x))) {
391                             if (x > 0) {
392                                 new_label += ' ' + chunk.value;
393                             } else {
394                                 new_label = chunk.value;
395                             }
396                             x++;
397                         }
398
399                         if (chunk = $(row_id.prefix + x)) {
400                             new_label += chunk.value;
401                             x++;
402                         }
403
404                         while (chunk = $(row_id.prefix + x)) {
405                             new_label += ' ' + chunk.value;
406                             x++;
407                         }
408                         generate({"acn": row_id.acn, "label": new_label});
409                         $(row_id.prefix + row_id.spine).focus();
410                     }
411                     if (sel_start == 0) {
412                         /* Move to the previous row */
413                         var prev_row = $(row_id.prefix + (parseInt(row_id.spine) - 1));
414                         if (prev_row) {
415                             prev_row.focus();
416                         }
417                     }
418                     break;
419                 }
420
421                 case dojo.keys.DELETE : {
422                     /* Delete line if at the end of an input box */
423                     if (sel_start == event.target.textLength) {
424                         var new_label = '';
425                         var chunk;
426                         var x = 0;
427                         while (x <= row_id.spine && (chunk = $(row_id.prefix + x))) {
428                             if (x > 0) {
429                                 new_label += ' ' + chunk.value;
430                             } else {
431                                 new_label = chunk.value;
432                             }
433                             x++;
434                         }
435
436                         if (chunk = $(row_id.prefix + x)) {
437                             new_label += chunk.value;
438                             x++;
439                         }
440
441                         while (chunk = $(row_id.prefix + x)) {
442                             new_label += ' ' + chunk.value;
443                             x++;
444                         }
445                         generate({"acn": row_id.acn, "label": new_label});
446                         $(row_id.prefix + row_id.spine).focus();
447                     }
448                     break;
449                 }
450
451                 case dojo.keys.UP_ARROW : {
452                     /* Move to the previous row */
453                     var prev_row = $(row_id.prefix + (parseInt(row_id.spine) - 1));
454                     if (prev_row) {
455                         prev_row.focus();
456                     }
457                     break;
458                 }
459
460                 case dojo.keys.DOWN_ARROW : {
461                     /* Move to the next row */
462                     var next_row = $(row_id.prefix + (parseInt(row_id.spine) + 1));
463                     if (next_row) {
464                         next_row.focus();
465                     }
466                     break;
467                 }
468
469                 default : {
470                     break;
471                 }
472             }
473         }
474
475         function expand_macros(text,copy,volume,record) {
476             var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record };
477             var obj = { 'data' : g.data };
478             for (var i in g.col_map) {
479                 var re = g.col_map[i].regex;
480                 if (text.match(re)) {
481                     try {
482                         text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) );
483                     } catch(E) {
484                         g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E);
485                     }
486                 }
487             }
488             return text;
489         }
490
491         function preview(idx) {
492             try {
493                     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
494                     var pt = Number( $('pt').value );  /* font size */
495                     if (!pt) {
496                         pt = g.data.hash.aous['cat.label.font.size'] || 10;
497                         $('pt').value = pt;
498                     }
499                     var ff = g.data.hash.aous['cat.label.font.family'] || 'monospace';
500                     var fw = $('font_weight').value;  /* font weight */
501                     if (!fw) {
502                         fw = g.data.hash.aous['cat.label.font.weight'] || 'normal';
503                     }
504                     var lm = Number($('lm').value); /* left margin */
505                     if (!lm) {
506                         lm = g.data.hash.aous['cat.spine.line.margin'] || 0;
507                     }
508                     var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */
509                     var lw = Number($('lw').value); /* spine label width */
510                     if (!lw) {
511                         lw = g.data.hash.aous['cat.spine.line.width'] || 8;
512                         $('lw').value = lw;
513                     }
514                     var ll = Number($('ll').value); /* spine label length */
515                     if (!ll) {
516                         ll = g.data.hash.aous['cat.spine.line.height'] || 9;
517                         $('ll').value = ll;
518                     }
519                     var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */
520                     var html = "<html><head>";
521                     html += "<link type='text/css' rel='stylesheet' href='" + xulG.url_prefix('/xul/server/skin/print.css') + "'></link>"
522                     html += "<link type='text/css' rel='stylesheet' href='data:text/css,pre{font-family:" + ff + ";font-size:" + pt + "pt; font-weight: " + fw + ";}'></link>";
523                     html += "<title>Spine Labels</title></head><body>\n";
524                     var nl = document.getElementsByAttribute('name','template');
525                     for (var i = 0; i < nl.length; i++) {
526                         if (typeof idx == 'undefined' || idx == null) { } else {
527                             if (idx != i) continue;
528                         }
529                         var volume = g.volumes[ nl[i].getAttribute('acn_id') ];
530
531                         for (var j = 0; j < volume.copies().length; j++) {
532                             var copy = volume.copies()[j];
533                             if (i == 0 && j == 0) {
534                                 html += '<pre class="first_pre">\n';
535                             } else {
536                                 html += '<pre class="not_first_pre">\n';
537                             }
538                             var gb = nl[i].getElementsByTagName('groupbox')[0];
539                             var nl2 = gb.getElementsByAttribute('name','spine');
540                             for (var k = 0; k < nl2.length; k++) {
541                                 for (var m = 0; m < lm; m++) html += ' ';
542                                 html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
543                                 if ($('pl').checked) {
544                                     var sib = nl2[k].nextSibling;
545                                     if (sib) {
546                                         for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
547                                         for (var m = 0; m < mm; m++) html += ' ';
548                                         html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
549                                     }
550                                 }
551                                 html += '\n';
552                             }
553                             html += '</pre hex="0C">\n';
554                         }
555                     }
556                     html += '</body></html>';
557
558                     /* From https://developer.mozilla.org/en/Using_nsIXULAppInfo */
559                     var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
560                                             .getService(Components.interfaces.nsIXULAppInfo);
561                     var platformVer = appInfo.platformVersion;
562
563                     /* We need to use different print strategies for different
564                      * XUL versions, apparently
565                      */
566                     if (platformVer.substr(0, 5) == '1.9.0') {
567                         preview_xul_190(html);
568                     } else {
569                         preview_xul_192(html);
570                     }
571
572
573             } catch(E) {
574                 g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E);
575             }
576         }
577
578         function preview_xul_190(html) {
579             JSAN.use('util.window'); var win = new util.window();
580             var loc = ( urls.XUL_REMOTE_BROWSER );
581             //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels');
582             var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550');
583             w.xulG = { 
584                 'url' : 'about:blank',
585                 'url_prefix' : function (u) { return xulG.url_prefix(u); },
586                 'show_print_button' : 1,
587                 'printer_context' : 'label',
588                 'alternate_print' : 1,
589                 'no_xulG' : 1,
590                 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'),
591                 'on_url_load' : function(b) { 
592                     try { 
593                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
594                         if (typeof w.xulG.written == 'undefined') {
595                             w.xulG.written = true;
596                             w.g.browser.get_content().document.write(html);
597                             w.g.browser.get_content().document.close();
598                         }
599                     } catch(E) {
600                         alert(E);
601                     }
602                 }
603             };
604         }
605
606         function preview_xul_192(html) {
607             var loc = ( urls.XUL_BROWSER );
608             xulG.new_tab(
609                 loc,
610                 {
611                     'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title')
612                 },
613                 { 
614                     'url' : 'data:text/html;charset=utf-8,'+window.escape(html),
615                     'html_source' : html,
616                     'show_print_button' : 1,
617                     'printer_context' : 'label',
618                     'no_xulG' : 1
619                 }
620             );
621         }