Repaired sync down
This commit is contained in:
parent
6fae74a18e
commit
5becb98e62
13
css/main.css
13
css/main.css
@ -25,12 +25,19 @@ div, span, a, ul, li, textarea, input, button {
|
|||||||
text-shadow: none !important;
|
text-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn, .navbar-inner, .ui-layout-east, .ui-layout-south, textarea, input, .input-append .add-on {
|
.btn, .navbar-inner, .ui-layout-east, .ui-layout-south, textarea, input, .add-on {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border, .dropdown-menu {
|
.dropdown-menu {
|
||||||
border: 1px solid #ddd !important;
|
border: 1px solid #e2e2e2 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-prepend input,
|
||||||
|
.input-prepend .btn,
|
||||||
|
.input-prepend .add-on
|
||||||
|
{
|
||||||
|
border: 1px solid #ebebeb !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-inner .btn {
|
.navbar-inner .btn {
|
||||||
|
183
index.html
183
index.html
@ -22,15 +22,15 @@
|
|||||||
<i class="icon-refresh"></i>
|
<i class="icon-refresh"></i>
|
||||||
</button></li>
|
</button></li>
|
||||||
<li class="btn-group"><button class="btn action-create-file"
|
<li class="btn-group"><button class="btn action-create-file"
|
||||||
title="New local file">
|
title="New local document">
|
||||||
<i class="icon-file"></i>
|
<i class="icon-file"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn" title="Delete local file"
|
<button class="btn" title="Delete local document"
|
||||||
data-toggle="modal" data-target="#modal-remove-file-confirm">
|
data-toggle="modal" data-target="#modal-remove-file-confirm">
|
||||||
<i class="icon-trash"></i>
|
<i class="icon-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn dropdown-toggle" data-toggle="dropdown"
|
<button class="btn dropdown-toggle" data-toggle="dropdown"
|
||||||
title="Open local file">
|
title="Open local document">
|
||||||
<i class="icon-folder-open"></i>
|
<i class="icon-folder-open"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul id="file-selector" class="dropdown-menu">
|
<ul id="file-selector" class="dropdown-menu">
|
||||||
@ -47,27 +47,27 @@
|
|||||||
<li class="dropdown-submenu"><a href="#"><i
|
<li class="dropdown-submenu"><a href="#"><i
|
||||||
class="icon-gdrive"></i> Google Drive</a>
|
class="icon-gdrive"></i> Google Drive</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a class="action-upload-gdrive" href="#">Export
|
<li><a class="action-upload-gdrive" href="#">Export to
|
||||||
to Google Drive</a></li>
|
Google Drive</a></li>
|
||||||
<li><a href="#" data-toggle="modal" data-target="#modal-download-gdrive">Import
|
<li><a href="#" data-toggle="modal"
|
||||||
from Google Drive</a></li>
|
data-target="#modal-download-gdrive">Import from Google
|
||||||
|
Drive</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li class="dropdown-submenu"><a href="#"><i
|
<li class="dropdown-submenu"><a href="#"><i
|
||||||
class="icon-dropbox"></i> Dropbox</a>
|
class="icon-dropbox"></i> Dropbox</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a class="action-upload-dropbox" href="#">Export
|
<li><a class="action-upload-dropbox" href="#">Export to
|
||||||
to Dropbox</a></li>
|
Dropbox</a></li>
|
||||||
<li><a class="action-download-dropbox" href="#">Import
|
<li><a class="action-download-dropbox" href="#">Import
|
||||||
from Dropbox</a></li>
|
from Dropbox</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="#"
|
<li><a href="#" data-toggle="modal"
|
||||||
data-toggle="modal" data-target="#modal-manage-sync"><i
|
data-target="#modal-manage-sync"><i class="icon-refresh"></i>
|
||||||
class="icon-refresh"></i> Manage synchronization</a></li>
|
Manage synchronization</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="#"
|
<li><a href="#" data-toggle="modal"
|
||||||
data-toggle="modal" data-target="#modal-settings"
|
data-target="#modal-settings" class="action-load-settings"><i
|
||||||
class="action-load-settings"><i class="icon-cog"></i>
|
class="icon-cog"></i> Settings</a></li>
|
||||||
Settings</a></li>
|
|
||||||
<li><a href="#" data-toggle="modal"
|
<li><a href="#" data-toggle="modal"
|
||||||
data-target="#modal-about"><i class="icon-question-sign"></i>
|
data-target="#modal-about"><i class="icon-question-sign"></i>
|
||||||
About</a></li>
|
About</a></li>
|
||||||
@ -76,9 +76,9 @@
|
|||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><i class="working-indicator icon-spinner hide"></i></li>
|
<li><i class="working-indicator icon-spinner hide"></i></li>
|
||||||
<li><a class="brand" id="file-title" href="#"
|
<li><a class="brand" id="file-title" href="#"
|
||||||
title="Rename current file"> </a></li>
|
title="Rename current document"> </a></li>
|
||||||
<li class="navbar-form"><input id="file-title-input"
|
<li class="navbar-form"><input id="file-title-input"
|
||||||
type="text" class="span3 hide" placeholder="File title" /></li>
|
type="text" class="span3 hide" placeholder="Document title" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -111,9 +111,13 @@
|
|||||||
<h3>Import</h3>
|
<h3>Import</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Please provide a Google Drive file ID:
|
<p>Please provide a Google Drive file ID:</p>
|
||||||
</p>
|
<div class="input-prepend">
|
||||||
<p><input type="text" class="border span6 gdrive-fileid" placeholder="File ID"></input></p>
|
<span class="add-on"><i class="icon-gdrive"></i></span><input
|
||||||
|
id="gdrive-fileid" type="text" class="span5" placeholder="Google Drive file ID"></input>
|
||||||
|
</div>
|
||||||
|
<p class="muted"><b>NOTE:</b> This will create a local copy of your Google Drive document
|
||||||
|
and synchronize it.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" class="btn" data-dismiss="modal">Cancel</a> <a href="#"
|
<a href="#" class="btn" data-dismiss="modal">Cancel</a> <a href="#"
|
||||||
@ -133,14 +137,20 @@
|
|||||||
is synchronized with these locations:
|
is synchronized with these locations:
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<br class="msg-sync-list hide" />
|
|
||||||
<p class="msg-sync-list hide muted"><b>NOTE:</b> Removing a
|
<p class="msg-sync-list hide muted"><b>NOTE:</b> Removing a
|
||||||
synchronized location will not delete any file.</p>
|
synchronized location will not delete any file.</p>
|
||||||
<p class="msg-no-sync hide">"<span class="file-title"></span>" is
|
<p class="msg-no-sync hide">"<span class="file-title"></span>" is
|
||||||
not synchronized.
|
not synchronized.
|
||||||
</p>
|
</p>
|
||||||
<p class="msg-no-sync hide muted"><b>NOTE:</b> You can add
|
<p>Add a synchronized location manually:</p>
|
||||||
synchronized locations using the top-right menu.</p>
|
<div class="input-prepend input-append">
|
||||||
|
<span class="add-on"><i class="icon-gdrive"></i></span><input
|
||||||
|
id="manual-gdrive-fileid" type="text" class="span5" placeholder="Google Drive file ID"></input>
|
||||||
|
<a class="btn action-manual-gdrive" data-dismiss="modal"><i class="icon-ok"></i></a>
|
||||||
|
</div>
|
||||||
|
<p class="muted"><b>NOTE:</b> Adding a synchronized location will
|
||||||
|
first upload the local document and overwrite the file on the
|
||||||
|
server.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
||||||
@ -178,69 +188,70 @@
|
|||||||
aria-hidden="true">×</button>
|
aria-hidden="true">×</button>
|
||||||
<img src="img/stackedit-promo.png" />
|
<img src="img/stackedit-promo.png" />
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>About:</dt>
|
<dt>About:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://github.com/benweet/stackedit/">GitHub
|
<a target="_blank" href="https://github.com/benweet/stackedit/">GitHub
|
||||||
page</a>
|
page</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
href="https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg">Chrome
|
href="https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg">Chrome
|
||||||
app</a>
|
app</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://twitter.com/stackedit/">Follow
|
<a target="_blank" href="https://twitter.com/stackedit/">Follow
|
||||||
on Twitter</a>
|
on Twitter</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://www.facebook.com/stackedit/">Follow
|
<a target="_blank" href="https://www.facebook.com/stackedit/">Follow
|
||||||
on Facebook</a>
|
on Facebook</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
href="https://plus.google.com/b/110816046787593496375/110816046787593496375">Follow
|
href="https://plus.google.com/b/110816046787593496375/110816046787593496375">Follow
|
||||||
on Google+</a>
|
on Google+</a>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Developer:</dt>
|
<dt>Developer:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://www.benoitschweblin.com">Benoit
|
<a target="_blank" href="http://www.benoitschweblin.com">Benoit
|
||||||
Schweblin</a>
|
Schweblin</a>
|
||||||
<dd>
|
<dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Credits:</dt>
|
<dt>Credits:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://jquery.com/">jQuery</a>
|
<a target="_blank" href="http://jquery.com/">jQuery</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://twitter.github.com/bootstrap/">Bootstrap</a>
|
<a target="_blank" href="http://twitter.github.com/bootstrap/">Bootstrap</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
|
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://code.google.com/p/pagedown/">PageDown</a>
|
<a target="_blank" href="https://code.google.com/p/pagedown/">PageDown</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="http://layout.jquery-dev.net/">UI
|
<a target="_blank" href="http://layout.jquery-dev.net/">UI
|
||||||
Layout</a>
|
Layout</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
<a target="_blank" href="https://github.com/stanlemon/jGrowl/">jGrowl</a>
|
<a target="_blank" href="https://github.com/stanlemon/jGrowl/">jGrowl</a>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>Copyright 2013 <a target="_blank"
|
<p>Copyright 2013 <a target="_blank"
|
||||||
href="http://www.benoitschweblin.com">Benoit Schweblin</a><br />
|
href="http://www.benoitschweblin.com">Benoit Schweblin</a><br />
|
||||||
Licensed under an <a target="_blank"
|
Licensed under an <a target="_blank"
|
||||||
href="http://www.apache.org/licenses/LICENSE-2.0">Apache License</a></p>
|
href="http://www.apache.org/licenses/LICENSE-2.0">Apache License</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -77,9 +77,18 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
});
|
});
|
||||||
$(".action-upload-gdrive").click(uploadGdrive);
|
$(".action-upload-gdrive").click(uploadGdrive);
|
||||||
$(".action-download-gdrive").click(function() {
|
$(".action-download-gdrive").click(function() {
|
||||||
var fileId = $(".gdrive-fileid").val();
|
var input = $("#gdrive-fileid");
|
||||||
$(".gdrive-fileid").val("");
|
var fileId = input.val();
|
||||||
downloadGdrive(fileId);
|
input.val("");
|
||||||
|
if(checkGdriveFileId(fileId) === true) {
|
||||||
|
gdrive.importFiles([fileId]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".action-manual-gdrive").click(function() {
|
||||||
|
var input = $("#manual-gdrive-fileid");
|
||||||
|
var fileId = input.val();
|
||||||
|
input.val("");
|
||||||
|
manualGdrive(fileId);
|
||||||
});
|
});
|
||||||
$(".action-download-dropbox").click(function() {
|
$(".action-download-dropbox").click(function() {
|
||||||
core.showMessage("Sorry, Dropbox synchronization is not yet available.");
|
core.showMessage("Sorry, Dropbox synchronization is not yet available.");
|
||||||
@ -216,7 +225,6 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
synchronizer.useGoogleDrive = useGoogleDrive;
|
|
||||||
|
|
||||||
// Update the file title
|
// Update the file title
|
||||||
var title = localStorage[fileIndex + ".title"];
|
var title = localStorage[fileIndex + ".title"];
|
||||||
@ -243,6 +251,7 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
}
|
}
|
||||||
$("#file-selector").append(li);
|
$("#file-selector").append(li);
|
||||||
}
|
}
|
||||||
|
synchronizer.useGoogleDrive = useGoogleDrive;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove a synchronized location
|
// Remove a synchronized location
|
||||||
@ -280,22 +289,55 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
var content = localStorage[fileIndex + ".content"];
|
var content = localStorage[fileIndex + ".content"];
|
||||||
var title = localStorage[fileIndex + ".title"];
|
var title = localStorage[fileIndex + ".title"];
|
||||||
gdrive.createFile(title, content, function(fileSyncIndex) {
|
gdrive.createFile(title, content, function(fileSyncIndex) {
|
||||||
if (fileSyncIndex) {
|
if (fileSyncIndex === undefined) {
|
||||||
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
|
return;
|
||||||
refreshManageSync();
|
|
||||||
fileManager.updateFileTitles();
|
|
||||||
core.showMessage('"' + title
|
|
||||||
+ '" will now be synchronized on Google Drive.');
|
|
||||||
}
|
}
|
||||||
|
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
|
||||||
|
refreshManageSync();
|
||||||
|
fileManager.updateFileTitles();
|
||||||
|
core.showMessage('"' + title
|
||||||
|
+ '" will now be synchronized on Google Drive.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadGdrive(fileId) {
|
function checkGdriveFileId(fileId) {
|
||||||
fileId = fileId.trim();
|
fileId = fileId.trim();
|
||||||
if(fileId.length === 0) {
|
if(fileId.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check that file is not synchronized with an other one
|
||||||
|
var fileSyncIndex = SYNC_PROVIDER_GDRIVE + fileId;
|
||||||
|
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
|
||||||
|
if(fileIndex !== undefined) {
|
||||||
|
var title = localStorage[fileIndex + ".title"];
|
||||||
|
core.showError('Google Drive file is already synchronized with "' + title + '"');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function manualGdrive(fileId) {
|
||||||
|
if(checkGdriveFileId(fileId) === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gdrive.importFiles([fileId]);
|
var fileIndex = localStorage["file.current"];
|
||||||
|
var title = localStorage[fileIndex + ".title"];
|
||||||
|
gdrive.downloadMetadata([fileId], function(result) {
|
||||||
|
if(result === undefined || result.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var file = result[0];
|
||||||
|
var fileSyncIndex = SYNC_PROVIDER_GDRIVE + file.id;
|
||||||
|
localStorage[fileSyncIndex + ".etag"] = file.etag;
|
||||||
|
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
|
||||||
|
refreshManageSync();
|
||||||
|
fileManager.updateFileTitles();
|
||||||
|
core.showMessage('"' + title
|
||||||
|
+ '" will now be synchronized on Google Drive.');
|
||||||
|
// Force synchronization
|
||||||
|
synchronizer.addFileForUpload(fileIndex);
|
||||||
|
synchronizer.forceSync();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshManageSync() {
|
function refreshManageSync() {
|
||||||
@ -317,7 +359,7 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
'<i class="icon-gdrive"></i>'));
|
'<i class="icon-gdrive"></i>'));
|
||||||
line.append($("<input>").prop("type", "text").prop(
|
line.append($("<input>").prop("type", "text").prop(
|
||||||
"disabled", true).addClass("span5").val(
|
"disabled", true).addClass("span5").val(
|
||||||
"FileID="
|
"ID="
|
||||||
+ fileSyncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
|
+ fileSyncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
|
||||||
}
|
}
|
||||||
line.append($("<a>").addClass("btn").html(
|
line.append($("<a>").addClass("btn").html(
|
||||||
|
Loading…
Reference in New Issue
Block a user