Commits

Yury Shulaev committed 4cdabd7 Merge

Merge with origin

  • Participants
  • Parent commits 4578ecd, 47b5eef

Comments (0)

Files changed (7)

File db/mysql/datatypes.xml

 		<type label="YEAR" length="0" sql="YEAR" quote="" />
 		<type label="TIMESTAMP" length="0" sql="TIMESTAMP" quote="'" />
 	</group>
-
+	
 	<group label="Miscellaneous" color="rgb(200,200,255)">
 		<type label="ENUM" length="1" sql="ENUM" quote="" />
 		<type label="SET" length="1" sql="SET" quote="" />
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <!--
-	WWW SQL Designer, (C) 2005-2011 Ondrej Zara, ondras@zarovi.cz
-	Version: 2.6
+	WWW SQL Designer, (C) 2005-2012 Ondrej Zara, ondras@zarovi.cz
+	Version: 2.7
 	See license.txt for licencing information.
 -->
 <html xmlns="http://www.w3.org/1999/xhtml">
 						* <label id="language" for="optionlocale"></label>
 					</td>
 					<td>
-						<select id="optionlocale"></select>
+						<select id="optionlocale"><option></option></select>
 					</td>
 				</tr>
 				<tr>
 						* <label id="db" for="optiondb"></label>
 					</td>
 					<td>
-						<select id="optiondb"></select>
+						<select id="optiondb"><option></option></select>
 					</td>
 				</tr>
 				<tr>
 							<legend id="client"></legend>
 							<input type="button" id="clientsave" />
 							<input type="button" id="clientload" />
+							<input type="button" id="clientlocalsave" />
+							<input type="button" id="clientlocalload" />
 							<hr/>
 							<input type="button" id="clientsql" />
 						</fieldset>
 					<td>
 						<fieldset>
 							<legend id="server"></legend>
-							<label for="backend" id="backendlabel"></label> <select id="backend"></select>
+							<label for="backend" id="backendlabel"></label> <select id="backend"><option></option></select>
 							<hr/>
 							<input type="button" id="serversave" />
 							<input type="button" id="quicksave" />
 					<td colspan="2">
 						<fieldset>
 							<legend id="output"></legend>
-							<textarea id="textarea"></textarea>
+							<textarea id="textarea" rows="1" cols="1"></textarea><!--modified by javascript later-->
 						</fieldset>
 					</td>
 				</tr>
 
 	<div id="keys">
 		<fieldset>
-			<legend id="keyslistlabel"></legend>
-			<select id="keyslist"></select>
+			<legend id="keyslistlabel"></legend> 
+			<select id="keyslist"><option></option></select>
 			<input type="button" id="keyadd" />
 			<input type="button" id="keyremove" />
 		</fieldset>
 					<tr>
 						<td>
 							<label for="keytype" id="keytypelabel"></label>
-							<select id="keytype"></select>
+							<select id="keytype"><option></option></select>
 						</td>
 						<td></td>
 						<td>
 					<tr>
 						<td>
 							<label for="keyfields" id="keyfieldslabel"></label><br/>
-							<select id="keyfields" size="5" multiple="multiple"></select>
+							<select id="keyfields" size="5" multiple="multiple"><option></option></select>
 						</td>
 						<td>
 							<input type="button" id="keyleft" value="&lt;&lt;" /><br/>
 						</td>
 						<td>
 							<label for="keyavail" id="keyavaillabel"></label><br/>
-							<select id="keyavail" size="5" multiple="multiple"></select>
+							<select id="keyavail" size="5" multiple="multiple"><option></option></select>
 						</td>
 					</tr>
 				</tbody>

File 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 = [];
-
-	var color = CONFIG.RELATION_COLORS[type];
-
+	if (CONFIG.RELATION_COLORS) {
+		var colorIndex = this.constructor._counter - 1;
+		var color = CONFIG.RELATION_COLORS[colorIndex % CONFIG.RELATION_COLORS.length];
+	} else {
+		var color = "#000";
+	}
+	
 	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[type]+"px"});
