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

Stephan Richter srichter@cbu.edu
Sun, 23 Mar 2003 10:07:17 -0500


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

Modified Files:
	jsdav.js 
Log Message:
Started WebDAV framework for Javascript. I think I list all possible
headers and commands at this point. Handling of the XML elements is not 
yet outline (Chapter 12).

I plan to develop this lib and the Zope 3 WebDAV support in parallel so 
that:

  - I have a client to check the server.

  - I have a server to check the client.

  - Heck, read once the specification, why not do both.

  - Guarantee Moztop and Zope 3 work well together.


=== Packages/Moztop/moztop/content/lib/jsdav.js 1.3 => 1.4 ===
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.3	Sun Mar 23 08:32:52 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js	Sun Mar 23 10:07:16 2003
@@ -17,50 +17,53 @@
 
 ******************************************************************************/
 
-function DELETE(puturl, putcontent) {
-    /* Deleting a resource on the server */
-    var request = new XMLHttpRequest();
+function DELETE(url) {
+    /* Implementation of WebDAV command DELETE.
 
-    if (!putcontent) {
-	putcontent = "";
-    }
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.6
+    */
+    var request = new XMLHttpRequest();
 
-    function myfunc(e) {
+    function handleResponse(error) {
 	if (request.responseXML) {
 
 	    var serializer = new XMLSerializer();
-	    var resp = request.responseXML;
-	    var str = serializer.serializeToString(d);
+	    var response = request.responseXML;
+	    var response_str = serializer.serializeToString(response);
 
-	    dump("\nmade it in PUT\n" + str + "\n");
+	    dump("\nmade it in PUT\n" + response_str + "\n");
 	}
     }
 
-    request.onload = myfunc;
-    request.open("DELETE", puturl);
+    request.onload = handleResponse;
+    request.open("DELETE", url);
     request.setRequestHeader("Content-type", "text/plain");
-    //request.setRequestHeader("Host", "localhost");
+    // XXX: implement "Host" header in a non-static way
+    request.setRequestHeader("Host", "localhost");
     request.send(putcontent);
 
     return;
 }    
 
 
-function PUT() {
-    var puturl = "http://localhost:9700/fooboy3";
-    var putcontent = "";
+function PUT(url, headers) {
+    /* Implementation of WebDAV command PUT.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.7
+       and http://asg.web.cmu.edu/rfc/rfc2068.html#sec-9.6
+    */
 
     var request = new XMLHttpRequest();
     var typeheader = "X-Zope-Type-Name"
 
-    function myfunc (e) {
+    function handleResponse(error) {
 	if (request.responseXML) {
 
-	    var s = new XMLSerializer();
-	    var d = request.responseXML;
-	    var str = s.serializeToString(d);
+	    var serializer = new XMLSerializer();
+	    var response = request.responseXML;
+	    var response_str = serializer.serializeToString(response);
 
-	    dump("\nmade it in PUT\n" + str + "\n");
+	    dump("\nmade it in PUT\n" + response_str + "\n");
 	}
     }
 
@@ -73,13 +76,134 @@
     var s = new XMLSerializer();
     str = s.serializeToString(x);
 
-    request.onload = myfunc;
-    request.open("PUT",puturl);
+    request.onload = handleResponse;
+    request.open("PUT", url);
     request.setRequestHeader("Content-type", "text/xml");
     request.setRequestHeader("Host","localhost");
+    // XXX: implement "Host" header in a non-static way
     request.setRequestHeader(typeheader, "PageTemplate");
     request.send(x);
 
     return;
 }    
 
+
+function COPY(url, destination, content, headers) {
+    /* Implementation of WebDAV command COPY.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.8
+    */
+
+}
+
+
+function MOVE(url, destination, headers) {
+    /* Implementation of WebDAV command MOVE.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.9
+    */
+
+}
+
+
+function LOCK(url, content, headers) {
+    /* Implementation of WebDAV command LOCK.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.10
+    */
+
+}
+
+
+function UNLOCK(url, headers) {
+    /* Implementation of WebDAV command UNLOCK.
+
+       See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.11 
+    */
+
+}
+
+
+function createDAVHeader(version) {
+    /* Creates a DAV Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.1
+    */
+
+}
+
+
+function createDepthHeader(depth) {
+    /* Creates a Depth Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.2
+    */
+
+}
+
+function createDestinationHeader(destination) {
+    /* Creates a Destination Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.3
+    */
+
+}
+
+
+function createIfHeader() {
+    /* Creates a If Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.4
+    */
+
+}
+
+
+function createLockTokenHeader(url) {
+    /* Creates a Lock-Token Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.5
+    */
+
+}
+
+
+function createOverwriteHeader(bool) {
+    /* Creates an Overwrite Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.6
+    */
+
+}
+
+
+
+function handleStatusURIHeader(header) {
+    /* Handle a Status-URI Response Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.7
+    */
+
+}
+
+
+function createTimeoutHeader(time) {
+    /* Creates an Timeout Request Header. 
+
+      See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-9.8
+    */
+
+}
+
+
+/* WebDAV Status Code Extensions
+
+   See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-10
+*/
+var statusCodes = new Array();
+statusCodes[102] = 'Processing';
+statusCodes[207] = 'Multi-Status';
+statusCodes[422] = 'Unprocessable Entity';
+statusCodes[423] = 'Locked';
+statusCodes[424] = 'Failed Dependency';
+statusCodes[507] = 'Insufficient Storage';