Commits

Yury Shulaev committed 9b2a863

Fix relation types

  • Participants
  • Parent commits 4cdabd7

Comments (0)

Files changed (1)

js/wwwsqldesigner.js

 	this.owner = owner;
 	this.row1 = row1;
 	this.row2 = row2;
+	this.type = type;
 	this.hidden = false;
 	SQL.Visual.prototype.init.apply(this);
-	
+
 	this.row1.addRelation(this);
 	this.row2.addRelation(this);
-	
+
 	this.dom = [];
-	if (CONFIG.RELATION_COLORS) {
-		var colorIndex = this.constructor._counter - 1;
-		var color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
-	} else {
-		var color = "#000";
-	}
-	
+
+	var color = CONFIG.RELATION_COLORS[type];
+
 	if (this.owner.vector) {
 		var path = document.createElementNS(this.owner.svgNS, "path");
 		path.setAttribute("stroke", color);
 			var div = OZ.DOM.elm("div",{position:"absolute",className:"relation",backgroundColor:color});
 			this.dom.push(div);
 			if (i & 1) { /* middle */
-				OZ.Style.set(div,{width:CONFIG.RELATION_THICKNESS+"px"});
+				OZ.Style.set(div,{width:CONFIG.RELATION_THICKNESS[type]+"px"});
 			} else { /* first & last */
-				OZ.Style.set(div,{height:CONFIG.RELATION_THICKNESS+"px"});
+				OZ.Style.set(div,{height:CONFIG.RELATION_THICKNESS[type]+"px"});
 			}
 			this.owner.dom.container.appendChild(div);
 		}
 		container:OZ.$("io")
 	};
 
-	var ids = ["saveload","clientlocalsave", "clientsave", "clientlocalload","clientload", "clientsql", 
+	var ids = ["saveload","clientlocalsave", "clientsave", "clientlocalload","clientload", "clientsql",
 				"quicksave", "serversave", "serverload",
 				"serverlist", "serverimport"];
 	for (var i=0;i<ids.length;i++) {
 }
 
 SQL.IO.prototype.clientlocalsave = function() {
-	if (!window.localStorage) { 
+	if (!window.localStorage) {
 		alert("Sorry, your browser does not seem to support localStorage.");
 		return;
 	}
-	
+
 	var xml = this.owner.toXML();
 	if (xml.length >= (5*1024*1024)/2) { /* this is a very big db structure... */
 		alert("Warning: your database structure is above 5 megabytes in size, this is above the localStorage single key limit allowed by some browsers, example Mozilla Firefox 10");
 
 	var key = prompt(_("serversaveprompt"), this._name) || "default";
 	key = "wwwsqldesigner_databases_"+key;
-	
+
 	try {
 		localStorage.setItem(key, xml);
 		if (localStorage.getItem(key) != xml) { throw new Error("Content verification failed"); }
 
 
 SQL.IO.prototype.clientlocalload = function() {
-	if (!window.localStorage) { 
+	if (!window.localStorage) {
 		alert("Sorry, your browser does not seem to support localStorage.");
 		return;
 	}
-	
+
 	var key = prompt(_("serverloadprompt"), this._name) || "default";
 	key = "wwwsqldesigner_databases_"+key;
-	
+
 	try {
 		var xml = localStorage.getItem(key);
 		if (!xml) { throw new Error("No data available"); }
 		alert("Error loading database structure from localStorage! ("+e.message+")");
 		return;
 	}
-	
+
 	try {
 		if (window.DOMParser) {
 			var parser = new DOMParser();
 		} else {
 			throw new Error("No XML parser available.");
 		}
-	} catch(e) { 
+	} catch(e) {
 		alert(_("xmlerror")+': '+e.message);
 		return;
 	}