+				OZ.Style.set(div,{width:CONFIG.RELATION_THICKNESS+"px"});
 			} else { /* first & last */
-				OZ.Style.set(div,{height:CONFIG.RELATION_THICKNESS[type]+"px"});
+				OZ.Style.set(div,{height:CONFIG.RELATION_THICKNESS+"px"});
 			}
 			this.owner.dom.container.appendChild(div);
 		}
 	this.redraw();
 }
 
+SQL.Relation.prototype.getColor = function() {
+	return this.color;
+}
+
 SQL.Relation.prototype.show = function() {
 	this.hidden = false;
 	for (var i=0;i<this.dom.length;i++) {
 		container:OZ.$("io")
 	};
 
-	var ids = ["saveload", "clientsave", "clientload", "clientsql",
+	var ids = ["saveload","clientlocalsave", "clientsave", "clientlocalload","clientload", "clientsql", 
 				"quicksave", "serversave", "serverload",
 				"serverlist", "serverimport"];
 	for (var i=0;i<ids.length;i++) {
 	this.importresponse = this.bind(this.importresponse);
 
 	OZ.Event.add(this.dom.saveload, "click", this.bind(this.click));
+	OZ.Event.add(this.dom.clientlocalsave, "click", this.bind(this.clientlocalsave));
 	OZ.Event.add(this.dom.clientsave, "click", this.bind(this.clientsave));
+	OZ.Event.add(this.dom.clientlocalload, "click", this.bind(this.clientlocalload));
 	OZ.Event.add(this.dom.clientload, "click", this.bind(this.clientload));
 	OZ.Event.add(this.dom.clientsql, "click", this.bind(this.clientsql));
 	OZ.Event.add(this.dom.quicksave, "click", this.bind(this.quicksave));
 	this.fromXML(xmlDoc);
 }
 
+SQL.IO.prototype.clientlocalsave = function() {
+	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");
+		return;
+	}
+
+	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"); }
+	} catch (e) {
+		alert("Error saving database structure to localStorage! ("+e.message+")");
+	}
+}
+
+
+
+SQL.IO.prototype.clientlocalload = function() {
+	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"); }
+	} catch (e) {
+		alert("Error loading database structure from localStorage! ("+e.message+")");
+		return;
+	}
+	
+	try {
+		if (window.DOMParser) {
+			var parser = new DOMParser();
+			var xmlDoc = parser.parseFromString(xml, "text/xml");
+		} else if (window.ActiveXObject) {
+			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
+			xmlDoc.loadXML(xml);
+		} else {
+			throw new Error("No XML parser available.");
+		}
+	} catch(e) { 
+		alert(_("xmlerror")+': '+e.message);
+		return;
+	}
+
+	this.fromXML(xmlDoc);
+}
+
+
 SQL.IO.prototype.clientsql = function() {
 	var bp = this.owner.getOption("staticpath");
 	var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl";
-Copyright (c) 2005-2010, Ondrej Zara
+Copyright (c) 2005-2012, Ondrej Zara
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification, 

File locale/cs.xml

 	<string name="output">Vstup / Výstup</string>
 	<string name="clientsave">Uložit XML</string>
 	<string name="clientload">Načíst XML</string>
+	<string name="clientlocalsave">Uložit v prohlížeči</string>
+	<string name="clientlocalload">Načíst z prohlížeče</string>
 	<string name="clientsql">Generovat SQL</string>
 	<string name="backendlabel">Server backend:</string>
 	<string name="serversave">Uložit</string>

File locale/en.xml

 	<string name="output">Input / Output</string>
 	<string name="clientsave">Save XML</string>
 	<string name="clientload">Load XML</string>
+	<string name="clientlocalsave">Save in Browser</string>
+	<string name="clientlocalload">Load from Browser</string>
 	<string name="clientsql">Generate SQL</string>
 	<string name="backendlabel">Server backend:</string>
 	<string name="serversave">Save</string>

File styles/style.css

File contents unchanged.