Eliminate an annoying and useless warning in the JavaScript Console.
authorJason Stephenson <jstephenson@mvlc.org>
Wed, 11 Dec 2013 14:50:09 +0000 (09:50 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 17 Dec 2013 19:39:59 +0000 (14:39 -0500)
Timestamp: 12/10/2013 02:52:51 PM
Warning: Empty string passed to getElementById().
Source File: oils://remote/xul/rel_3_0_20131206_120120/server/OpenILS/global_util.js
Line: 354

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js

index d1be186..6a9332f 100644 (file)
                     }
                 }
                 var cmd = nodes[i].getAttribute('command');
                     }
                 }
                 var cmd = nodes[i].getAttribute('command');
-                var cmd_el = document.getElementById(cmd);
-                if (nodes[i].disabled == false && nodes[i].hidden == false) {
-                    var no_poke = nodes[i].getAttribute('oils_persist_no_poke');
-                    if (no_poke && no_poke == 'true') {
-                        // Timing issue for some checkboxes; don't poke them with an event
-                        dump('\tnot poking\n');
-                    } else {
-                        if (cmd_el) {
-                            dump('\tpoking @command\n');
-                            var evt = document.createEvent("Events");
-                            evt.initEvent( 'command', true, true );
-                            cmd_el.dispatchEvent(evt);
+                if (cmd) {
+                    var cmd_el = document.getElementById(cmd);
+                    if (nodes[i].disabled == false && nodes[i].hidden == false) {
+                        var no_poke = nodes[i].getAttribute('oils_persist_no_poke');
+                        if (no_poke && no_poke == 'true') {
+                            // Timing issue for some checkboxes; don't poke them with an event
+                            dump('\tnot poking\n');
                         } else {
                         } else {
-                            dump('\tpoking\n');
-                            var evt = document.createEvent("Events");
-                            evt.initEvent( 'command', true, true );
-                            nodes[i].dispatchEvent(evt);
+                            if (cmd_el) {
+                                dump('\tpoking @command\n');
+                                var evt = document.createEvent("Events");
+                                evt.initEvent( 'command', true, true );
+                                cmd_el.dispatchEvent(evt);
+                            } else {
+                                dump('\tpoking\n');
+                                var evt = document.createEvent("Events");
+                                evt.initEvent( 'command', true, true );
+                                nodes[i].dispatchEvent(evt);
+                            }
                         }
                     }
                         }
                     }
-                }
-                if (cmd_el) {
-                    window.persist_helper_event_listeners.add(cmd_el, 
-                        'command',
-                        gen_event_handler('command',cmd_el),
-                        false
-                    );
-                    window.persist_helper_event_listeners.add(cmd_el, 
-                        'oils_persist',
-                        gen_oils_persist_handler( base_key, nodes[i] ),
-                        false
-                    );
-                } else {
-                    var node = nodes[i];
-                    var event_types = [];
-                    if (node.hasAttribute('oils_persist_events')) {
-                        var event_type_list = node.getAttribute('oils_persist_events').split(' ');
-                        for (var j = 0; j < event_type_list.length; j++) {
-                            event_types.push( event_type_list[j] );
-                        }
+                    if (cmd_el) {
+                        window.persist_helper_event_listeners.add(cmd_el, 
+                            'command',
+                            gen_event_handler('command',cmd_el),
+                            false
+                        );
+                        window.persist_helper_event_listeners.add(cmd_el, 
+                            'oils_persist',
+                            gen_oils_persist_handler( base_key, nodes[i] ),
+                            false
+                        );
                     } else {
                     } else {
-                        if (node.nodeName == 'textbox') { 
-                            event_types.push('change');
-                        } else if (node.nodeName == 'menulist') { 
-                            event_types.push('select');  
-                        } else if (node.nodeName == 'window') {
-                            event_types.push('resize'); 
-                            node = window; // xul window is an element of window.document
+                        var node = nodes[i];
+                        var event_types = [];
+                        if (node.hasAttribute('oils_persist_events')) {
+                            var event_type_list = node.getAttribute('oils_persist_events').split(' ');
+                            for (var j = 0; j < event_type_list.length; j++) {
+                                event_types.push( event_type_list[j] );
+                            }
                         } else {
                         } else {
-                            event_types.push('command'); 
+                            if (node.nodeName == 'textbox') { 
+                                event_types.push('change');
+                            } else if (node.nodeName == 'menulist') { 
+                                event_types.push('select');  
+                            } else if (node.nodeName == 'window') {
+                                event_types.push('resize'); 
+                                node = window; // xul window is an element of window.document
+                            } else {
+                                event_types.push('command'); 
+                            }
+                        }
+                        for (var j = 0; j < event_types.length; j++) {
+                            window.persist_helper_event_listeners.add(node, 
+                                event_types[j],
+                                gen_event_handler(event_types[j],node),
+                                false
+                            );
                         }
                         }
-                    }
-                    for (var j = 0; j < event_types.length; j++) {
                         window.persist_helper_event_listeners.add(node, 
                         window.persist_helper_event_listeners.add(node, 
-                            event_types[j],
-                            gen_event_handler(event_types[j],node),
+                            'oils_persist',
+                            gen_oils_persist_handler( base_key, node ),
                             false
                         );
                     }
                             false
                         );
                     }
-                    window.persist_helper_event_listeners.add(node, 
-                        'oils_persist',
-                        gen_oils_persist_handler( base_key, node ),
-                        false
-                    );
                 }
             }
         } catch(E) {
                 }
             }
         } catch(E) {