[isidorus-cvs] r47 - in trunk/src/ajax: css javascripts

Lukas Giessmann lgiessmann at common-lisp.net
Thu Jun 18 15:05:10 UTC 2009


Author: lgiessmann
Date: Thu Jun 18 11:05:08 2009
New Revision: 47

Log:
ajax-client: fixed a bug with exclusive-instance-constraints; changes: associations created from constraints are initialy disabled; during ajax-requests there will be hidden the entire content. instead of the content there will be shown a message with some information what the client is doing at the moment - but this should be displaced by a loader-gif or something

Modified:
   trunk/src/ajax/css/main.css
   trunk/src/ajax/javascripts/constants.js
   trunk/src/ajax/javascripts/create.js
   trunk/src/ajax/javascripts/datamodel.js
   trunk/src/ajax/javascripts/requests.js

Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css	(original)
+++ trunk/src/ajax/css/main.css	Thu Jun 18 11:05:08 2009
@@ -47,6 +47,12 @@
 }
 
 .errorMessage {
+    margin: 0.5em;
     color: red;
     font-size: 0.85em;
+}
+
+div.loadFrame {
+    padding: 2em;
+    color: #ff7f00;
 }
\ No newline at end of file

Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js	(original)
+++ trunk/src/ajax/javascripts/constants.js	Thu Jun 18 11:05:08 2009
@@ -32,6 +32,9 @@
 var STRING = "http://www.w3.org/2001/XMLSchema#string";
 var CURRENT_TOPIC = "**current-topic**";
 var CURRENT_TOPIC_ESCAPED = "\\*\\*current-topic\\*\\*";
+var INIT_DATE = ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"];
+var MAX_INT = "MAX_INT";
+var MMAX_INT = "*";
 
 // --- Contains most css classes used in this project
 // --- There should be called only the function to be sure to don't override
@@ -77,6 +80,7 @@
 	       "__divFog__" : "fog",
 	       "__inputCommitButton__" : "commitButton",
 	       "__divTmIdFrame__" : "tmIdFrame",
+	       "__divLoad__" : "loadFrame",
 
 	       "page" : function(){ return this.__divPage__; },
 	       "subPage" : function(){ return this.__divSubPage__; },
@@ -117,5 +121,6 @@
 	       "deselect" : function(){ return this.__spanDeselect__; },
 	       "fog" : function(){ return this.__divFog__; },
 	       "commitButton" : function(){ return this.__inputCommitButton__; },
-	       "tmIdFrame" : function(){ return this.__divTmIdFrame__; }
+	       "tmIdFrame" : function(){ return this.__divTmIdFrame__; },
+	       "load" : function(){ return this.__divLoad__; }
 	      };
\ No newline at end of file

Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js	(original)
+++ trunk/src/ajax/javascripts/create.js	Thu Jun 18 11:05:08 2009
@@ -26,26 +26,7 @@
 	
 	function makeInstanceOfFrame(context){
 	    function makeFragment(psis, constraints){
-		var items = $$("li." + CLASSES.topicFrame());
-		for(var i = 0; i != items.length; ++i){
-		    items[i].remove();
-		}
-
-		items = $$("li." + CLASSES.associationContainer());
-		for(var i = 0; i != items.length; ++i){
-		    items[i].remove();
-		}
-
-		items = $$("li." + CLASSES.tmIdFrame());
-		for(var i = 0; i !== items.length; ++i){
-		    items[i].remove();
-		}
-
-		items = $$("li." + CLASSES.commitButton());
-		for(var i = 0; i !== items.length; ++i){
-		    items[i].remove();
-		}
-		
+		clearFragment();
 		var instanceOfs = new Array();
 		for(var i = 0; psis && i !== psis.length; ++i){
 		    instanceOfs.push(new Array(psis[i]));
@@ -115,8 +96,7 @@
 		var liCB = new Element("li", {"class" : CLASSES.commitButton()});
 		liCB.update(commitButton);
 		liTm.insert({"after" : liCB});
-		
-	    }
+	    } //makeFragment
 
 	    function onSuccessHandler(xhr){
 		var json = null;
@@ -134,13 +114,38 @@
 		catch(innerErr){
 		    alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
 		}
-	    }
+	    } //onSuccessHandler
 
 	    getTypePsis(onSuccessHandler, null);
