Use of underscore.js

This commit is contained in:
benweet 2013-04-13 19:11:54 +01:00
parent ff7e08b2bc
commit 98cc144b0a
13 changed files with 1383 additions and 3530 deletions

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="lib/dropbox.js"></script>
<script src="lib/dropbox.min.js"></script>
<script type="text/javascript">
Dropbox.Drivers.Popup.oauthReceiver();
</script>

View File

@ -476,6 +476,9 @@
<dd>
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
</dd>
<dd>
<a target="_blank" href="http://underscorejs.org/">Underscore.js</a>
</dd>
<dd>
<a target="_blank" href="http://layout.jquery-dev.net/">UI Layout</a>
</dd>

View File

@ -2,7 +2,7 @@ define(
[ "jquery", "file-manager", "google-helper", "dropbox-helper",
"github-helper", "synchronizer", "publisher", "async-runner",
"bootstrap", "jgrowl", "layout", "Markdown.Editor", "config",
"underscore-min" ],
"underscore" ],
function($, fileManager, googleHelper, dropboxHelper, githubHelper,
synchronizer, publisher, asyncTaskRunner) {
@ -117,7 +117,7 @@ define(
core.showMessage = function(msg, iconClass, options) {
options = options || {};
iconClass = iconClass || "icon-info-sign";
$.jGrowl("<i class='icon-white " + iconClass + "'></i> " + $("<div>").text(msg).html(), options);
$.jGrowl("<i class='icon-white " + iconClass + "'></i> " + _.escape(msg), options);
};
// Used to show an error message
@ -429,7 +429,7 @@ define(
// Generates a random string
core.randomString = function() {
return Math.ceil(Math.random() * 4294967296).toString(36);
return _.random(4294967296).toString(36);
};
// Used to setup an empty localStorage

View File

@ -280,6 +280,7 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
callback();
};
if (error) {
console.error(error);
// Try to analyze the error
if (typeof error === "string") {
errorMsg = error;

View File

@ -1,4 +1,4 @@
define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchronizer", "publisher"],
define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchronizer", "publisher", "underscore"],
function($, googleHelper, dropboxHelper, githubHelper, synchronizer, publisher) {
var fileManager = {};
@ -6,6 +6,26 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
// Dependencies
var core = undefined;
// Defines the current file
var currentFileIndex = localStorage["file.current"];
fileManager.getCurrentFileIndex = function() {
return currentFileIndex;
};
fileManager.isCurrentFileIndex = function(fileIndex) {
return fileIndex == currentFileIndex;
};
fileManager.setCurrentFileIndex = function(fileIndex) {
currentFileIndex = fileIndex;
// Sanity check since we are going to modify current file in localStorage
core.checkWindowUnique();
if(fileIndex === undefined) {
localStorage.removeItem("file.current");
}
else {
localStorage["file.current"] = fileIndex;
}
};
// Caution: this function recreate the editor (reset undo operations)
var fileDescList = [];
fileManager.selectFile = function(fileIndex) {
@ -15,19 +35,17 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
}
if(fileIndex !== undefined) {
// Since we are going to modify current file
core.checkWindowUnique();
localStorage["file.current"] = fileIndex;
fileManager.setCurrentFileIndex(fileIndex);
}
// Update the file titles
fileManager.updateFileTitles();
refreshManageSync();
refreshManagePublish();
publisher.notifyCurrentFile(localStorage["file.current"]);
publisher.notifyCurrentFile();
// Recreate the editor
fileIndex = localStorage["file.current"];
fileIndex = fileManager.getCurrentFileIndex();
$("#wmd-input").val(localStorage[fileIndex + ".content"]);
core.createEditor(function() {
fileManager.saveFile();
@ -40,15 +58,10 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
if (!title) {
// Create a file title
title = DEFAULT_FILE_TITLE;
function exists(title) {
for ( var i = 0; i < fileDescList.length; i++) {
if(fileDescList[i].title == title) {
return true;
}
}
}
var indicator = 2;
while(exists(title)) {
while(_.some(fileDescList, function(fileDesc) {
return fileDesc.title == title;
})) {
title = DEFAULT_FILE_TITLE + indicator++;
}
}
@ -57,15 +70,14 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
var fileIndex = undefined;
do {
fileIndex = "file." + core.randomString();
} while(localStorage[fileIndex + ".title"] !== undefined);
} while(_.has(localStorage, fileIndex + ".title"));
// Create the file in the localStorage
localStorage[fileIndex + ".content"] = content;
localStorage[fileIndex + ".title"] = title;
var sync = ";";
for(var i=0; i<syncIndexes.length; i++) {
sync += syncIndexes[i] + ";";
}
var sync = _.reduce(syncIndexes, function(sync, syncIndex) {
return sync + syncIndex + ";";
}, ";");
localStorage[fileIndex + ".sync"] = sync;
localStorage[fileIndex + ".publish"] = ";";
localStorage["file.list"] += fileIndex + ";";
@ -73,29 +85,25 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
};
fileManager.deleteFile = function(fileIndex) {
var fileIndexCurrent = localStorage["file.current"];
fileIndex = fileIndex || fileIndexCurrent;
if(fileIndex == fileIndexCurrent) {
// Since we are going to modify current file
core.checkWindowUnique();
localStorage.removeItem("file.current");
fileIndex = fileIndex || fileManager.getCurrentFileIndex();
if(fileManager.isCurrentFileIndex(fileIndex)) {
// Unset the current fileIndex
fileManager.setCurrentFileIndex();
}
// Remove synchronized locations
var fileSyncIndexList = localStorage[fileIndex + ".sync"].split(";");
for ( var i = 1; i < fileSyncIndexList.length - 1; i++) {
var fileSyncIndex = fileSyncIndexList[i];
fileManager.removeSync(fileSyncIndex);
}
var syncIndexList = _.compact(localStorage[fileIndex + ".sync"].split(";"));
localStorage.removeItem(fileIndex + ".sync");
_.each(syncIndexList, function(syncIndex) {
fileManager.removeSync(syncIndex);
});
// Remove publish locations
var publishIndexList = localStorage[fileIndex + ".publish"].split(";");
for ( var i = 1; i < publishIndexList.length - 1; i++) {
var publishIndex = publishIndexList[i];
var publishIndexList = _.compact(localStorage[fileIndex + ".publish"].split(";"));
localStorage.removeItem(fileIndex + ".publish");
_.each(publishIndexList, function(publishIndex) {
fileManager.removePublish(publishIndex);
}
localStorage.removeItem(fileIndex + ".sync");
});
localStorage["file.list"] = localStorage["file.list"].replace(";"
+ fileIndex + ";", ";");
@ -105,35 +113,29 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
fileManager.saveFile = function() {
var content = $("#wmd-input").val();
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
localStorage[fileIndex + ".content"] = content;
synchronizer.notifyChange(fileIndex);
};
fileManager.updateFileTitles = function() {
fileDescList = [];
$("#file-selector").empty();
var fileIndexList = localStorage["file.list"].split(";");
for ( var i = 1; i < fileIndexList.length - 1; i++) {
var fileIndex = fileIndexList[i];
var title = localStorage[fileIndex + ".title"];
fileDescList.push({ index : fileIndex, title : title });
}
fileDescList.sort(function(a, b) {
if (a.title.toLowerCase() < b.title.toLowerCase())
return -1;
if (a.title.toLowerCase() > b.title.toLowerCase())
return 1;
return 0;
});
fileDescList = _.chain(localStorage["file.list"].split(";"))
.compact()
.reduce(function(fileDescList, fileIndex) {
var title = localStorage[fileIndex + ".title"];
fileDescList.push({ index : fileIndex, title : title });
return fileDescList;
}, [])
.sortBy(function(fileDesc) {
return fileDesc.title.toLowerCase();
}).value();
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
// If no default file take first one
if (!fileIndex) {
// Since we are going to modify current file
core.checkWindowUnique();
if (fileIndex === undefined) {
fileIndex = fileDescList[0].index;
localStorage["file.current"] = fileIndex;
fileManager.setCurrentFileIndex(fileIndex);
}
var useGoogleDrive = false;
@ -170,10 +172,7 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
} else {
a.prop("href", "#").click((function(fileIndex) {
return function() {
// Since we are going to modify current file
core.checkWindowUnique();
localStorage["file.current"] = fileIndex;
fileManager.selectFile();
fileManager.selectFile(fileIndex);
};
})(fileDesc.index));
}
@ -184,30 +183,30 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
};
// Remove a synchronized location
fileManager.removeSync = function(fileSyncIndex) {
var fileIndexCurrent = localStorage["file.current"];
var fileIndex = this.getFileIndexFromSync(fileSyncIndex);
fileManager.removeSync = function(syncIndex) {
var currentFileIndex = fileManager.getCurrentFileIndex();
var fileIndex = this.getFileIndexFromSync(syncIndex);
if(fileIndex !== undefined) {
localStorage[fileIndex + ".sync"] = localStorage[fileIndex + ".sync"].replace(";"
+ fileSyncIndex + ";", ";");
if(fileIndex == fileIndexCurrent) {
+ syncIndex + ";", ";");
if(fileIndex == currentFileIndex) {
refreshManageSync();
}
}
// Remove ETAG, version, CRCs (if any)
localStorage.removeItem(fileSyncIndex + ".etag");
localStorage.removeItem(fileSyncIndex + ".version");
localStorage.removeItem(fileSyncIndex + ".contentCRC");
localStorage.removeItem(fileSyncIndex + ".titleCRC");
localStorage.removeItem(syncIndex + ".etag");
localStorage.removeItem(syncIndex + ".version");
localStorage.removeItem(syncIndex + ".contentCRC");
localStorage.removeItem(syncIndex + ".titleCRC");
};
// Look for local file associated to a synchronized location
fileManager.getFileIndexFromSync = function(fileSyncIndex) {
fileManager.getFileIndexFromSync = function(syncIndex) {
var fileIndexList = localStorage["file.list"].split(";");
for ( var i = 1; i < fileIndexList.length - 1; i++) {
var fileIndex = fileIndexList[i];
var sync = localStorage[fileIndex + ".sync"];
if (sync.indexOf(";" + fileSyncIndex + ";") !== -1) {
if (sync.indexOf(";" + syncIndex + ";") !== -1) {
return fileIndex;
}
}
@ -216,18 +215,18 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
// Remove a publish location
fileManager.removePublish = function(publishIndex) {
var fileIndexCurrent = localStorage["file.current"];
var currentFileIndex = fileManager.getCurrentFileIndex();
var fileIndex = this.getFileIndexFromPublish(publishIndex);
if(fileIndex !== undefined) {
localStorage[fileIndex + ".publish"] = localStorage[fileIndex + ".publish"].replace(";"
+ publishIndex + ";", ";");
if(fileIndex == fileIndexCurrent) {
if(fileIndex == currentFileIndex) {
refreshManagePublish();
}
}
// Remove publish object
localStorage.removeItem(publishIndex);
publisher.notifyCurrentFile(localStorage["file.current"]);
publisher.notifyCurrentFile();
};
// Look for local file associated to a publish location
@ -244,18 +243,18 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
};
function uploadGdrive(fileId, folderId) {
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
var content = localStorage[fileIndex + ".content"];
var title = localStorage[fileIndex + ".title"];
googleHelper.upload(fileId, folderId, title, content, function(fileSyncIndex) {
if (fileSyncIndex === undefined) {
googleHelper.upload(fileId, folderId, title, content, function(syncIndex) {
if (syncIndex === undefined) {
return;
}
var contentCRC = core.crc32(content);
localStorage[fileSyncIndex + ".contentCRC"] = contentCRC;
localStorage[syncIndex + ".contentCRC"] = contentCRC;
var titleCRC = core.crc32(title);
localStorage[fileSyncIndex + ".titleCRC"] = titleCRC;
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
localStorage[syncIndex + ".titleCRC"] = titleCRC;
localStorage[fileIndex + ".sync"] += syncIndex + ";";
refreshManageSync();
fileManager.updateFileTitles();
core.showMessage('"' + title
@ -268,8 +267,8 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
return;
}
// Check that file is not synchronized with an other one
var fileSyncIndex = SYNC_PROVIDER_GDRIVE + fileId;
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
var syncIndex = SYNC_PROVIDER_GDRIVE + fileId;
var fileIndex = fileManager.getFileIndexFromSync(syncIndex);
if(fileIndex !== undefined) {
var title = localStorage[fileIndex + ".title"];
core.showError('File ID is already synchronized with "' + title + '"');
@ -285,8 +284,8 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
var importIds = [];
for(var i=0; i<ids.length; i++) {
var fileId = ids[i];
var fileSyncIndex = SYNC_PROVIDER_GDRIVE + fileId;
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
var syncIndex = SYNC_PROVIDER_GDRIVE + fileId;
var fileIndex = fileManager.getFileIndexFromSync(syncIndex);
if(fileIndex !== undefined) {
var title = localStorage[fileIndex + ".title"];
core.showError('"' + title + '" was already imported');
@ -306,23 +305,23 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
return;
}
// Check that file is not synchronized with an other one
var fileSyncIndex = SYNC_PROVIDER_DROPBOX + encodeURIComponent(path.toLowerCase());
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
var syncIndex = SYNC_PROVIDER_DROPBOX + encodeURIComponent(path.toLowerCase());
var fileIndex = fileManager.getFileIndexFromSync(syncIndex);
if(fileIndex !== undefined) {
var title = localStorage[fileIndex + ".title"];
core.showError('Path "' + path + '" is already synchronized with "' + title + '"');
return;
}
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
var content = localStorage[fileIndex + ".content"];
var title = localStorage[fileIndex + ".title"];
dropboxHelper.upload(path, content, function(fileSyncIndex) {
if (fileSyncIndex === undefined) {
dropboxHelper.upload(path, content, function(syncIndex) {
if (syncIndex === undefined) {
return;
}
var contentCRC = core.crc32(content);
localStorage[fileSyncIndex + ".contentCRC"] = contentCRC;
localStorage[fileIndex + ".sync"] += fileSyncIndex + ";";
localStorage[syncIndex + ".contentCRC"] = contentCRC;
localStorage[fileIndex + ".sync"] += syncIndex + ";";
refreshManageSync();
fileManager.updateFileTitles();
core.showMessage('"' + title
@ -337,8 +336,8 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
var importPaths = [];
for(var i=0; i<paths.length; i++) {
var filePath = paths[i];
var fileSyncIndex = SYNC_PROVIDER_DROPBOX + encodeURIComponent(filePath.toLowerCase());
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
var syncIndex = SYNC_PROVIDER_DROPBOX + encodeURIComponent(filePath.toLowerCase());
var fileIndex = fileManager.getFileIndexFromSync(syncIndex);
if(fileIndex !== undefined) {
var title = localStorage[fileIndex + ".title"];
core.showError('"' + title + '" was already imported');
@ -350,46 +349,46 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
}
function refreshManageSync() {
var fileIndex = localStorage["file.current"];
var fileSyncIndexList = localStorage[fileIndex + ".sync"].split(";");
var fileIndex = fileManager.getCurrentFileIndex();
var syncIndexList = localStorage[fileIndex + ".sync"].split(";");
$(".msg-no-sync, .msg-sync-list").addClass("hide");
$("#manage-sync-list .input-append").remove();
if (fileSyncIndexList.length > 2) {
if (syncIndexList.length > 2) {
$(".msg-sync-list").removeClass("hide");
} else {
$(".msg-no-sync").removeClass("hide");
}
for ( var i = 1; i < fileSyncIndexList.length - 1; i++) {
var fileSyncIndex = fileSyncIndexList[i];
(function(fileSyncIndex) {
for ( var i = 1; i < syncIndexList.length - 1; i++) {
var syncIndex = syncIndexList[i];
(function(syncIndex) {
var line = $("<div>").addClass("input-prepend input-append");
if (fileSyncIndex.indexOf(SYNC_PROVIDER_GDRIVE) === 0) {
if (syncIndex.indexOf(SYNC_PROVIDER_GDRIVE) === 0) {
line.append($("<span>").addClass("add-on").prop("title", "Google Drive").html(
'<i class="icon-gdrive"></i>'));
line.append($("<input>").prop("type", "text").prop(
"disabled", true).addClass("span5").val(
fileSyncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
syncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
}
else if (fileSyncIndex.indexOf(SYNC_PROVIDER_DROPBOX) === 0) {
else if (syncIndex.indexOf(SYNC_PROVIDER_DROPBOX) === 0) {
line.append($("<span>").addClass("add-on").prop("title", "Dropbox").html(
'<i class="icon-dropbox"></i>'));
line.append($("<input>").prop("type", "text").prop(
"disabled", true).addClass("span5").val(
decodeURIComponent(fileSyncIndex.substring(SYNC_PROVIDER_DROPBOX.length))));
decodeURIComponent(syncIndex.substring(SYNC_PROVIDER_DROPBOX.length))));
}
line.append($("<a>").addClass("btn").html(
'<i class="icon-trash"></i>').prop("title",
"Remove this location").click(function() {
fileManager.removeSync(fileSyncIndex);
fileManager.removeSync(syncIndex);
fileManager.updateFileTitles();
}));
$("#manage-sync-list").append(line);
})(fileSyncIndex);
})(syncIndex);
}
}
function refreshManagePublish() {
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
var publishIndexList = localStorage[fileIndex + ".publish"].split(";");
$(".msg-no-publish, .msg-publish-list").addClass("hide");
$("#manage-publish-list .input-append").remove();
@ -465,7 +464,7 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
return;
}
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
var title = localStorage[fileIndex + ".title"];
var content = publisher.getPublishContent(publishObject);
var commitMsg = core.settings.commitMsg;
@ -475,7 +474,7 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
if(error === undefined) {
createPublishIndex(publishObject, fileIndex);
refreshManagePublish();
publisher.notifyCurrentFile(localStorage["file.current"]);
publisher.notifyCurrentFile();
core.showMessage('"' + title
+ '" will now be published on GitHub.');
}
@ -516,7 +515,7 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
$("#file-title-input").blur(function() {
var title = $.trim($(this).val());
if (title) {
var fileIndexTitle = localStorage["file.current"] + ".title";
var fileIndexTitle = fileManager.getCurrentFileIndex() + ".title";
if (title != localStorage[fileIndexTitle]) {
localStorage[fileIndexTitle] = title;
fileManager.updateFileTitles();

View File

@ -161,6 +161,7 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
callback(error);
};
asyncTask.onError = function() {
console.error(error);
var errorMsg = "Could not publish on GitHub.";
if(error === 401 || error === 403) {
github = undefined;

View File

@ -364,6 +364,7 @@ define(["jquery", "async-runner"], function($, asyncTaskRunner) {
callback();
};
if (error) {
console.error(error);
// Try to analyze the error
if (typeof error === "string") {
errorMsg = error;

9
js/main-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
define(["jquery", "google-helper", "github-helper"], function($, googleHelper, githubHelper) {
define(["jquery", "google-helper", "github-helper", "publish-github", "underscore"], function($, googleHelper, githubHelper) {
// Dependencies
var core = undefined;
@ -6,11 +6,15 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
var publisher = {};
// Providers
var providerMap = {};
// Used to know if the current file has publications
var hasPublications = false;
// Allows external modules to update hasPublications flag
publisher.notifyCurrentFile = function(fileIndex) {
publisher.notifyCurrentFile = function() {
var fileIndex = fileManager.getCurrentFileIndex();
// Check that file has publications
if(localStorage[fileIndex + ".publish"].length === 1) {
@ -33,7 +37,7 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
};
// Used to get content to publish
publisher.getPublishContent = function(publishObject) {
function getPublishContent(publishObject) {
if(publishObject.format === undefined) {
publishObject.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
}
@ -41,7 +45,7 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
return $("#wmd-input").val();
}
return $("#wmd-preview").html();
};
}
// Recursive function to publish a file on multiple locations
var publishIndexList = [];
@ -61,7 +65,7 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
}
var publishObject = JSON.parse(localStorage[publishIndex]);
var content = publisher.getPublishContent(publishObject);
var content = getPublishContent(publishObject);
var commitMsg = core.settings.commitMsg;
// Try to find the provider
@ -82,7 +86,7 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
publishRunning = true;
publisher.updatePublishButton();
var fileIndex = localStorage["file.current"];
var fileIndex = fileManager.getCurrentFileIndex();
var title = localStorage[fileIndex + ".title"];
publishIndexList = localStorage[fileIndex + ".publish"].split(";");;
publishLocation(function(error) {
@ -93,10 +97,32 @@ define(["jquery", "google-helper", "github-helper"], function($, googleHelper, g
}
});
};
// Add a new publish location to a local document
publisher.newLocation = function(publishObject, callback) {
var fileIndex = fileManager.getCurrentFileIndex();
var title = localStorage[fileIndex + ".title"];
var content = getPublishContent(publishObject);
var provider = providerMap[publishObject.provider];
provider.publishNew(publishObject, title, content);
};
// Associate publish provider to publisher
_.each(arguments, function(argument) {
if(argument !== undefined && argument.publishProvider !== undefined) {
providerMap[argument.publishProvider] = argument;
}
});
publisher.init = function(coreModule, fileManagerModule) {
core = coreModule;
fileManager = fileManagerModule;
// Init providers
_.each(providerMap, function(provider) {
provider.init();
});
$(".action-force-publish").click(function() {
if(!$(this).hasClass("disabled")) {
publisher.publish();

View File

@ -209,7 +209,7 @@ define(["jquery", "google-helper", "dropbox-helper"], function($, googleHelper,
if(fileContentChanged) {
localStorage[fileIndex + ".content"] = file.content;
core.showMessage('"' + file.title + '" has been updated from Google Drive.');
if(fileIndex == localStorage["file.current"]) {
if(fileManager.isCurrentFileIndex(fileIndex)) {
updateFileTitles = false; // Done by next function
fileManager.selectFile(); // Refresh editor
}
@ -278,7 +278,7 @@ define(["jquery", "google-helper", "dropbox-helper"], function($, googleHelper,
if(fileContentChanged) {
localStorage[fileIndex + ".content"] = file.content;
core.showMessage('"' + localTitle + '" has been updated from Dropbox.');
if(fileIndex == localStorage["file.current"]) {
if(fileManager.isCurrentFileIndex(fileIndex)) {
updateFileTitles = false; // Done by next function
fileManager.selectFile(); // Refresh editor
}

File diff suppressed because one or more lines are too long

1227
js/underscore.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff