issue #160 - localStorage; thanks to divinity76
This commit is contained in:
@@ -151,6 +151,8 @@
|
|||||||
<legend id="client"></legend>
|
<legend id="client"></legend>
|
||||||
<input type="button" id="clientsave" />
|
<input type="button" id="clientsave" />
|
||||||
<input type="button" id="clientload" />
|
<input type="button" id="clientload" />
|
||||||
|
<input type="button" id="clientlocalsave" />
|
||||||
|
<input type="button" id="clientlocalload" />
|
||||||
<hr/>
|
<hr/>
|
||||||
<input type="button" id="clientsql" />
|
<input type="button" id="clientsql" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
+67
-1
@@ -1245,7 +1245,7 @@ SQL.IO.prototype.init = function(owner) {
|
|||||||
container:OZ.$("io")
|
container:OZ.$("io")
|
||||||
};
|
};
|
||||||
|
|
||||||
var ids = ["saveload", "clientsave", "clientload", "clientsql",
|
var ids = ["saveload","clientlocalsave", "clientsave", "clientlocalload","clientload", "clientsql",
|
||||||
"quicksave", "serversave", "serverload",
|
"quicksave", "serversave", "serverload",
|
||||||
"serverlist", "serverimport"];
|
"serverlist", "serverimport"];
|
||||||
for (var i=0;i<ids.length;i++) {
|
for (var i=0;i<ids.length;i++) {
|
||||||
@@ -1276,7 +1276,9 @@ SQL.IO.prototype.init = function(owner) {
|
|||||||
this.importresponse = this.bind(this.importresponse);
|
this.importresponse = this.bind(this.importresponse);
|
||||||
|
|
||||||
OZ.Event.add(this.dom.saveload, "click", this.bind(this.click));
|
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.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.clientload, "click", this.bind(this.clientload));
|
||||||
OZ.Event.add(this.dom.clientsql, "click", this.bind(this.clientsql));
|
OZ.Event.add(this.dom.clientsql, "click", this.bind(this.clientsql));
|
||||||
OZ.Event.add(this.dom.quicksave, "click", this.bind(this.quicksave));
|
OZ.Event.add(this.dom.quicksave, "click", this.bind(this.quicksave));
|
||||||
@@ -1354,6 +1356,67 @@ SQL.IO.prototype.clientload = function() {
|
|||||||
this.fromXML(xmlDoc);
|
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() {
|
SQL.IO.prototype.clientsql = function() {
|
||||||
var bp = this.owner.getOption("staticpath");
|
var bp = this.owner.getOption("staticpath");
|
||||||
var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl";
|
var path = bp + "db/"+window.DATATYPES.getAttribute("db")+"/output.xsl";
|
||||||
@@ -1924,6 +1987,7 @@ SQL.KeyManager.prototype.build = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var types = ["PRIMARY","INDEX","UNIQUE","FULLTEXT"];
|
var types = ["PRIMARY","INDEX","UNIQUE","FULLTEXT"];
|
||||||
|
OZ.DOM.clear(this.dom.type);
|
||||||
for (var i=0;i<types.length;i++) {
|
for (var i=0;i<types.length;i++) {
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
o.innerHTML = types[i];
|
o.innerHTML = types[i];
|
||||||
@@ -2219,6 +2283,7 @@ SQL.Options.prototype.build = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ls = CONFIG.AVAILABLE_LOCALES;
|
var ls = CONFIG.AVAILABLE_LOCALES;
|
||||||
|
OZ.DOM.clear(this.dom.optionlocale);
|
||||||
for (var i=0;i<ls.length;i++) {
|
for (var i=0;i<ls.length;i++) {
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
o.value = ls[i];
|
o.value = ls[i];
|
||||||
@@ -2228,6 +2293,7 @@ SQL.Options.prototype.build = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dbs = CONFIG.AVAILABLE_DBS;
|
var dbs = CONFIG.AVAILABLE_DBS;
|
||||||
|
OZ.DOM.clear(this.dom.optiondb);
|
||||||
for (var i=0;i<dbs.length;i++) {
|
for (var i=0;i<dbs.length;i++) {
|
||||||
var o = OZ.DOM.elm("option");
|
var o = OZ.DOM.elm("option");
|
||||||
o.value = dbs[i];
|
o.value = dbs[i];
|
||||||
|
|||||||
@@ -75,6 +75,8 @@
|
|||||||
<string name="output">Vstup / Výstup</string>
|
<string name="output">Vstup / Výstup</string>
|
||||||
<string name="clientsave">Uložit XML</string>
|
<string name="clientsave">Uložit XML</string>
|
||||||
<string name="clientload">Načíst 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="clientsql">Generovat SQL</string>
|
||||||
<string name="backendlabel">Server backend:</string>
|
<string name="backendlabel">Server backend:</string>
|
||||||
<string name="serversave">Uložit</string>
|
<string name="serversave">Uložit</string>
|
||||||
|
|||||||
@@ -75,6 +75,8 @@
|
|||||||
<string name="output">Input / Output</string>
|
<string name="output">Input / Output</string>
|
||||||
<string name="clientsave">Save XML</string>
|
<string name="clientsave">Save XML</string>
|
||||||
<string name="clientload">Load 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="clientsql">Generate SQL</string>
|
||||||
<string name="backendlabel">Server backend:</string>
|
<string name="backendlabel">Server backend:</string>
|
||||||
<string name="serversave">Save</string>
|
<string name="serversave">Save</string>
|
||||||
|
|||||||
+1
-1
@@ -205,7 +205,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#textarea {
|
#textarea {
|
||||||
width: 500px;
|
width: 600px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user