-	}
+	} //makeInstanceOfFrame
 
 	makeInstanceOfFrame(liTopicSelect);
     }catch(err){
 	alert(err);
     }
+}
+
+
+// --- removes old elements from the fragment frame
+function clearFragment()
+{
+    var items = $$("li." + CLASSES.topicFrame());
+    for(var i = 0; i != items.length; ++i){
+	items[i].remove();
+    }
+    
+    items = $$("li." + CLASSES.associationContainer());
+    for(var i = 0; i != items.length; ++i){
+	items[i].remove();
+    }
+    
+    items = $$("li." + CLASSES.tmIdFrame());
+    for(var i = 0; i !== items.length; ++i){
+	items[i].remove();
+    }
+    
+    items = $$("li." + CLASSES.commitButton());
+    for(var i = 0; i !== items.length; ++i){
+	items[i].remove();
+    }
 }
\ No newline at end of file

Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js	(original)
+++ trunk/src/ajax/javascripts/datamodel.js	Thu Jun 18 11:05:08 2009
@@ -294,6 +294,7 @@
 
                                             	    myself.__commit__.observe("click", function(event){
 							myself.hideError();
+							clearFragment();
                                                         requestConstraints(myself.toJSON(true), onSuccessHandler, null);
                                                     });
                                                 }
@@ -395,7 +396,7 @@
 							for(var i = 0; i != constraints.length; ++i){
 							    this.__containers__.push(new Object());
 							    var min = parseInt(constraints[i].cardMin);
-							    var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+							    var max = constraints[i].cardMax !== MAX_INT ? parseInt(constraints[i].cardMax) : MMAX_INT;
 							    if(max !== 0){
 								var cssTitle = "min: " + min + "   max: " + max + "   regular expression: " + constraints[i].regexp;
 								for(var j = 0; j != (min === 0 ? 1 : min); ++j){
@@ -403,7 +404,7 @@
 								    var dblClickHandler = null;
 								    if(min === 0) dblClickHandler = dblClickHandlerF;
 								    var row = new TextrowC("", constraints[i].regexp, this.__containers__[i],
-											   min === 0 ? 1 : min, max === "*" ? -1 : max, cssTitle, dblClickHandler);
+											   min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, cssTitle, dblClickHandler);
 								    row.dblClick();
 								    this.__error__.insert({"before" : row.getFrame()});
 								}
@@ -470,7 +471,7 @@
 						    for(var i = 0; i !== this.__constraints__.length; ++i){
 							var regexp = new RegExp(this.__constraints__[i].regexp);
 							var cardMin = parseInt(this.__constraints__[i].cardMin);
-							var cardMax = this.__constraints__[i].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].cardMax);
+							var cardMax = this.__constraints__[i].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].cardMax);
 							var currentIdentifiers = new Array();
 							for(var j = 0; j !== allIdentifiers.length; ++j){
 							    if(regexp.match(allIdentifiers[j].getContent()) === true) currentIdentifiers.push(allIdentifiers[j]);
@@ -482,7 +483,7 @@
 							    errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
 							    ret = false;
 							}
-							if(cardMax !== "*" && cardMax < currentIdentifiers.length){
+							if(cardMax !== MMAX_INT && cardMax < currentIdentifiers.length){
 							    errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
 							    ret = false;
 							}
@@ -773,7 +774,7 @@
 							for(var i = 0; i != constraints.length; ++i){
 							    var scopeTypes = constraints[i].scopeTypes;
 							    var min = parseInt(constraints[i].cardMin);
-							    var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+							    var max = constraints[i].cardMax !== MAX_INT ? parseInt(constraints[i].cardMax) : MMAX_INT;
 							    
 							    // TODO: check and adds contents to the types
 							    
@@ -781,7 +782,7 @@
 							    if(min === 0){ // TODO: check contents of this type
 								scopeTypes.unshift(new Array(new Array(""))); // [[""]]
 							    }
-							    this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === "*" ? -1 : max));
+							    this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === MMAX_INT ? -1 : max));
 							    this.__error__.insert({"before" : this.__container__[this.__container__.length - 1].getFrame()});
 							}
 						    }
