dropbox conf in config.js, fixed button hiding

This commit is contained in:
Ondrej Zara
2015-06-12 09:40:15 +02:00
parent b3bf2bd8ec
commit 6fb6ba452f
3 changed files with 55 additions and 61 deletions
+14 -1
View File
@@ -13,5 +13,18 @@ var CONFIG = {
RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"], RELATION_COLORS: ["#000", "#800", "#080", "#008", "#088", "#808", "#088"],
STATIC_PATH: "", STATIC_PATH: "",
XHR_PATH: "" XHR_PATH: "",
/*
* The key below needs to be set individually by you if you want to use the Dropbox load/save feature.
* To do that, first sign up with Dropbox (may require a specific developer / SDK sign-up), go to
* https://www.dropbox.com/developers/apps and use "Create app" to add a new app. Call it, for instance,
* "wwwsqldesigner", and give it the "App Folder" permission. Unter "OAuth 2", "Redirect URIs", add
* the URL to the "dropbox-oauth-receiver.html" file on your server. E.g, if you install wwwsqldesigner
* on your local web server under "http://localhost/sqldesigner/", then add
* http://localhost/sqldesigner/dropbox-oauth-receiver.html as a Redirection URI.
* Copy the shown "App key" and paste it here below:
*/
DROPBOX_KEY: null // "your app key";
} }
-17
View File
@@ -1,20 +1,3 @@
/* -------------------- configuration -------------------- */
/*
* The key below needs to be set individually by you if you want to use the Dropbox load/save feature.
* To do that, first sign up with Dropbox (may require a specific developer / SDK sign-up), go to
* https://www.dropbox.com/developers/apps and use "Create app" to add a new app. Call it, for instance,
* "wwwsqldesigner", and give it the "App Folder" permission. Unter "OAuth 2", "Redirect URIs", add
* the URL to the "dropbox-oauth-receiver.html" file on your server. E.g, if you install wwwsqldesigner
* on your local web server under "http://localhost/sqldesigner/", then add
* http://localhost/sqldesigner/dropbox-oauth-receiver.html as a Redirection URI.
* Copy the shown "App key" and paste it here below:
*/
var dropboxAppKey = null; // "your app key";
/* -------------------- globals -------------------- */
function _(str) { /* getText */ function _(str) { /* getText */
if (!(str in window.LOCALE)) { return str; } if (!(str in window.LOCALE)) { return str; }
return window.LOCALE[str]; return window.LOCALE[str];
+41 -43
View File
@@ -32,7 +32,10 @@ SQL.IO.prototype.init = function(owner) {
this.dom.ta = OZ.$("textarea"); this.dom.ta = OZ.$("textarea");
this.dom.backend = OZ.$("backend"); 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.parentNode.removeChild(this.dom.container);
this.dom.container.style.visibility = ""; 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(this.dom.serverimport, "click", this.bind(this.serverimport));
OZ.Event.add(document, "keydown", this.bind(this.press)); OZ.Event.add(document, "keydown", this.bind(this.press));
this.build(); this.build();
this.dropBoxInit ();
} }
SQL.IO.prototype.build = function() { SQL.IO.prototype.build = function() {
@@ -191,52 +192,49 @@ SQL.IO.prototype.clientlocalload = function() {
} }
SQL.IO.prototype.clientlocallist = function() { SQL.IO.prototype.clientlocallist = function() {
if (!window.localStorage) { if (!window.localStorage) {
alert("Sorry, your browser does not seem to support localStorage."); alert("Sorry, your browser does not seem to support localStorage.");
return; return;
} }
/* --- Define some useful vars --- */ /* --- Define some useful vars --- */
var baseKeysName = "wwwsqldesigner_databases_"; var baseKeysName = "wwwsqldesigner_databases_";
var localLen = localStorage.length; var localLen = localStorage.length;
var data = ""; var data = "";
var schemasFound = false; var schemasFound = false;
var code = 200; var code = 200;
/* --- work --- */ /* --- work --- */
try { try {
for (var i = 0; i< localLen; ++i) { for (var i = 0; i< localLen; ++i) {
var key = localStorage.key(i); var key = localStorage.key(i);
if((new RegExp(baseKeysName)).test(key)) { if((new RegExp(baseKeysName)).test(key)) {
var result = key.substring(baseKeysName.length); var result = key.substring(baseKeysName.length);
schemasFound = true; schemasFound = true;
data += result + "\n"; data += result + "\n";
} }
} }
if (!schemasFound) { if (!schemasFound) {
throw new Error("No data available"); throw new Error("No data available");
} }
} catch (e) { } catch (e) {
alert("Error loading database names from localStorage! ("+e.message+")"); alert("Error loading database names from localStorage! ("+e.message+")");
return; return;
} }
this.listresponse(data, code); this.listresponse(data, code);
} }
/* ------------------------- Dropbox start ------------------------ */ /* ------------------------- Dropbox start ------------------------ */
/* /**
* The following code uses this lib: https://github.com/dropbox/dropbox-js * The following code uses this lib: https://github.com/dropbox/dropbox-js
*/ */
SQL.IO.prototype.dropBoxInit = function() {
SQL.IO.prototype.dropBoxInit = function() if (CONFIG.DROPBOX_KEY) {
{ this.dropboxClient = new Dropbox.Client({ key: CONFIG.DROPBOX_KEY });
if (dropboxAppKey) { } else {
this.dropboxClient = new Dropbox.Client({ key: dropboxAppKey });
} else {
this.dropboxClient = null; this.dropboxClient = null;
// Hide the Dropbox buttons
// Hide the Dropbox buttons and divider
var elems = document.querySelectorAll("[id^=dropbox]"); // gets all tags whose id start with "dropbox" var elems = document.querySelectorAll("[id^=dropbox]"); // gets all tags whose id start with "dropbox"
[].slice.call(elems).forEach( [].slice.call(elems).forEach(
function(elem) { elem.style.display = "none"; } function(elem) { elem.style.display = "none"; }
@@ -349,7 +347,7 @@ SQL.IO.prototype.dropboxload = function() {
SQL.IO.prototype.dropboxlist = function() { SQL.IO.prototype.dropboxlist = function() {
if (!this.showDropboxAuthenticate()) return; if (!this.showDropboxAuthenticate()) return;
var sql_io = this; var sql_io = this;
sql_io.listresponse("Loading...", 200); sql_io.listresponse("Loading...", 200);
this.dropboxClient.readdir("/", function(error, entries) { this.dropboxClient.readdir("/", function(error, entries) {