[Zope3-checkins] CVS: ZopeProducts/RotterdamSprint - XmlObjectView.py:1.10 xmltree.js:1.10

Godefroid Chapelle gotcha@swing.be
Wed, 11 Dec 2002 08:25:48 -0500


Update of /cvs-repository/ZopeProducts/RotterdamSprint
In directory cvs.zope.org:/tmp/cvs-serv7247

Modified Files:
	XmlObjectView.py xmltree.js 
Log Message:
replace small hack for root folder


=== ZopeProducts/RotterdamSprint/XmlObjectView.py 1.9 => 1.10 ===
--- ZopeProducts/RotterdamSprint/XmlObjectView.py:1.9	Wed Dec 11 06:28:48 2002
+++ ZopeProducts/RotterdamSprint/XmlObjectView.py	Wed Dec 11 08:25:48 2002
@@ -54,7 +54,6 @@
             oldItem = item
         # do not forget root folder
         icon = queryView(oldItem, 'zmi_icon', self.request)
-        #XXX should not hardcode root folder name string
-        result = '<collection name="%s" length="%s" icon_url="%s">%s</collection>' % ('[top]', len(oldItem), icon.url(), result)    
+        result = '<collection name="%s" length="%s" icon_url="%s" isroot="">%s</collection>' % ('', len(oldItem), icon.url(), result)    
         self.request.response.setHeader('Content-Type', 'text/xml')
         return u'<?xml version="1.0" ?><children> %s </children>' % result


=== ZopeProducts/RotterdamSprint/xmltree.js 1.9 => 1.10 ===
--- ZopeProducts/RotterdamSprint/xmltree.js:1.9	Wed Dec 11 06:28:48 2002
+++ ZopeProducts/RotterdamSprint/xmltree.js	Wed Dec 11 08:25:48 2002
@@ -249,19 +249,19 @@
 function getChildCollectionNodes(elem) {
         var items = elem.childNodes;
         var numitems = items.length;
-        var curritem;
+        var currentItem;
         var result = new Array();
         for (var i=0; i< numitems; i++) {
-                curritem = items[i];
+                currentItem = items[i];
 
-                if (curritem.nodeType != ELEMENT_NODE) {
+                if (currentItem.nodeType != ELEMENT_NODE) {
                         continue;
                         }
 
-                if (!isCollection(curritem)) {
+                if (!isCollection(currentItem)) {
                         continue;
                         }
-                result.push(curritem);
+                result.push(currentItem);
                 }
         return result;
         }
@@ -275,40 +275,45 @@
         expandElem.appendChild(iconElem);
         iconElem.style.backgroundImage = 'url("' + baseurl + icon_url + '")';
         // create title
-        var titleelem = document.createElement('title');
+        var titleElem = document.createElement('title');
         var newtextnode = document.createTextNode(title);
         
-        titleelem.appendChild(newtextnode);
+        titleElem.appendChild(newtextnode);
         
-        iconElem.appendChild(titleelem);
+        iconElem.appendChild(titleElem);
 
         return expandElem;
         }
 
-function createCollection(curritem, basename, deep) {
-        var currname = curritem.getAttribute('name');
-        var length = curritem.getAttribute('length');
-        var title = currname + '(' + length + ')';
-        var icon_url = curritem.getAttribute('icon_url');  
-
-        var newelem = document.createElement(curritem.tagName);
-        
-        var expandElem = createCollectionDescription(title, icon_url);
-        newelem.appendChild(expandElem);
+function createCollection(source, basename, deep) {
+        var newelem = document.createElement(source.tagName);
 
         var elemName;
+        var elemTitle;
         //XXX should not hardcode root folder name string
-        if (currname == '[top]') {
+        if (source.getAttribute('isroot') != null) {
+                elemTitle = '[top]';
                 elemName = basename;
                 newelem.style.marginLeft = '0px';
                 }
         else {
-                elemName = basename + currname + '/';
+                elemTitle = source.getAttribute('name');
+                elemName = basename + elemTitle + '/';
                 }
         newelem.setAttribute('name', elemName);
+        
+        var length = source.getAttribute('length');
+        elemTitle = elemTitle + '(' + length + ')';
+        
+        var icon_url = source.getAttribute('icon_url');  
+
+        
+        var expandElem = createCollectionDescription(elemTitle, icon_url);
+        newelem.appendChild(expandElem);
+
 
         if (deep) {
-                var children = getChildCollectionNodes(curritem);
+                var children = getChildCollectionNodes(source);
                 var numchildren = children.length;
                 for (var i=0; i< numchildren; i++) {
                         var newchild = createCollection(children[i], elemName, deep);