[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - jsdav.js:1.6

Stephan Richter srichter@cbu.edu
Sun, 23 Mar 2003 13:03:52 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv12654/moztop/content/lib

Modified Files:
	jsdav.js 
Log Message:
Started DAV test function.

Implemented propfind, allprop, propname and prop XML elements.


=== Packages/Moztop/moztop/content/lib/jsdav.js 1.5 => 1.6 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.5	Sun Mar 23 11:29:49 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js	Sun Mar 23 13:03:22 2003
@@ -44,12 +44,19 @@
 }
 
 
-DavClient.prototype.PROPFIND = function(url) {
+DavClient.prototype.PROPFIND = function(url, headers) {
     /* Implementation of WebDAV command PROPFIND.
 
        See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.1
     */
 
+    // look for optional Depth Header 
+
+    // generate propfind XML element (12.14)
+
+    // request body optional (if not, all names and values are returned)
+
+    // Return value text/xml using multi-status
 }
 
 
@@ -212,7 +219,7 @@
       Example: 'DAV:1,2'
     */
     var header = "DAV: ";
-    for (index = 0; index == classes.length; index++) {
+    for (var index = 0; index < classes.length; index++) {
 	header += classes[index];
 	if (index != classes[length])
 	    header += ",";
@@ -283,7 +290,80 @@
 DavClient.prototype.createTimeoutHeader = function(time) {
     /* Creates an Timeout Request Header. 
 
-      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.8
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.8
     */
 
 }
+
+
+/* Data structure for the propfind XML Element and its children */
+
+function Prop(ns) {
+    /* Implementation of prop XML Element.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-12.11
+    */
+    this.namespace = ns;
+    this.properties = new Array();
+}
+
+Prop.prototype = {
+    addProperty: function(name) {
+	this.properties[this.properties.length] = name;
+    },
+
+    serialize: function(ns) {
+	xml = '  <DAV:prop xmlns:'+ns+'="'+this.namespace+'">\n';
+	for (var index = 0; index < this.properties.length; index++)
+	    xml += '    <'+ns+':'+this.properties[index]+' />\n'; 
+	xml += '  </DAV:prop>\n';
+	return xml;	    
+    }
+}
+
+
+function PropFind() {
+    /* Implementation of propfind XML Element.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-12.14
+    */
+    this.allprop = false;
+    this.propname = false;
+    this.props = new Array();
+}
+
+PropFind.prototype = {
+
+    addProp: function(prop) {
+	if ((this.allprop == false) && (this.propname == false))
+	    this.props[this.props.length] = prop;
+    },
+    
+    setAllProp: function() {
+	if ((this.props.length == 0) && (this.propname == false))
+	    this.allprop = true;
+    },
+
+    setPropName: function() {
+	if ((this.props.length == 0) && (this.allprop == false))
+	    this.propname = true;
+    },
+
+    serialize: function() {
+	xml = '<DAV:propfind xmlns:DAV="DAV:">\n';
+	if (this.allprop == true)
+	    xml += '  <DAV:allprop />\n';
+
+	if (this.propname == true)
+	    xml += '  <DAV:propname />\n';
+
+	if (this.props.length > 0) {
+	    for (var index = 0; index < this.props.length; index++) 
+		xml += this.props[index].serialize('PROP'+index); 
+	}
+		
+	xml += '</DAV:propfind>\n';
+	return xml;
+    }
+}
+