From: phasefx Date: Thu, 13 Dec 2007 15:27:14 +0000 (+0000) Subject: robustify these X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=30b4d7f4ed0eb2e286ff50522f62c545be3a4896;p=Evergreen.git robustify these git-svn-id: svn://svn.open-ils.org/ILS/trunk@8206 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js index de9c1690fd..29cf4f29f0 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js @@ -324,9 +324,15 @@ util.widgets.save_attributes = function (file,ids_attrs) { for (var element_id in ids_attrs) { var attribute_list = ids_attrs[ element_id ]; if (! blob[ element_id ] ) blob[ element_id ] = {}; - for (var j = 0; j < attribute_list.length; j++) { - blob[ element_id ][ attribute_list[j] ] = document.getElementById( element_id ).getAttribute( attribute_list[j] ); - } + var x = document.getElementById( element_id ); + if (x) { + for (var j = 0; j < attribute_list.length; j++) { + blob[ element_id ][ attribute_list[j] ] = x.getAttribute( attribute_list[j] ); + } + } else { + dump('Error in util.widgets.save_attributes('+file._file.path+','+js2JSON(ids_attrs)+'):\n'); + dump('\telement_id = ' + element_id + '\n'); + } } netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); //FIXME - WHY DOES THIS NOT WORK?// JSAN.use('util.file'); var file = new util.file(filename); @@ -344,7 +350,15 @@ util.widgets.load_attributes = function (file) { var blob = file.get_object(); file.close(); for (var element_id in blob) { for (var attribute in blob[ element_id ]) { - document.getElementById( element_id ).setAttribute(attribute, blob[ element_id ][ attribute ]); + var x = document.getElementById( element_id ); + if (x) { + x.setAttribute(attribute, blob[ element_id ][ attribute ]); + } else { + dump('Error in util.widgets.load_attributes('+file._file.path+'):\n'); + dump('\telement_id = ' + element_id + '\n'); + dump('\tattribute = ' + attribute + '\n'); + dump('\tblob[id][attr] = ' + blob[element_id][attribute] + '\n'); + } } } return blob;