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