summaryrefslogtreecommitdiffstats
path: root/js/io.js
diff options
context:
space:
mode:
authorOndrej Zara <ondrej.zara@firma.seznam.cz>2015-06-12 09:40:15 +0200
committerOndrej Zara <ondrej.zara@firma.seznam.cz>2015-06-12 09:40:15 +0200
commit6fb6ba452f2bd616b6fe8d2edd0273e63b6e3f62 (patch)
tree58f9be7ce76ea934c0b9ed5f12d200151e5f9df9 /js/io.js
parentb3bf2bd8ecc9bd175793f67c46a8319b7d67174c (diff)
downloadwwwsqldesigner-6fb6ba452f2bd616b6fe8d2edd0273e63b6e3f62.zip
wwwsqldesigner-6fb6ba452f2bd616b6fe8d2edd0273e63b6e3f62.tar.gz
wwwsqldesigner-6fb6ba452f2bd616b6fe8d2edd0273e63b6e3f62.tar.bz2
dropbox conf in config.js, fixed button hiding
Diffstat (limited to 'js/io.js')
-rw-r--r--js/io.js84
1 files changed, 41 insertions, 43 deletions
diff --git a/js/io.js b/js/io.js
index 1fdc3c4..55dadfb 100644
--- a/js/io.js
+++ b/js/io.js
@@ -32,7 +32,10 @@ SQL.IO.prototype.init = function(owner) {
this.dom.ta = OZ.$("textarea");
this.dom.backend = OZ.$("backend");
-
+
+ /* init dropbox before hiding the container so it can adjust its buttons */
+ this.dropBoxInit();
+
this.dom.container.parentNode.removeChild(this.dom.container);
this.dom.container.style.visibility = "";
@@ -58,8 +61,6 @@ SQL.IO.prototype.init = function(owner) {
OZ.Event.add(this.dom.serverimport, "click", this.bind(this.serverimport));
OZ.Event.add(document, "keydown", this.bind(this.press));
this.build();
-
- this.dropBoxInit ();
}
SQL.IO.prototype.build = function() {
@@ -191,52 +192,49 @@ SQL.IO.prototype.clientlocalload = function() {
}
SQL.IO.prototype.clientlocallist = function() {
- if (!window.localStorage) {
- alert("Sorry, your browser does not seem to support localStorage.");
- return;
- }
-
- /* --- Define some useful vars --- */
- var baseKeysName = "wwwsqldesigner_databases_";
- var localLen = localStorage.length;
- var data = "";
- var schemasFound = false;
- var code = 200;
-
- /* --- work --- */
- try {
- for (var i = 0; i< localLen; ++i) {
- var key = localStorage.key(i);
- if((new RegExp(baseKeysName)).test(key)) {
- var result = key.substring(baseKeysName.length);
- schemasFound = true;
- data += result + "\n";
- }
- }
- if (!schemasFound) {
- throw new Error("No data available");
- }
- } catch (e) {
- alert("Error loading database names from localStorage! ("+e.message+")");
- return;
- }
- this.listresponse(data, code);
+ if (!window.localStorage) {
+ alert("Sorry, your browser does not seem to support localStorage.");
+ return;
+ }
+
+ /* --- Define some useful vars --- */
+ var baseKeysName = "wwwsqldesigner_databases_";
+ var localLen = localStorage.length;
+ var data = "";
+ var schemasFound = false;
+ var code = 200;
+
+ /* --- work --- */
+ try {
+ for (var i = 0; i< localLen; ++i) {
+ var key = localStorage.key(i);
+ if((new RegExp(baseKeysName)).test(key)) {
+ var result = key.substring(baseKeysName.length);
+ schemasFound = true;
+ data += result + "\n";
+ }
+ }
+ if (!schemasFound) {
+ throw new Error("No data available");
+ }
+ } catch (e) {
+ alert("Error loading database names from localStorage! ("+e.message+")");
+ return;
+ }
+ this.listresponse(data, code);
}
/* ------------------------- Dropbox start ------------------------ */
-/*
+/**
* The following code uses this lib: https://github.com/dropbox/dropbox-js
*/
-
-SQL.IO.prototype.dropBoxInit = function()
-{
- if (dropboxAppKey) {
- this.dropboxClient = new Dropbox.Client({ key: dropboxAppKey });
-} else {
+SQL.IO.prototype.dropBoxInit = function() {
+ if (CONFIG.DROPBOX_KEY) {
+ this.dropboxClient = new Dropbox.Client({ key: CONFIG.DROPBOX_KEY });
+ } else {
this.dropboxClient = null;
-
- // Hide the Dropbox buttons and divider
+ // Hide the Dropbox buttons
var elems = document.querySelectorAll("[id^=dropbox]"); // gets all tags whose id start with "dropbox"
[].slice.call(elems).forEach(
function(elem) { elem.style.display = "none"; }
@@ -349,7 +347,7 @@ SQL.IO.prototype.dropboxload = function() {
SQL.IO.prototype.dropboxlist = function() {
if (!this.showDropboxAuthenticate()) return;
-
+
var sql_io = this;
sql_io.listresponse("Loading...", 200);
this.dropboxClient.readdir("/", function(error, entries) {