[Zope-CVS] CVS: Packages/Moztop/moztop/content/menu - connection-wizard.js:1.3 connection-wizard.xul:1.2

Stephan Richter srichter@cbu.edu
Thu, 20 Mar 2003 14:31:21 -0500


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

Modified Files:
	connection-wizard.js connection-wizard.xul 
Log Message:
fixing site discovery and site adding.


=== Packages/Moztop/moztop/content/menu/connection-wizard.js 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/menu/connection-wizard.js:1.2	Thu Mar 20 11:30:22 2003
+++ Packages/Moztop/moztop/content/menu/connection-wizard.js	Thu Mar 20 14:30:50 2003
@@ -17,7 +17,6 @@
 
 ******************************************************************************/
 
-
 /* Create a site from the wizard */
 
 function getSiteConfiguration () {
@@ -25,62 +24,92 @@
 
     var url = document.getElementById("newsite_url").value;
 
-    function myfunc (e) {
+    function determineStatus(error) {
 
-	if (p.readyState != 4) {
-	    return;
-	}
-
-	var status = p.status + ": " + p.statusText + "\n";
-	var status = status + p.getAllResponseHeaders() + "\n\n";
-	var status = status + p.responseText;
-	document.getElementById("responsetext").firstChild.nodeValue = status;
-        if (p.responseXML) {
-	    var dcns = "http://www.purl.org/dc/1.1#";
-	    var realm = p.responseXML.getElementsByTagName("realm")[0];
-	    var realm = realm.firstChild.nodeValue;
-	    var sitename = p.responseXML.getElementsByTagNameNS(dcns,"title")[0];
-	    var sitename = sitename.firstChild.nodeValue;
-
-	    document.getElementById("newsite_realm").value=realm;
-	    document.getElementById("newsite_name").value=sitename;
-	    dump("\nrealm and sitename are " + realm + " " + sitename);
-
-	}
-    }
-
-    var p = new XMLHttpRequest();
-    p.onreadystatechange = myfunc;
-    p.open("GET", url + "config.xml");
-    p.send(null);
+	// XXX: does this mean the connection is not yet ready?
+        if (request.readyState != 4) {
+            return;
+        }
+
+	// Construct server output and display it in the dialog page
+        var status = request.status + ": " + request.statusText + "\n";
+        var status = status + request.getAllResponseHeaders() + "\n\n";
+        var status = status + request.responseText;
+        document.getElementById("responsetext").firstChild.nodeValue = status;
+
+        if (request.responseXML) {
+	    // XXX: Define namespaces manually; use siteds for this later
+ 	    var dcns = "http://www.purl.org/dc/1.1#";
+ 	    var oscomns = "http://www.oscom.org/rdf#";
+
+	    // Retrieve site title from response (XML)
+            var holder = request.responseXML
+                .getElementsByTagNameNS(dcns, "title")[0];
+            var title = holder.firstChild.nodeValue;
+
+	    // Retrieve site content URL from response (XML)
+            var holder = request.responseXML
+                .getElementsByTagNameNS(oscomns, "contentsurl")[0];
+            var contentsurl = holder.firstChild.nodeValue;
+
+	    // Retrieve site URN from response (XML)
+            var holder = request.responseXML
+                .getElementsByTagNameNS(oscomns, "siteurn")[0];
+            var siteurn = holder.firstChild.nodeValue;
+
+	    // Update the dialog page
+            document.getElementById("newsite_title").value = title;
+            document.getElementById("newsite_siteurn").value = siteurn;
+            document.getElementById("newsite_contentsurl").value = contentsurl;
+        }
+    };
+
+    // Trying to get a discovery response from the server
+    var request = new XMLHttpRequest();
+    request.onreadystatechange = determineStatus;
+    request.open("GET", url+"rsd.xml");
+    request.send(null);
 }
 
 function verifyValues () {
     /* Before leaving the first page, make sure newsite_name is set */
 
-    var newsite_name = document.getElementById("newsite_name").value;
-    if (newsite_name == "Not connected.") {
-	alert("Must successfully connect");
-	return false;
-    }
+    var newsite_title = document.getElementById("newsite_title").value;
+    var newsite_siteurn = document.getElementById("newsite_siteurn").value;
+    var newsite_contentsurl = document.getElementById(
+                                               "newsite_contentsurl").value;
+
+    if (newsite_title == "Not connected.") {
+        alert("Must successfully connect, no 'dc:title' found.");
+        return false;
+    };
+
+    if (newsite_siteurn == "Not connected.") {
+        alert("Must successfully connect, no 'oscom:siteurn' found.");
+        return false;
+    };
+
+    if (newsite_contentsurl == "Not connected.") {
+        alert("Must successfully connect, no 'oscom:contentsurl' found.");
+        return false;
+    };
 
     return true;
 }
 
