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

Paul Everitt paul@zope.com
Tue, 18 Feb 2003 10:37:08 -0500


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

Modified Files:
	connection-wizard.xul connection-wizard.js 
Log Message:
Added discover to the New Site wizard

=== Packages/Moztop/moztop/content/Menu/connection-wizard.xul 1.3 => 1.4 ===
--- Packages/Moztop/moztop/content/Menu/connection-wizard.xul:1.3	Sat Feb 15 05:56:45 2003
+++ Packages/Moztop/moztop/content/Menu/connection-wizard.xul	Tue Feb 18 10:36:37 2003
@@ -7,32 +7,32 @@
   onwizardfinish="return createSite();"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-<script>
-/* Create a site from the wizard */
-function createSite() {
+  <script type="application/x-javascript" src="connection-wizard.js"/>
 
-  // 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_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 Explorer/Explorer.js
-  sm.addSite(newsite_name, newsite_url, newsite_username, newsite_password);
-}
-</script>
-
-  <wizardpage>
+  <wizardpage onpageadvanced="return verifyValues();">
     <description>
       This Wizard will help you to connect to a new site.
     </description>
-    <label value="Site name:"/>
-    <textbox id="newsite_name" value="localhost"/>
-    <label value="Site URL:"/>
-    <textbox id="newsite_url" value="http://localhost:8080/"/>
+    <hbox>
+      <label value="Site URL:"/>
+      <textbox flex="1" id="newsite_url" value="http://localhost:8080/"/>
+    </hbox>
+    <hbox>
+    <button id="getsiteconfiguration" label="Connect" 
+	    oncommand="getSiteConfiguration();"/><spacer flex="1"/>
+    </hbox>
+
+    <groupbox flex="1">
+      <caption label="Server Response"/>
+      <hbox>
+        <label value="Site name:"/>
+        <label id="newsite_name" style="font-weight: bold" 
+	       value="Not connected."/>
+	<label hidden="true" id="newsite_realm" value="Not connected."/>
+      </hbox>
+      <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">


=== Packages/Moztop/moztop/content/Menu/connection-wizard.js 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/Menu/connection-wizard.js:1.2	Fri Feb  7 10:28:44 2003
+++ Packages/Moztop/moztop/content/Menu/connection-wizard.js	Tue Feb 18 10:36:37 2003
@@ -17,22 +17,70 @@
 
 ******************************************************************************/
 
+
 /* Create a site from the wizard */
-function createSite() {
 
-  // The sitesds was passed in as an argument
-  // var sitesds = window.arguments[0];
+function getSiteConfiguration () {
+    /* Connect to site and retrieve site configuration information */
+
+    var url = document.getElementById("newsite_url").value;
+
+    function myfunc (e) {
+
+	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);
+}
+
+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;
+    }
+
+    return true;
+}
+
+
+function createSite() {
 
-  var prefsdir = getProfileURL();
-  sitesds = new RDFDataSource(prefsdir + "/moztop_sites.rdf");
-  typesds = new RDFDataSource(prefsdir + "/moztop_types.rdf");
+  // 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 Explorer/Explorer.js
-  addSite(newsite_name, newsite_url, newsite_username, newsite_password);
+  sm.addSite(newsite_name, newsite_realm, newsite_url, 
+	     newsite_username, newsite_password);
 }