[open-ils-commits] r14671 - trunk/Open-ILS/web/js/dojo/fieldmapper (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Oct 29 09:30:27 EDT 2009
Author: miker
Date: 2009-10-29 09:30:25 -0400 (Thu, 29 Oct 2009)
New Revision: 14671
Modified:
trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
Log:
use more dojo-tastic methods
Modified: trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2009-10-29 13:25:00 UTC (rev 14670)
+++ trunk/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2009-10-29 13:30:25 UTC (rev 14671)
@@ -1,4 +1,5 @@
if(!dojo._hasResource["fieldmapper.IDL"]) {
+ dojo.require('dojox.data.dom');
dojo.provide("fieldmapper.IDL");
dojo.declare('fieldmapper.IDL', null, {
@@ -33,16 +34,14 @@
},
_parse : function(xmlNode, callback) {
- var classes = xmlNode.getElementsByTagName('class');
var idl = fieldmapper.IDL.fmclasses = {};
-
- for(var i = 0; i < classes.length; i++) {
- var node = classes[i];
+
+ dojo.forEach( dojo.query('class', xmlNode), function (node) {
var id = node.getAttribute('id');
- var fields = node.getElementsByTagName('fields')[0];
+ var fields = dojo.query('fields', node)[0];
window.fmclasses[id] = [];
- var fieldData = this._parseFields(node, id);
+ var fieldData = this._parseFields( node, id );
var obj = {
fields : fieldData.list,
@@ -86,10 +85,9 @@
obj.core = (obj.core == 'true');
obj.label = (obj.label) ? obj.label : obj.name;
idl[id] = obj;
- }
+ });
- if(callback)
- callback();
+ if(callback) callback();
},
/* parses the links and fields portion of the IDL */
@@ -97,17 +95,10 @@
var data = [];
var map = {};
- var fields = node.getElementsByTagName('fields')[0];
- fields = fields.getElementsByTagName('field');
+ var links = dojo.query('links', node);
- var links = node.getElementsByTagName('links')[0];
- if( links ) links = links.getElementsByTagName('link');
- else links = [];
-
-
var position = 0;
- for(var i = 0; i < fields.length; i++) {
- var field = fields[i];
+ dojo.forEach(dojo.query('fields field', node), function (field) {
var name = field.getAttribute('name');
if(name == 'isnew' || name == 'ischanged' || name == 'isdeleted')
@@ -122,7 +113,7 @@
selector : field.getAttributeNS(this.NS_REPORTS,'selector'),
array_position : position++,
type : 'field',
- virtual : (fields[i].getAttributeNS(this.NS_PERSIST, 'virtual') == 'true')
+ virtual : (field.getAttributeNS(this.NS_PERSIST, 'virtual') == 'true')
};
obj.label = obj.label || obj.name;
@@ -130,14 +121,7 @@
window.fmclasses[classname].push(obj.name);
- var link = null;
- for(var l = 0; l < links.length; l++) {
- if(links[l].getAttribute('field') == name) {
- link = links[l];
- break;
- }
- }
-
+ var link = dojo.query('links link[field=' + name + ']', node)[0];
if(link) {
obj.type = 'link';
obj.key = link.getAttribute('key');
@@ -147,7 +131,7 @@
data.push(obj);
map[obj.name] = obj;
- }
+ });
dojo.forEach(['isnew', 'ischanged', 'isdeleted'],
function(name) {
More information about the open-ils-commits
mailing list