5 /******************************************************************************************************/
6 /* setup JSAN and some initial libraries */
8 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
9 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
10 JSAN.errorLevel = "die"; // none, warn, or die
11 JSAN.addRepository('/xul/server/');
12 JSAN.use('util.error'); g.error = new util.error();
13 g.error.sdump('D_TRACE','my_init() for cat/copy_editor.xul');
15 JSAN.use('util.functional');
16 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
17 JSAN.use('util.network'); g.network = new util.network();
21 g.docid = g.cgi.param('docid');
22 g.handle_update = g.cgi.param('handle_update');
24 /******************************************************************************************************/
25 /* Get the copy ids from various sources and flesh them */
28 if (g.cgi.param('copy_ids')) copy_ids = JSON2js( g.cgi.param('copy_ids') );
29 if (!copy_ids) copy_ids = [];
30 if (window.xulG && window.xulG.copy_ids) copy_ids = copy_ids.concat( window.xulG.copy_ids );
32 if (copy_ids.length > 0) g.copies = g.network.request(
33 api.FM_ACP_FLESHED_BATCH_RETRIEVE.app,
34 api.FM_ACP_FLESHED_BATCH_RETRIEVE.method,
38 /******************************************************************************************************/
39 /* And other fleshed copies if any */
41 if (!g.copies) g.copies = [];
42 if (window.xulG && window.xulG.copies) g.copies = g.copies.concat( window.xulG.copies );
43 if (g.cgi.param('copies')) g.copies = g.copies.concat( JSON2js( g.cgi.param('copies') ) );
45 /******************************************************************************************************/
46 /* We try to retrieve callnumbers for existing copies, but for new copies, we rely on this */
48 if (window.xulG && window.xulG.callnumbers) g.callnumbers = window.xulG.callnumbers;
49 if (g.cgi.param('callnumbers')) g.callnumbers = JSON2js( g.cgi.param('callnumbers') );
51 /******************************************************************************************************/
52 /* Is the interface an editor or a viewer, single or multi copy, existing copies or new copies? */
54 if (g.cgi.param('edit') == '1') {
56 document.getElementById('caption').setAttribute('label','Copy Editor');
57 document.getElementById('save').setAttribute('hidden','false');
58 g.retrieve_templates();
61 if (g.cgi.param('single_edit') == '1') {
63 document.getElementById('caption').setAttribute('label','Copy Editor');
64 document.getElementById('save').setAttribute('hidden','false');
67 if (g.copies.length > 0 && g.copies[0].id() < 0) {
68 document.getElementById('copy_notes').setAttribute('hidden','true');
69 g.apply("status",5 /* In Process */);
70 $('save').setAttribute('label','Create Copies');
72 g.panes_and_field_names.left_pane =
77 render: 'typeof fm.status() == "object" ? fm.status().name() : g.data.hash.ccs[ fm.status() ].name()',
78 input: 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.ccs, function(obj) { return [ obj.name(), obj.id() ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
81 ].concat(g.panes_and_field_names.left_pane);
84 if (g.copies.length != 1) {
85 document.getElementById('copy_notes').setAttribute('hidden','true');
88 /******************************************************************************************************/
89 /* Show the Record Details? */
92 document.getElementById('brief_display').setAttribute(
94 urls.XUL_BIB_BRIEF + '?docid=' + g.docid
97 document.getElementById('brief_display').setAttribute('hidden','true');
100 /******************************************************************************************************/
101 /* Add stat cats to the panes_and_field_names.right_pane4 */
103 var stat_cat_seen = {};
105 function add_stat_cat(sc) {
107 if (typeof g.data.hash.asc == 'undefined') { g.data.hash.asc = {}; g.data.stash('hash'); }
111 if (typeof sc == 'object') {
116 if (typeof stat_cat_seen[sc_id] != 'undefined') { return; }
118 stat_cat_seen[ sc_id ] = 1;
120 if (typeof sc != 'object') {
122 sc = g.network.simple_request(
123 'FM_ASC_BATCH_RETRIEVE',
129 g.data.hash.asc[ sc.id() ] = sc; g.data.stash('hash');
131 var label_name = g.data.hash.aou[ sc.owner() ].shortname() + " : " + sc.name();
136 render: 'var l = util.functional.find_list( fm.stat_cat_entries(), function(e){ return e.stat_cat() == '
137 + sc.id() + '; } ); l ? l.value() : "<Unset>";',
138 input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.hash.asc[' + sc.id()
139 + '].entries(), function(obj){ return [ obj.value(), obj.id() ]; } ).sort() ); '
140 + 'x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c),false);',
144 dump('temp_array = ' + js2JSON(temp_array) + '\n');
146 g.panes_and_field_names.right_pane4.push( temp_array );
149 /* The stat cats for the pertinent library */
150 for (var i = 0; i < g.data.list.my_asc.length; i++) {
151 add_stat_cat( g.data.list.my_asc[i] );
154 /* Other stat cats present on these copies */
155 for (var i = 0; i < g.copies.length; i++) {
156 var entries = g.copies[i].stat_cat_entries();
157 if (!entries) entries = [];
158 for (var j = 0; j < entries.length; j++) {
159 var sc_id = entries[j].stat_cat();
160 add_stat_cat( sc_id );
164 /******************************************************************************************************/
165 /* Backup copies :) */
167 g.original_copies = js2JSON( g.copies );
169 /******************************************************************************************************/
172 g.summarize( g.copies );
176 var err_msg = "!! This software has encountered an error. Please tell your friendly " +
177 "system administrator or software developer the following:\ncat/copy_editor.xul\n" + E + '\n';
178 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
183 /******************************************************************************************************/
184 /* Retrieve Templates */
186 g.retrieve_templates = function() {
188 JSAN.use('util.widgets'); JSAN.use('util.functional');
190 var robj = g.network.simple_request('FM_AUS_RETRIEVE',[ses(),g.data.list.au[0].id()]);
191 if (typeof robj['staff_client.copy_editor.templates'] != 'undefined') {
192 g.templates = JSON2js( robj['staff_client.copy_editor.templates'] );
194 util.widgets.remove_children('template_placeholder');
195 var list = util.functional.map_object_to_list( g.templates, function(obj,i) { return [i, i]; } );
197 g.template_menu = util.widgets.make_menulist( list );
198 $('template_placeholder').appendChild(g.template_menu);
200 g.error.standard_unexpected_error_alert('Error retrieving templates',E);
204 /******************************************************************************************************/
207 g.apply_template = function() {
209 var name = g.template_menu.value;
210 if (g.templates[ name ] != 'undefined') {
211 var template = g.templates[ name ];
212 for (var i in template) {
213 g.changed[ i ] = template[ i ];
214 switch( template[i].type ) {
216 g.apply(template[i].field,template[i].value);
219 g.apply_stat_cat(template[i].field,template[i].value);
223 g.summarize( g.copies );
227 g.error.standard_unexpected_error_alert('Error applying template',E);
231 /******************************************************************************************************/
232 /* Save as Template */
234 g.save_template = function() {
236 var name = window.prompt('Enter template name:','','Save As Template');
238 g.templates[name] = g.changed;
239 var robj = g.network.simple_request(
240 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : js2JSON(g.templates) }]
242 if (typeof robj.ilsevent != 'undefined') {
245 alert('Template "' + name + '" saved.');
249 g.retrieve_templates();
251 g.error.standard_unexpected_error_alert('Error saving template',E);
257 g.error.standard_unexpected_error_alert('Error saving template',E);
261 /******************************************************************************************************/
262 /* Delete Template */
264 g.delete_template = function() {
266 var name = g.template_menu.value;
268 if (! window.confirm('Delete template "' + name + '"?') ) return;
269 delete(g.templates[name]);
270 var robj = g.network.simple_request(
271 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : js2JSON(g.templates) }]
273 if (typeof robj.ilsevent != 'undefined') {
276 alert('Template "' + name + '" deleted.');
280 g.retrieve_templates();
282 g.error.standard_unexpected_error_alert('Error deleting template',E);
288 g.error.standard_unexpected_error_alert('Error deleting template',E);
292 /******************************************************************************************************/
293 /* Restore backup copies */
295 g.reset = function() {
297 g.copies = JSON2js( g.original_copies );
298 g.summarize( g.copies );
302 /******************************************************************************************************/
303 /* Apply a value to a specific field on all the copies being edited */
305 g.apply = function(field,value) {
306 g.error.sdump('D_TRACE','field = ' + field + ' value = ' + value + '\n');
307 for (var i = 0; i < g.copies.length; i++) {
308 var copy = g.copies[i];
310 copy[field]( value ); copy.ischanged('1');
317 /******************************************************************************************************/
318 /* Apply a stat cat entry to all the copies being edited */
320 g.apply_stat_cat = function(sc_id,entry_id) {
321 g.error.sdump('D_TRACE','sc_id = ' + sc_id + ' entry_id = ' + entry_id + '\n');
322 for (var i = 0; i < g.copies.length; i++) {
323 var copy = g.copies[i];
326 var temp = copy.stat_cat_entries();
327 if (!temp) temp = [];
328 temp = util.functional.filter_list(
331 return (obj.stat_cat() != sc_id);
335 util.functional.find_id_object_in_list(
336 g.data.hash.asc[sc_id].entries(),
340 copy.stat_cat_entries( temp );
348 /******************************************************************************************************/
349 /* This keeps track of what fields have been edited for styling purposes */
353 /******************************************************************************************************/
354 /* These need data from the middle layer to render */
356 g.special_exception = {
357 'Call Number' : function(label,value) {
358 if (value>0) { /* an existing call number */
360 api.FM_ACN_RETRIEVE.app,
361 api.FM_ACN_RETRIEVE.method,
364 var cn = '??? id = ' + value;
366 cn = req.getResultObject().label();
368 g.error.sdump('D_ERROR','callnumber retrieve: ' + E);
370 label.setAttribute('value',cn);
373 } else { /* a yet to be created call number */
375 label.setAttribute('value',g.callnumbers[value]);
379 'Creator' : function(label,value) {
380 if (value == null || value == '' || value == 'null') return;
381 g.network.simple_request(
382 'FM_AU_RETRIEVE_VIA_ID',
385 var p = '??? id = ' + value;
387 p = req.getResultObject();
391 g.error.sdump('D_ERROR','patron retrieve: ' + E);
393 label.setAttribute('value',p);
397 'Last Editor' : function(label,value) {
398 if (value == null || value == '' || value == 'null') return;
399 g.network.simple_request(
400 'FM_AU_RETRIEVE_VIA_ID',
403 var p = '??? id = ' + value;
405 p = req.getResultObject();
409 g.error.sdump('D_ERROR','patron retrieve: ' + E);
411 label.setAttribute('value',p);
418 /******************************************************************************************************/
419 g.readonly_stat_cat_names = [];
420 g.editable_stat_cat_names = [];
422 /******************************************************************************************************/
423 /* These get show in the left panel */
425 g.panes_and_field_names = {
432 render: 'fm.barcode();',
438 render: 'util.date.formatted_date( fm.create_date(), "%F");',
444 render: 'fm.creator();',
450 render: 'util.date.formatted_date( fm.edit_date(), "%F");',
456 render: 'fm.editor();',
467 render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.hash.acpl[ fm.location() ].name()',
468 input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.acpl, function(obj) { return [ obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
473 "Circulation Library",
475 render: 'typeof fm.circ_lib() == "object" ? fm.circ_lib().shortname() : g.data.hash.aou[ fm.circ_lib() ].shortname()',
476 input: 'c = function(v){ g.apply("circ_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list(g.data.list.my_aou, function(obj) { return g.data.hash.aout[ obj.ou_type() ].can_have_vols(); }), function(obj) { return [ obj.shortname(), obj.id() ]; }).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
482 render: 'fm.call_number();',
488 render: 'fm.copy_number() == null ? "<Unset>" : fm.copy_number()',
489 input: 'c = function(v){ g.apply("copy_number",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
501 render: 'fm.circulate() == null ? "<Unset>" : ( fm.circulate() == 1 ? "Yes" : "No" )',
502 input: 'c = function(v){ g.apply("circulate",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Yes", "1" ], [ "No", "0" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
508 render: 'fm.holdable() == null ? "<Unset>" : ( fm.holdable() == 1? "Yes" : "No" )',
509 input: 'c = function(v){ g.apply("holdable",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Yes", "1" ], [ "No", "0" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
516 render: 'switch(fm.loan_duration()){ case 1: case "1": "Short"; break; case 2: case "2": "Normal"; break; case 3:case "3": "Long"; break; }',
517 input: 'c = function(v){ g.apply("loan_duration",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Short", "1" ], [ "Normal", "2" ], [ "Long", "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
524 render: 'switch(fm.fine_level()){ case 1: case "1": "Low"; break; case 2: case "2": "Normal"; break; case 3: case "3": "High"; break; }',
525 input: 'c = function(v){ g.apply("fine_level",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Low", "1" ], [ "Normal", "2" ], [ "High", "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
532 render: 'fm.circ_as_type() == null ? "<Unset>" : fm.circ_as_type()',
533 input: 'c = function(v){ g.apply("circ_as_type",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
537 "Circulation Modifier",
539 render: 'fm.circ_modifier() == null ? "<Unset>" : fm.circ_modifier()',
540 input: 'c = function(v){ g.apply("circ_modifier",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
549 render: 'fm.alert_message() == null ? "<Unset>" : fm.alert_message()',
550 input: 'c = function(v){ g.apply("alert_message",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
557 render: 'fm.deposit() == null ? "<Unset>" : ( fm.deposit() == 1 ? "Yes" : "No" )',
558 input: 'c = function(v){ g.apply("deposit",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Yes", "1" ], [ "No", "0" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
564 render: 'util.money.sanitize( fm.deposit_amount() );',
565 input: 'c = function(v){ g.apply("deposit_amount",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
571 render: 'util.money.sanitize( fm.price() );',
572 input: 'c = function(v){ g.apply("price",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
579 render: 'fm.opac_visible() == null ? "<Unset>" : ( fm.opac_visible() == 1 ? "Yes" : "No" )',
580 input: 'c = function(v){ g.apply("opac_visible",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Yes", "1" ], [ "No", "0" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
586 render: 'fm.ref() == null ? "<Unset>" : ( fm.ref() == 1 ? "Yes" : "No" )',
587 input: 'c = function(v){ g.apply("ref",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Yes", "1" ], [ "No", "0" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
598 /******************************************************************************************************/
599 /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
601 g.summarize = function( copies ) {
602 /******************************************************************************************************/
605 JSAN.use('util.date'); JSAN.use('util.money');
608 for (var i in g.panes_and_field_names) {
609 g.field_names = g.field_names.concat( g.panes_and_field_names[i] );
611 g.field_names = g.field_names.concat( g.editable_stat_cat_names );
612 g.field_names = g.field_names.concat( g.readonly_stat_cat_names );
614 /******************************************************************************************************/
615 /* Loop through the field names */
617 for (var i = 0; i < g.field_names.length; i++) {
619 var field_name = g.field_names[i][0];
620 var render = g.field_names[i][1].render;
621 g.summary[ field_name ] = {};
623 /******************************************************************************************************/
624 /* Loop through the copies */
626 for (var j = 0; j < copies.length; j++) {
629 var cmd = render || ('fm.' + field_name + '();');
632 /**********************************************************************************************/
633 /* Try to retrieve the value for this field for this copy */
638 g.error.sdump('D_ERROR','Attempted ' + cmd + '\n' + E + '\n');
640 if (typeof value == 'object' && value != null) {
641 alert('FIXME: field_name = ' + field_name + ' value = ' + js2JSON(value) + '\n');
644 /**********************************************************************************************/
645 /* Tally the count */
647 if (g.summary[ field_name ][ value ]) {
648 g.summary[ field_name ][ value ]++;
650 g.summary[ field_name ][ value ] = 1;
654 g.error.sdump('D_TRACE','summary = ' + js2JSON(g.summary) + '\n');
657 /******************************************************************************************************/
658 /* Display the summarized data and inputs for editing */
660 g.render = function() {
662 /******************************************************************************************************/
663 /* Library setup and clear any existing interface */
665 JSAN.use('util.widgets'); JSAN.use('util.date'); JSAN.use('util.money'); JSAN.use('util.functional');
667 for (var i in g.panes_and_field_names) {
668 var p = document.getElementById(i);
669 if (p) util.widgets.remove_children(p);
672 /******************************************************************************************************/
673 /* Prepare the panes */
675 var groupbox; var caption; var vbox; var grid; var rows;
677 /******************************************************************************************************/
678 /* Loop through the field names */
680 for (h in g.panes_and_field_names) {
681 if (!document.getElementById(h)) continue;
682 for (var i = 0; i < g.panes_and_field_names[h].length; i++) {
684 var f = g.panes_and_field_names[h][i]; var fn = f[0];
685 groupbox = document.createElement('groupbox'); document.getElementById(h).appendChild(groupbox);
686 if (typeof g.changed[fn] != 'undefined') groupbox.setAttribute('class','copy_editor_field_changed');
687 caption = document.createElement('caption'); groupbox.appendChild(caption);
688 caption.setAttribute('label',fn);
689 vbox = document.createElement('vbox'); groupbox.appendChild(vbox);
690 grid = util.widgets.make_grid( [ { 'flex' : 1 }, {}, {} ] ); vbox.appendChild(grid);
691 grid.setAttribute('flex','1');
692 rows = grid.lastChild;
695 /**************************************************************************************/
696 /* Loop through each value for the field */
698 for (var j in g.summary[fn]) {
699 var value = j; var count = g.summary[fn][j];
700 row = document.createElement('row'); rows.appendChild(row);
701 var label1 = document.createElement('description'); row.appendChild(label1);
702 if (g.special_exception[ fn ]) {
703 g.special_exception[ fn ]( label1, value );
705 label1.appendChild( document.createTextNode(value) );
707 var label2 = document.createElement('description'); row.appendChild(label2);
708 var unit = count == 1 ? 'copy' : 'copies';
709 label2.appendChild( document.createTextNode(count + ' ' + unit) );
711 var hbox = document.createElement('hbox');
712 hbox.setAttribute('id',fn);
713 groupbox.appendChild(hbox);
714 var hbox2 = document.createElement('hbox');
715 groupbox.appendChild(hbox2);
717 /**************************************************************************************/
718 /* Render the input widget */
720 if (f[1].input && g.edit) {
721 g.render_input(hbox,f[1]);
725 g.error.sdump('D_ERROR','copy editor: ' + E + '\n');
731 /******************************************************************************************************/
732 /* This actually draws the change button and input widget for a given field */
733 g.render_input = function(node,blob) {
735 // node = hbox ; groupbox -> hbox, hbox
737 var groupbox = node.parentNode;
738 var vbox = node.previousSibling;
740 var hbox2 = node.nextSibling;
742 var input_cmd = blob.input;
743 var render_cmd = blob.render;
745 var block = false; var first = true;
747 function on_mouseover(ev) {
748 groupbox.setAttribute('style','background: white');
751 function on_mouseout(ev) {
752 groupbox.setAttribute('style','');
755 vbox.addEventListener('mouseover',on_mouseover,false);
756 vbox.addEventListener('mouseout',on_mouseout,false);
757 groupbox.addEventListener('mouseover',on_mouseover,false);
758 groupbox.addEventListener('mouseout',on_mouseout,false);
759 groupbox.firstChild.addEventListener('mouseover',on_mouseover,false);
760 groupbox.firstChild.addEventListener('mouseout',on_mouseout,false);
762 function on_click(ev){
764 if (block) return; block = true;
769 var t = input_cmd.match('apply_stat_cat') ? 'stat_cat' : 'attribute';
773 f = input_cmd.match(/apply\("(.+?)",/)[1];
776 f = input_cmd.match(/apply_stat_cat\((.+?),/)[1];
779 g.changed[ hbox.id ] = { 'type' : t, 'field' : f, 'value' : v };
783 g.summarize( g.copies );
788 g.error.standard_unexpected_error_alert('post_c',E);
791 var x; var c; eval( input_cmd );
793 util.widgets.remove_children(vbox);
794 util.widgets.remove_children(hbox);
795 util.widgets.remove_children(hbox2);
797 var apply = document.createElement('button');
798 apply.setAttribute('label','Apply');
799 apply.setAttribute('accesskey','A');
800 hbox2.appendChild(apply);
801 apply.addEventListener('command',function() { c(x.value); },false);
802 var cancel = document.createElement('button');
803 cancel.setAttribute('label','Cancel');
804 cancel.addEventListener('command',function() { setTimeout( function() { g.summarize( g.copies ); g.render(); }, 0); }, false);
805 hbox2.appendChild(cancel);
806 setTimeout( function() { x.focus(); }, 0 );
809 g.error.standard_unexpected_error_alert('render_input',E);
812 vbox.addEventListener('click',on_click, false);
813 hbox.addEventListener('click',on_click, false);
814 groupbox.firstChild.addEventListener('click',on_click, false);
817 g.error.sdump('D_ERROR',E + '\n');
821 /******************************************************************************************************/
822 /* store the copies in the global xpcom stash */
824 g.stash_and_close = function() {
825 if (g.handle_update) {
827 var r = g.network.request(
828 api.FM_ACP_FLESHED_BATCH_UPDATE.app,
829 api.FM_ACP_FLESHED_BATCH_UPDATE.method,
832 if (typeof r.ilsevent != 'undefined') {
833 g.error.standard_unexpected_error_alert('copy update',r);
835 /* FIXME -- revisit the return value here */
837 alert('copy update error: ' + js2JSON(E));
840 g.data.temp_copies = js2JSON( g.copies );
841 g.data.stash('temp_copies');
842 g.error.sdump('D_CAT','in modal window, g.data.temp_copies = \n' + g.data.temp_copies + '\n');
846 /******************************************************************************************************/
847 /* spawn copy notes interface */
849 g.copy_notes = function() {
850 JSAN.use('util.window'); var win = new util.window();
851 win.open(urls.XUL_COPY_NOTES + '?copy_id=' + window.escape(g.copies[0].id()),'Copy Notes','chrome,resizable,modal');