@@ -1071,7 +1072,7 @@
 					      // --- value
 					      this.__value__ = new Object();
 					      var _min = parseInt(simpleConstraint.cardMin);
-					      var _max = simpleConstraint.cardMax !== "MAX_INT" ? parseInt(simpleConstraint.cardMax) : "*";
+					      var _max = simpleConstraint.cardMax !== MAX_INT ? parseInt(simpleConstraint.cardMax) : MMAX_INT;
 					      var cssTitleV = "min: " + _min + "   max: " + _max + "   regular expression: " + (simpleConstraint ? simpleConstraint.regexp : ".*");
 					      this.__cssTitle__ = cssTitle;
 					      new TextrowC((contents ? contents.value : ""), (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
@@ -1179,7 +1180,7 @@
 							       for(var j = 0; j != constraints[i].constraints.length; ++j){
 								   this.__containers__[i].push(new Object());
 								   var min = parseInt(constraints[i].constraints[j].cardMin);
-								   var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
+								   var max = constraints[i].constraints[j].cardMax !== MAX_INT ? parseInt(constraints[i].constraints[j].cardMax) : MMAX_INT;
 								   var regexp = constraints[i].constraints[j].regexp;
 								   if(max !== 0){
 								       var dblClickHandler = null;
@@ -1187,7 +1188,7 @@
 
 								       var title = "min: " + min + "   max: " + max + "   regular expression: " + regexp;
 								       for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
-									   var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j], this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+									   var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j], this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler);
 									   if(min === 0)name.disable();
 									   this.__error__.insert({"before" : name.getFrame()});
 									   if(min === 0)name.minimize();
@@ -1300,7 +1301,7 @@
 						       for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
 							   var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
 							   var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
-							   var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+							   var cardMax = this.__constraints__[i].constraints[j].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].constraints[j].cardMax);
 							   var matchedNames = 0;
 							   for(var k = 0; k !== currentNames.length; ++k){
 							       if(regexp.match(currentNames[k].getContent().value) === true){
@@ -1313,7 +1314,7 @@
 							       if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							       errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
 							   }
-							   if(cardMax !== "*" && matchedNames > cardMax){
+							   if(cardMax !== MMAX_INT && matchedNames > cardMax){
 							       ret = false;
 							       if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							       errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
@@ -1381,7 +1382,7 @@
 
 						    // --- resource value and datatype
 						    var _min = parseInt(constraint.cardMin);
-						    var _max = constraint.cardMax !== "MAX_INT" ? parseInt(constraint.cardMax) : "*";
+						    var _max = constraint.cardMax !== MAX_INT ? parseInt(constraint.cardMax) : MMAX_INT;
 						    var cssTitle = "min: " + _min + "   max: " + _max + "   regular expression: " + constraint.regexp;
 						    this.__cssTitle__ = cssTitle;
 						    makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle);
@@ -1493,7 +1494,7 @@
 								     for(var j = 0; j != constraints[i].constraints.length; ++j){
 									 this.__containers__[i].push(new Object());
 									 var min = parseInt(constraints[i].constraints[j].cardMin);
-									 var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
+									 var max = constraints[i].constraints[j].cardMax !== MAX_INT ? parseInt(constraints[i].constraints[j].cardMax) : MMAX_INT;
 									 var regexp = constraints[i].constraints[j].regexp;
 									 if(max !== 0){
 									     var dblClickHandler = null;
@@ -1501,7 +1502,7 @@
 
 									     var title = "min: " + min + "   max: " + max + "   regular expression: " + regexp;
 									     for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
-										 var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+										 var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler);
 										 if(min === 0) occurrence.disable();
 										 this.__error__.insert({"before" : occurrence.getFrame()});
 										 if(min === 0)occurrence.minimize();
@@ -1572,7 +1573,7 @@
 							     for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
 								 var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
 								 var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
-								 var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+								 var cardMax = this.__constraints__[i].constraints[j].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].constraints[j].cardMax);
 								 var matchedOccurrences = 0;
 								 for(var k = 0; k !== currentOccurrences.length; ++k){
 								     var value = currentOccurrences[k].getContent().resourceRef;
@@ -1589,7 +1590,7 @@
 								     if(errorStr.length !== 0) errorStr += "<br/><br/>";
 								     errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
 								 }
-								 if(cardMax !== "*" && matchedOccurrences > cardMax){
+								 if(cardMax !== MMAX_INT && matchedOccurrences > cardMax){
 								     ret = false;
 								     if(errorStr.length !== 0) errorStr += "<br/><br/>";
 								     errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
@@ -2170,7 +2171,7 @@
 						   if(!role || !constraint) return;
 						   var cOtherPlayers = constraint.otherPlayers;
 						   var cOtherRoleType = constraint.otherRoleType;
-						   var cardMax = constraint.cardMax === "MAX_INT" ? "*" : parseInt(constraint.cardMax);
+						   var cardMax = constraint.cardMax === MAX_INT ? MMAX_INT : parseInt(constraint.cardMax);
 						   var cardMin = parseInt(constraint.cardMin);
 						   var existingRoles = this.getExistingRoles(cOtherRoleType, cOtherPlayers, this.__orContainer__.__frames__);
 						   var cleanedPlayers = new Array();
@@ -2199,7 +2200,7 @@
 					       "__checkARCButtons__" : function(rolesToCheck, players, associationRoleConstraint){
 						   if(!rolesToCheck || !associationRoleConstraint) return;
 						   var cardMin = associationRoleConstraint.cardMin === 0 ? 1 : parseInt(associationRoleConstraint.cardMin);
-						   var cardMax = associationRoleConstraint.cardMax === "MAX_INT" ? "*" : parseInt(associationRoleConstraint.cardMax);
+						   var cardMax = associationRoleConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(associationRoleConstraint.cardMax);
 						   var lenPlayers = players ? players.length : 0;
 						   if(cardMin < rolesToCheck.length) {
 						       for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].showRemoveButton();
@@ -2208,7 +2209,7 @@
 						       for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].hideRemoveButton();
 						   }
 
-						   if(cardMax === "*" || cardMax > rolesToCheck.length && rolesToCheck.length < lenPlayers){
+						   if(cardMax === MMAX_INT || cardMax > rolesToCheck.length && rolesToCheck.length < lenPlayers){
 						       for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].showAddButton();
 						   }
 						   else {
@@ -2222,7 +2223,7 @@
 						   function addHandler(myself){
 						       var cOtherPlayers = currentConstraint.otherPlayers;
 						       var cOtherRoleType = currentConstraint.otherRoleType;
-						       var cardMax = currentConstraint.cardMax === "MAX_INT" ? "*" : parseInt(currentConstraint.cardMax);
+						       var cardMax = currentConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(currentConstraint.cardMax);
 						       var cardMin = currentConstraint.cardMin === 0 ? 1 : parseInt(currentConstraint.cardMin);
 						       var cardMinOrg = parseInt(currentConstraint.cardMin);;
 						       var existingRoles = roleContainer.getExistingRoles(cOtherRoleType, cOtherPlayers, roleContainer.__orContainer__.__frames__);
@@ -2260,7 +2261,7 @@
 						   function removeHandler(myself){
 						       var cOtherPlayers = currentConstraint.otherPlayers;
 						       var cOtherRoleType = currentConstraint.otherRoleType;
-						       var cardMax = currentConstraint.cardMax === "MAX_INT" ? "*" : parseInt(currentConstraint.cardMax);
+						       var cardMax = currentConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(currentConstraint.cardMax);
 						       var cardMin = currentConstraint.cardMin === 0 ? 1 : parseInt(currentConstraint.cardMin);
 						       var playerToAdd = null;
 						       for(var i = 0; i !== cOtherPlayers.length; ++i){
@@ -2283,7 +2284,7 @@
 						   if(!existingRoles) return;
 						   
 						   // --- checks all control buttons after an add or remove operation
-						   if(cardMax !== "*" && existingRoles.length >= cardMax){
+						   if(cardMax !== MMAX_INT && existingRoles.length >= cardMax){
 						       for(var i = 0; i !== existingRoles.length; ++i){
 							   existingRoles[i].hideAddButton();
 						       }
@@ -2319,9 +2320,9 @@
 						       }
 						       
 						       // --- creates a new role
-						       var cardMax = associationRoleConstraint.cardMax === "MAX_INT" ? "*" : parseInt(associationRoleConstraint.cardMax);
+						       var cardMax = associationRoleConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(associationRoleConstraint.cardMax);
 						       var cardMin = parseInt(associationRoleConstraint.cardMin);
-               					       if(cardMax === "*" || cardMax > rolesToCheck.length){
+               					       if(cardMax === MMAX_INT || cardMax > rolesToCheck.length){
 							   var usedPlayers = new Array();
 							   for(var i = 0; i !== rolesToCheck.length; ++i) usedPlayers.push(rolesToCheck[i].getPlayer());
 							   var cleanedPlayers = cleanPlayers(players ? players : new Array(), usedPlayers);
@@ -2582,7 +2583,7 @@
 						       var currentRoles = new Array();
 						       var rType = arcs[i].roleType.flatten();
 						       var cardMin = parseInt(arcs[i].cardMin);
-						       var cardMax = arcs[i].cardMax === "MAX_INT" ? "*" : parseInt(arcs[i].cardMax);
+						       var cardMax = arcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(arcs[i].cardMax);
 						       
 						       // --- collects all roles for the current constraint
 						       for(var j = 0; j !== allAroles.length; ++j){
@@ -2595,7 +2596,7 @@
 							   if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							   errorStr += "card-min of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
 						       }
-						       if(cardMax !== "*" && cardMax < currentRoles.length){
+						       if(cardMax !== MMAX_INT && cardMax < currentRoles.length){
 							   ret = false;
 							   if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							   errorStr += "card-max of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
@@ -2611,14 +2612,14 @@
 							   var players = currentRpcs[i].players;
 							   var pType = currentRpcs[i].playerType.flatten();
 							   cardMin = parseInt(currentRpcs[i].cardMin);
-							   cardMax = currentRpcs[i].cardMax === "MAX_INT" ? "*" : parseInt(currentRpcs[i].cardMax);
+							   cardMax = currentRpcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(currentRpcs[i].cardMax);
 							   var foundRoles = this.getExistingRoles(rType, players, currentRoles);
 							   if(cardMin > foundRoles.length){
 							       ret = false;
 							       if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							       errorStr += "card-min of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
 							   }
-							   if(cardMax !== "*" && cardMax < foundRoles.length){
+							   if(cardMax !== MMAX_INT && cardMax < foundRoles.length){
 							       ret = false;
 							       if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							       errorStr += "card-max of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
@@ -2649,7 +2650,7 @@
 						       var pType = usedOrcs[i].otherPlayerType;
 						       var rType = usedOrcs[i].otherRoleType;
 						       var cardMin = parseInt(usedOrcs[i].cardMin);
-						       var cardMax = usedOrcs[i].cardMax === "MAX_INT" ? "*" : parseInt(usedOrcs[i].cardMax);
+						       var cardMax = usedOrcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(usedOrcs[i].cardMax);
 						       var foundRoles = this.getExistingRoles(rType, players, allOroles);
 						       checkedRoles = checkedRoles.concat(foundRoles);
 						       if(cardMin > foundRoles.length){
@@ -2657,7 +2658,7 @@
 							   if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							   errorStr += "card-min of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
 						       }
-						       if(cardMax !== "*" && cardMax < foundRoles.length){
+						       if(cardMax !== MMAX_INT && cardMax < foundRoles.length){
 							   ret = false;
 							   if(errorStr.length !== 0) errorStr += "<br/><br/>";
 							   errorStr += "card-max of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
@@ -2835,6 +2836,7 @@
 								  td.update(association.getFrame());
 								  tr.update(td);
 								  this.__table__.insert({"bottom" : tr});
+								  association.disable();
 							      }
 							      function setMinimizeHandler(myself){
 								  myself.__caption__.observe("click", function(event){

Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js	(original)
+++ trunk/src/ajax/javascripts/requests.js	Thu Jun 18 11:05:08 2009
@@ -10,6 +10,8 @@
 //+-----------------------------------------------------------------------------
 
 
+
+
 // --- Sets a timeout function which alerts a message.
 function setAjaxTimeout(time, url)
 {
@@ -26,13 +28,32 @@
 function createXHRHandler(handler, timeFun)
 {
     function fun(xhr){
-	clearTimeout(timeFun);
-	handler(xhr);
+	try{
+	    clearTimeout(timeFun);
+	    var loading = $$("div." + CLASSES.load());
+	    if(loading.length === 1) loading[0].remove();
+	    var content = $$("div." + CLASSES.content());
+	    if(content.length === 1) content[0].show();
+	    handler(xhr);
+	}
+	catch(err) {alert("err: " + err); }
     }
     return fun;
 }
 
 
+function onLoad(text)
+{
+    var div = new Element("div", {"class" : CLASSES.load()}).update(content);
+    var content = $$("div." + CLASSES.content());
+    if(content.length === 1){
+	content[0].hide();
+	var load = new Element("div", {"class" : CLASSES.load()}).update(text);
+	content[0].insert({"before" : load});
+    }
+}
+
+
 // --- This is the default error handler of the used ajax.requests.
 function defaultFailureHandler(xhr)
 {
@@ -47,10 +68,11 @@
     try{
 	var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
 	var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
+	onLoad("Requesting all Type PSIs");
 
 	new Ajax.Request(TYPE_PSIS_URL, {
 	    "method" : "get",
-	    "requestHeaders" : ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"],
+	    "requestHeaders" : INIT_DATE,
 	    "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
 	    "onFailure" : createXHRHandler(onFailure, timeFun)});
     }
@@ -67,6 +89,7 @@
     try{
 	var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
 	var timeFun = setAjaxTimeout(TIMEOUT, TMCL_TYPE_URL);
+	onLoad("Requesting all constraints for psis:\<br/>" + psis.gsub("\\[", "").gsub("\\]", ""));
 
 	new Ajax.Request(TMCL_TYPE_URL, {
 	    "method" : "post",
@@ -89,12 +112,13 @@
     try{
 	var topicStubs = new Array();
 
-	if(psis){
+	if(psis && psis.length !== 0){
+	    onLoad("Requesting topicStubs information for<br/>" + psis);
 	    for(var i = 0; i !== psis.length; ++i){
 		var url = GET_STUB_PREFIX + psis[i].gsub("#", "%23");
 		new Ajax.Request(url, {
 		    "method" : "get",
-		    "requestHeaders" : ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"],
+		    "requestHeaders" : INIT_DATE,
 		    "onSuccess" : function(xhr){
 			if(xhr.responseText.length === 0 || xhr.responseText.isJSON() === false) errorHandler("Got bad JSON-Data for \"" + psis[i] + "\"!");
 			else topicStubs.push(xhr.responseText);
@@ -116,11 +140,21 @@
 	    neededTime += delta;
 	    if(delta > maxTimeout && psis && psis.length !== 0){
 		alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
+		var loading = $$("div." + CLASSES.load());
+		if(loading.length === 1) loading[0].remove();
+		var content = $$("div." + CLASSES.content());
+		if(content.length === 1) content[0].show();
 		onFailureHandler();
 		return;
 	    }
 
-	    if(topicStubs.length === psis.length) onSuccessHandler(topicStubs);
+	    if(topicStubs.length === psis.length){
+		var loading = $$("div." + CLASSES.load());
+		if(loading.length === 1) loading[0].remove();
+		var content = $$("div." + CLASSES.content());
+		if(content.length === 1) content[0].show();
+		onSuccessHandler(topicStubs);
+	    }
 	    else setTimeout(checkRequests, delta);
 	}
 
@@ -140,6 +174,7 @@
     try{
 	var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
 	var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
+	onLoad("Committing current fragment to " + COMMIT_URL);
 	
 	new Ajax.Request(COMMIT_URL, {
 	    "method" : "post",




More information about the Isidorus-cvs mailing list