-
-function createSite() {
-
+function addSite() {
   // The sitesmanager was passed in as an argument
   var sm = window.arguments[0];
 
    /* Setting up variables */
-  var newsite_name = document.getElementById("newsite_name").value;
-  var newsite_realm = document.getElementById("newsite_realm").value;
-  var newsite_url = document.getElementById("newsite_url").value;
-  var newsite_username = document.getElementById("newsite_username").value;
-  var newsite_password = document.getElementById("newsite_password").value;
-
-  // Now we call addSite in navigation/navigation.js
-  sm.addSite(newsite_name, newsite_realm, newsite_url, 
-	     newsite_username, newsite_password);
+  var newsite_title = document.getElementById("newsite_title").value;
+  var newsite_siteurn = document.getElementById("newsite_siteurn").value;
+  var newsite_contentsurl = document.getElementById(
+                                           "newsite_contentsurl").value;
+
+  // Now we call addSite in lib/sitemanager.js
+  sm.addSite(newsite_title, newsite_siteurn, newsite_siteurn, 
+	     "", "");
+
+  return true;
 }


=== Packages/Moztop/moztop/content/menu/connection-wizard.xul 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/menu/connection-wizard.xul:1.1	Thu Mar 20 09:56:06 2003
+++ Packages/Moztop/moztop/content/menu/connection-wizard.xul	Thu Mar 20 14:30:50 2003
@@ -3,15 +3,16 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>
 
-<wizard id="add-conn-wizard" title="Create a new Connection to Zope 3"
-  onwizardfinish="return createSite();"
+<wizard id="add-conn-wizard" title="Add a new Connection to Zope"
+  onwizardfinish="return addSite();"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/x-javascript" src="connection-wizard.js"/>
 
   <wizardpage onpageadvanced="return verifyValues();">
     <description>
-      This Wizard will help you to connect to a new site.
+      This Wizard will help you to connect to a new site. Simply specify the
+      root of your site.
     </description>
     <hbox>
       <label value="Site URL:"/>
@@ -26,27 +27,15 @@
       <caption label="Server Response"/>
       <hbox>
         <label value="Site name:"/>
-        <label id="newsite_name" style="font-weight: bold" 
+        <label id="newsite_title" style="font-weight: bold" 
 	       value="Not connected."/>
-	<label hidden="true" id="newsite_realm" value="Not connected."/>
+	<label hidden="true" id="newsite_siteurn" value="Not connected."/>
+	<label hidden="true" id="newsite_contentsurl" value="Not connected."/>
       </hbox>
-      <description style="font-size: xx-small; background-color: silver; white-space: pre;height: 3em; overflow: scroll"
+      <description style="font-size: xx-small; background-color: silver; 
+                          white-space: pre;height: 3em; overflow: scroll"
 		   id="responsetext">No response.</description>
     </groupbox>
-  </wizardpage>
-
-  <wizardpage description="Available Users">
-    <label value="Please select a user:"/>
-    <menulist id="newsite_username" label="Username">
-      <menupopup>
-        <menuitem label="gandalf (Default Zope 3 Manager)" value="gandalf"/>
-        <menuitem label="ev (Paul Everitt)" value="ev"/>
-        <menuitem label="srichter (Stephan Richter)" value="srichter"/>
-        <menuitem label="zope3 (Zope 3 USer)" value="zope3"/>
-      </menupopup>
-    </menulist>
-    <label value="Enter the password:"/>
-    <textbox id="newsite_password" type="password" value="" />
   </wizardpage>
 
 </wizard>