Commits

watermelon committed cee5c90

fix bug: Controller.server_url now is set after a successful probe

Comments (0)

Files changed (2)

src/main/client/controller/Controller.js

 
 
 /**
- * bookmaak.controller.Controller.probeServer(Function)
+ * bookmaak.controller.Controller.probeServer(String, Function)
  * 
  * TODO maybe we should replace that by a real login
  * 
+ * **server_url** the url of the server to be probed<br/>
  * **callback**		Is called passing the result as argument.<br/>
  * returns	calls callback with a result as
  * 			{	
  * 				msg: String, textual error message
  * 			};
  **/
-bookmaak.controller.Controller.probeServer = function(callback) {
+bookmaak.controller.Controller.probeServer = function(server_url, callback) {
 	
 	//work around for problem with opera... :(((((( about:config#UserPrefs|AllowFileXHTTPRequest does not work
 	if(jQuery.browser.opera) {
 	
 	//probe server
 	jQuery.ajax({
-		url: bookmaak.controller.Controller.server_url,
+		url: server_url,
 		aync: false,//we want to probe the server before proceeding TODO maybe we change the wohle process and make the login a real login...
 		type: "HEAD",
 		crossDomain: true,

src/main/client/ui/UiController.js

 	var server_url_is_valid = bookmaak.util.validation.validateServerUrl(_server_url);
 	if(server_url_is_valid) {//fix it if necessary
 		
-		//set the server url in Controller.
-		bookmaak.controller.Controller.
-		server_url = bookmaak.util.validation.fixServerUrl(_server_url);
+		_server_url = bookmaak.util.validation.fixServerUrl(_server_url);
+		console.log("server url fixed:"+_server_url);
 		
-		console.log("server url fixed:"+bookmaak.controller.Controller.server_url);
-	}
-	else {
-		
-		bookmaak.ui.UiController.printErrorMessage("Invalid server url");
-	}
-	
-	//try to contact server
-	if(server_url_is_valid) {
-		
-		bookmaak.controller.Controller.probeServer(function(probe) {
+		//try to contact server
+		bookmaak.controller.Controller.probeServer(_server_url, function(probe) {
 			
 			if(probe.success){
 				
 					
 				bookmaak.ui.UiController.printSuccessMessage(success_text);
 				
+				//set the server url in Controller.
+				bookmaak.controller.Controller.server_url = _server_url;
 				
-				showConnectViewConnected(_server_url);
+				showConnectViewConnected(bookmaak.controller.Controller.server_url);
 				
 				//TODO we skip connection view for development
 				showLoginView();
 			}
 		});
 	}
+	else {
+		
+		bookmaak.ui.UiController.printErrorMessage("Invalid server url");
+	}
 };
 
 /**