Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
commit
e8a87378aa
|
@ -12,8 +12,8 @@ define(function() {
|
||||||
*/
|
*/
|
||||||
config.notificationTimeout = 5000;
|
config.notificationTimeout = 5000;
|
||||||
|
|
||||||
config.USE_FS_STORE = false;
|
config.USE_FS_STORE = true;
|
||||||
config.USE_HOMEPAGE_TABLE = true;
|
config.USE_HOMEPAGE_TABLE = false;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
|
@ -133,8 +133,11 @@ define([
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var initialized = false;
|
||||||
|
|
||||||
var init = function (f, Cryptpad) {
|
var init = function (f, Cryptpad) {
|
||||||
if (!Cryptpad) { return; }
|
if (!Cryptpad || initialized) { return; }
|
||||||
|
initialized = true;
|
||||||
var hash = Cryptpad.getUserHash() || localStorage.FS_hash;
|
var hash = Cryptpad.getUserHash() || localStorage.FS_hash;
|
||||||
var secret = Cryptpad.getSecrets(hash);
|
var secret = Cryptpad.getSecrets(hash);
|
||||||
var listmapConfig = {
|
var listmapConfig = {
|
||||||
|
|
|
@ -95,7 +95,7 @@ define(['/customize/languageSelector.js',
|
||||||
$('[data-localization]').each(translateText);
|
$('[data-localization]').each(translateText);
|
||||||
$('#pad-iframe').contents().find('[data-localization]').each(translateText);
|
$('#pad-iframe').contents().find('[data-localization]').each(translateText);
|
||||||
$('[data-localization-title]').each(translateTitle);
|
$('[data-localization-title]').each(translateTitle);
|
||||||
$('[data-localization-placeholder').each(translatePlaceholder);
|
$('[data-localization-placeholder]').each(translatePlaceholder);
|
||||||
$('#pad-iframe').contents().find('[data-localization-title]').each(translateTitle);
|
$('#pad-iframe').contents().find('[data-localization-title]').each(translateTitle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ define([
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
setMyID: setMyID,
|
setMyID: setMyID,
|
||||||
transformFunction: JsonOT.transform || JsonOT.validate,
|
transformFunction: JsonOT.transform || JsonOT.validate,
|
||||||
|
network: Cryptpad.getNetwork()
|
||||||
};
|
};
|
||||||
|
|
||||||
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
||||||
|
|
|
@ -43,6 +43,14 @@ define([
|
||||||
if (USE_FS_STORE && !legacy && fsStore) { return fsStore; }
|
if (USE_FS_STORE && !legacy && fsStore) { return fsStore; }
|
||||||
throw new Error("Store is not ready!");
|
throw new Error("Store is not ready!");
|
||||||
};
|
};
|
||||||
|
var getNetwork = common.getNetwork = function () {
|
||||||
|
if (USE_FS_STORE && fsStore) {
|
||||||
|
if (fsStore.getProxy() && fsStore.getProxy().info) {
|
||||||
|
return fsStore.getProxy().info.network;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
var getWebsocketURL = common.getWebsocketURL = function () {
|
var getWebsocketURL = common.getWebsocketURL = function () {
|
||||||
if (!Config.websocketPath) { return Config.websocketURL; }
|
if (!Config.websocketPath) { return Config.websocketURL; }
|
||||||
|
|
|
@ -21,6 +21,7 @@ define([
|
||||||
var log = config.log || logging;
|
var log = config.log || logging;
|
||||||
var logError = config.logError || logging;
|
var logError = config.logError || logging;
|
||||||
var debug = config.debug || logging;
|
var debug = config.debug || logging;
|
||||||
|
var workgroup = config.workgroup;
|
||||||
|
|
||||||
var exp = {};
|
var exp = {};
|
||||||
|
|
||||||
|
@ -241,6 +242,9 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkDeletedFiles = function () {
|
var checkDeletedFiles = function () {
|
||||||
|
// Nothing in FILES_DATA for workgroups
|
||||||
|
if (workgroup) { return; }
|
||||||
|
|
||||||
var rootFiles = getRootFiles();
|
var rootFiles = getRootFiles();
|
||||||
var unsortedFiles = getUnsortedFiles();
|
var unsortedFiles = getUnsortedFiles();
|
||||||
var templateFiles = getTemplateFiles();
|
var templateFiles = getTemplateFiles();
|
||||||
|
@ -324,6 +328,7 @@ define([
|
||||||
|
|
||||||
// Data from filesData
|
// Data from filesData
|
||||||
var getTitle = exp.getTitle = function (href) {
|
var getTitle = exp.getTitle = function (href) {
|
||||||
|
if (workgroup) { debug("No titles in workgroups"); return; }
|
||||||
var data = getFileData(href);
|
var data = getFileData(href);
|
||||||
if (!href || !data) {
|
if (!href || !data) {
|
||||||
error("getTitle called with a non-existing href: ", href);
|
error("getTitle called with a non-existing href: ", href);
|
||||||
|
@ -458,6 +463,21 @@ define([
|
||||||
if(cb) { cb(); }
|
if(cb) { cb(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Import elements in the file manager
|
||||||
|
var importElements = exp.importElements = function (elements, path, cb) {
|
||||||
|
if (!elements || elements.length === 0) { return; }
|
||||||
|
console.log(elements);
|
||||||
|
var newParent = findElement(files, path);
|
||||||
|
if (!newParent) { debug("Trying to import elements into a non-existing folder"); return; }
|
||||||
|
elements.forEach(function (e) {
|
||||||
|
var el = e.el;
|
||||||
|
var key = e.name;
|
||||||
|
if (!key) { key = "???"; } // Should not happen...
|
||||||
|
newParent[key] = el;
|
||||||
|
});
|
||||||
|
if(cb) { cb(); }
|
||||||
|
};
|
||||||
|
|
||||||
var createNewFolder = exp.createNewFolder = function (folderPath, name, cb) {
|
var createNewFolder = exp.createNewFolder = function (folderPath, name, cb) {
|
||||||
var parentEl = findElement(files, folderPath);
|
var parentEl = findElement(files, folderPath);
|
||||||
var folderName = getAvailableName(parentEl, name || NEW_FOLDER_NAME);
|
var folderName = getAvailableName(parentEl, name || NEW_FOLDER_NAME);
|
||||||
|
@ -579,6 +599,7 @@ define([
|
||||||
|
|
||||||
|
|
||||||
var forgetPad = exp.forgetPad = function (href) {
|
var forgetPad = exp.forgetPad = function (href) {
|
||||||
|
if (workgroup) { return; }
|
||||||
var rootFiles = getRootFiles().slice();
|
var rootFiles = getRootFiles().slice();
|
||||||
if (rootFiles.indexOf(href) !== -1) {
|
if (rootFiles.indexOf(href) !== -1) {
|
||||||
removeFileFromRoot(files[ROOT], href);
|
removeFileFromRoot(files[ROOT], href);
|
||||||
|
@ -592,6 +613,7 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
var addUnsortedPad = exp.addPad = function (href, path, name) {
|
var addUnsortedPad = exp.addPad = function (href, path, name) {
|
||||||
|
if (workgroup) { return; }
|
||||||
var unsortedFiles = getUnsortedFiles();
|
var unsortedFiles = getUnsortedFiles();
|
||||||
var rootFiles = getRootFiles();
|
var rootFiles = getRootFiles();
|
||||||
var trashFiles = getTrashFiles();
|
var trashFiles = getTrashFiles();
|
||||||
|
@ -620,6 +642,7 @@ define([
|
||||||
// addTemplate is called when we want to add a new pad, never visited, to the templates list
|
// addTemplate is called when we want to add a new pad, never visited, to the templates list
|
||||||
// first, we must add it to FILES_DATA, so the input has to be an fileDAta object
|
// first, we must add it to FILES_DATA, so the input has to be an fileDAta object
|
||||||
var addTemplate = exp.addTemplate = function (fileData) {
|
var addTemplate = exp.addTemplate = function (fileData) {
|
||||||
|
if (workgroup) { return; }
|
||||||
if (typeof fileData !== "object" || !fileData.href || !fileData.title) { return; }
|
if (typeof fileData !== "object" || !fileData.href || !fileData.title) { return; }
|
||||||
|
|
||||||
var href = fileData.href;
|
var href = fileData.href;
|
||||||
|
@ -635,6 +658,7 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
var listTemplates = exp.listTemplates = function (type) {
|
var listTemplates = exp.listTemplates = function (type) {
|
||||||
|
if (workgroup) { return; }
|
||||||
var templateFiles = getTemplateFiles();
|
var templateFiles = getTemplateFiles();
|
||||||
var res = [];
|
var res = [];
|
||||||
templateFiles.forEach(function (f) {
|
templateFiles.forEach(function (f) {
|
||||||
|
@ -664,13 +688,9 @@ define([
|
||||||
|
|
||||||
var before = JSON.stringify(files);
|
var before = JSON.stringify(files);
|
||||||
|
|
||||||
|
var fixRoot = function (elem) {
|
||||||
if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; }
|
if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; }
|
||||||
if (typeof(files[TRASH]) !== "object") { debug("TRASH was not an object"); files[TRASH] = {}; }
|
var element = elem || files[ROOT];
|
||||||
if (!$.isArray(files[FILES_DATA])) { debug("FILES_DATA was not an array"); files[FILES_DATA] = []; }
|
|
||||||
if (!$.isArray(files[UNSORTED])) { debug("UNSORTED was not an array"); files[UNSORTED] = []; }
|
|
||||||
if (!$.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; }
|
|
||||||
|
|
||||||
var fixRoot = function (element) {
|
|
||||||
for (var el in element) {
|
for (var el in element) {
|
||||||
if (!isFile(element[el]) && !isFolder(element[el])) {
|
if (!isFile(element[el]) && !isFolder(element[el])) {
|
||||||
debug("An element in ROOT was not a folder nor a file. ", element[el]);
|
debug("An element in ROOT was not a folder nor a file. ", element[el]);
|
||||||
|
@ -681,9 +701,9 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fixRoot(files[ROOT]);
|
var fixTrashRoot = function () {
|
||||||
|
if (typeof(files[TRASH]) !== "object") { debug("TRASH was not an object"); files[TRASH] = {}; }
|
||||||
var fixTrashRoot = function (tr) {
|
var tr = files[TRASH];
|
||||||
var toClean;
|
var toClean;
|
||||||
var addToClean = function (obj, idx) {
|
var addToClean = function (obj, idx) {
|
||||||
if (typeof(obj) !== "object") { toClean.push(idx); return; }
|
if (typeof(obj) !== "object") { toClean.push(idx); return; }
|
||||||
|
@ -704,9 +724,10 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fixTrashRoot(files[TRASH]);
|
var fixUnsorted = function () {
|
||||||
|
if (!$.isArray(files[UNSORTED])) { debug("UNSORTED was not an array"); files[UNSORTED] = []; }
|
||||||
var fixUnsorted = function (us) {
|
files[UNSORTED] = uniq(files[UNSORTED]);
|
||||||
|
var us = files[UNSORTED];
|
||||||
var rootFiles = getRootFiles().slice();
|
var rootFiles = getRootFiles().slice();
|
||||||
var templateFiles = getTemplateFiles();
|
var templateFiles = getTemplateFiles();
|
||||||
var toClean = [];
|
var toClean = [];
|
||||||
|
@ -722,10 +743,10 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
files[UNSORTED] = uniq(files[UNSORTED]);
|
var fixTemplate = function () {
|
||||||
fixUnsorted(files[UNSORTED]);
|
if (!$.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; }
|
||||||
|
files[TEMPLATE] = uniq(files[TEMPLATE]);
|
||||||
var fixTemplate = function (us) {
|
var us = files[TEMPLATE];
|
||||||
var rootFiles = getRootFiles().slice();
|
var rootFiles = getRootFiles().slice();
|
||||||
var unsortedFiles = getUnsortedFiles();
|
var unsortedFiles = getUnsortedFiles();
|
||||||
var toClean = [];
|
var toClean = [];
|
||||||
|
@ -741,10 +762,9 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
files[TEMPLATE] = uniq(files[TEMPLATE]);
|
|
||||||
fixUnsorted(files[TEMPLATE]);
|
|
||||||
|
|
||||||
var fixFilesData = function (fd) {
|
var fixFilesData = function (fd) {
|
||||||
|
if (!$.isArray(files[FILES_DATA])) { debug("FILES_DATA was not an array"); files[FILES_DATA] = []; }
|
||||||
|
var fd = files[FILES_DATA];
|
||||||
var rootFiles = getRootFiles();
|
var rootFiles = getRootFiles();
|
||||||
var unsortedFiles = getUnsortedFiles();
|
var unsortedFiles = getUnsortedFiles();
|
||||||
var trashFiles = getTrashFiles();
|
var trashFiles = getTrashFiles();
|
||||||
|
@ -769,7 +789,14 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
fixFilesData(files[FILES_DATA]);
|
|
||||||
|
fixRoot();
|
||||||
|
fixTrashRoot();
|
||||||
|
if (!workgroup) {
|
||||||
|
fixUnsorted();
|
||||||
|
fixTemplate();
|
||||||
|
fixFilesData();
|
||||||
|
}
|
||||||
|
|
||||||
if (JSON.stringify(files) !== before) {
|
if (JSON.stringify(files) !== before) {
|
||||||
debug("Your file system was corrupted. It has been cleaned so that the pads you visit can be stored safely");
|
debug("Your file system was corrupted. It has been cleaned so that the pads you visit can be stored safely");
|
||||||
|
|
123
www/file/main.js
123
www/file/main.js
|
@ -28,6 +28,10 @@ define([
|
||||||
Cryptpad: Cryptpad
|
Cryptpad: Cryptpad
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var stringify = APP.stringify = function (obj) {
|
||||||
|
return JSONSortify(obj);
|
||||||
|
};
|
||||||
|
|
||||||
var ROOT = "root";
|
var ROOT = "root";
|
||||||
var ROOT_NAME = Messages.fm_rootName;
|
var ROOT_NAME = Messages.fm_rootName;
|
||||||
var UNSORTED = "unsorted";
|
var UNSORTED = "unsorted";
|
||||||
|
@ -121,7 +125,7 @@ define([
|
||||||
|
|
||||||
var setEditable = function (state) {
|
var setEditable = function (state) {
|
||||||
APP.editable = state;
|
APP.editable = state;
|
||||||
if (state) { $iframe.find('[draggable="true"]').attr('draggable', false); }
|
if (!state) { $iframe.find('[draggable="true"]').attr('draggable', false); }
|
||||||
else { $iframe.find('[draggable="false"]').attr('draggable', true); }
|
else { $iframe.find('[draggable="false"]').attr('draggable', true); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,6 +144,11 @@ define([
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = function (files) {
|
var init = function (files) {
|
||||||
|
var ownFileManager = function () {
|
||||||
|
return Cryptpad.getUserHash() === APP.hash || localStorage.FS_hash === APP.hash;
|
||||||
|
};
|
||||||
|
config.workgroup = !ownFileManager();
|
||||||
|
|
||||||
var filesOp = FO.init(files, config);
|
var filesOp = FO.init(files, config);
|
||||||
filesOp.fixFiles();
|
filesOp.fixFiles();
|
||||||
|
|
||||||
|
@ -242,10 +251,6 @@ define([
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var ownFileManager = function () {
|
|
||||||
return Cryptpad.getUserHash() === APP.hash || localStorage.FS_hash === APP.hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
var removeSelected = function () {
|
var removeSelected = function () {
|
||||||
$iframe.find('.selected').removeClass("selected");
|
$iframe.find('.selected').removeClass("selected");
|
||||||
};
|
};
|
||||||
|
@ -454,6 +459,25 @@ define([
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var getElementName = function (path) {
|
||||||
|
// Trash root
|
||||||
|
if (filesOp.isInTrashRoot(path)) {
|
||||||
|
return path[0];
|
||||||
|
}
|
||||||
|
// Root or trash
|
||||||
|
if (filesOp.isPathInRoot(path) || filesOp.isPathInTrash(path)) {
|
||||||
|
return path[path.length - 1];
|
||||||
|
}
|
||||||
|
// Unsorted or template
|
||||||
|
if (filesOp.isPathInUnsorted(path) || filesOp.isPathInTemplate(path)) {
|
||||||
|
var file = filesOp.findElement(files, path);
|
||||||
|
if (filesOp.isFile(file) && filesOp.getTitle(file)) {
|
||||||
|
return filesOp.getTitle(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// default
|
||||||
|
return "???";
|
||||||
|
};
|
||||||
// filesOp.moveElements is able to move several paths to a new location, including
|
// filesOp.moveElements is able to move several paths to a new location, including
|
||||||
// the Trash or the "Unsorted files" folder
|
// the Trash or the "Unsorted files" folder
|
||||||
var moveElements = function (paths, newPath, force, cb) {
|
var moveElements = function (paths, newPath, force, cb) {
|
||||||
|
@ -485,19 +509,36 @@ define([
|
||||||
if ($element.hasClass('selected')) {
|
if ($element.hasClass('selected')) {
|
||||||
var $selected = $iframe.find('.selected');
|
var $selected = $iframe.find('.selected');
|
||||||
$selected.each(function (idx, elmt) {
|
$selected.each(function (idx, elmt) {
|
||||||
if ($(elmt).data('path')) {
|
var ePath = $(elmt).data('path');
|
||||||
paths.push($(elmt).data('path'));
|
if (ePath) {
|
||||||
|
var val = filesOp.findElement(files, ePath);
|
||||||
|
if (!val) { return; } // Error? A ".selected" element in not in the object
|
||||||
|
paths.push({
|
||||||
|
path: ePath,
|
||||||
|
value: {
|
||||||
|
name: getElementName(ePath),
|
||||||
|
el: val
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
removeSelected();
|
removeSelected();
|
||||||
$element.addClass('selected');
|
$element.addClass('selected');
|
||||||
paths = [path];
|
var val = filesOp.findElement(files, path);
|
||||||
|
if (!val) { return; } // The element in not in the object
|
||||||
|
paths = [{
|
||||||
|
path: path,
|
||||||
|
value: {
|
||||||
|
name: getElementName(path),
|
||||||
|
el: val
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
'path': paths
|
'path': paths
|
||||||
};
|
};
|
||||||
ev.dataTransfer.setData("text", JSON.stringify(data));
|
ev.dataTransfer.setData("text", stringify(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
var onDrop = function (ev) {
|
var onDrop = function (ev) {
|
||||||
|
@ -505,9 +546,30 @@ define([
|
||||||
$iframe.find('.droppable').removeClass('droppable');
|
$iframe.find('.droppable').removeClass('droppable');
|
||||||
var data = ev.dataTransfer.getData("text");
|
var data = ev.dataTransfer.getData("text");
|
||||||
var oldPaths = JSON.parse(data).path;
|
var oldPaths = JSON.parse(data).path;
|
||||||
|
if (!oldPaths) { return; }
|
||||||
|
|
||||||
|
// Dropped elements can be moved from the same file manager or imported from another one.
|
||||||
|
// A moved element should be removed from its previous location
|
||||||
|
var movedPaths = [];
|
||||||
|
var importedElements = [];
|
||||||
|
oldPaths.forEach(function (p) {
|
||||||
|
var el = filesOp.findElement(files, p.path);
|
||||||
|
if (el && (stringify(el) === stringify(p.value.el) || !p.value || !p.value.el)) {
|
||||||
|
movedPaths.push(p.path);
|
||||||
|
} else {
|
||||||
|
importedElements.push(p.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var newPath = $(ev.target).data('path') || $(ev.target).parent('li').data('path');
|
var newPath = $(ev.target).data('path') || $(ev.target).parent('li').data('path');
|
||||||
if (!oldPaths || !oldPaths.length || !newPath) { return; }
|
console.log(newPath);
|
||||||
moveElements(oldPaths, newPath, null, refresh);
|
if (!newPath) { return; }
|
||||||
|
if (movedPaths && movedPaths.length) {
|
||||||
|
moveElements(movedPaths, newPath, null, refresh);
|
||||||
|
}
|
||||||
|
if (importedElements && importedElements.length) {
|
||||||
|
filesOp.importElements(importedElements, newPath, refresh);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var addDragAndDropHandlers = function ($element, path, isFolder, droppable) {
|
var addDragAndDropHandlers = function ($element, path, isFolder, droppable) {
|
||||||
|
@ -569,10 +631,13 @@ define([
|
||||||
var $type = $('<span>', {'class': 'type listElement', title: type}).text(type);
|
var $type = $('<span>', {'class': 'type listElement', title: type}).text(type);
|
||||||
var $adate = $('<span>', {'class': 'atime listElement', title: getDate(data.atime)}).text(getDate(data.atime));
|
var $adate = $('<span>', {'class': 'atime listElement', title: getDate(data.atime)}).text(getDate(data.atime));
|
||||||
var $cdate = $('<span>', {'class': 'ctime listElement', title: getDate(data.ctime)}).text(getDate(data.ctime));
|
var $cdate = $('<span>', {'class': 'ctime listElement', title: getDate(data.ctime)}).text(getDate(data.ctime));
|
||||||
if (displayTitle) {
|
if (displayTitle && ownFileManager()) {
|
||||||
$span.append($title);
|
$span.append($title);
|
||||||
}
|
}
|
||||||
$span.append($type).append($adate).append($cdate);
|
$span.append($type);
|
||||||
|
if (ownFileManager()) {
|
||||||
|
$span.append($adate).append($cdate);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var addFolderData = function (element, key, $span) {
|
var addFolderData = function (element, key, $span) {
|
||||||
|
@ -876,10 +941,13 @@ define([
|
||||||
var $fhAdate = $('<span>', {'class': 'atime'}).text(Messages.fm_lastAccess).click(onSortByClick);
|
var $fhAdate = $('<span>', {'class': 'atime'}).text(Messages.fm_lastAccess).click(onSortByClick);
|
||||||
var $fhCdate = $('<span>', {'class': 'ctime'}).text(Messages.fm_creation).click(onSortByClick);
|
var $fhCdate = $('<span>', {'class': 'ctime'}).text(Messages.fm_creation).click(onSortByClick);
|
||||||
$fihElement.append($fhName);
|
$fihElement.append($fhName);
|
||||||
if (displayTitle) {
|
if (displayTitle && ownFileManager()) {
|
||||||
$fihElement.append($fhTitle);
|
$fihElement.append($fhTitle);
|
||||||
}
|
}
|
||||||
$fihElement.append($fhType).append($fhAdate).append($fhCdate);
|
$fihElement.append($fhType);
|
||||||
|
if (ownFileManager()) {
|
||||||
|
$fihElement.append($fhAdate).append($fhCdate);
|
||||||
|
}
|
||||||
addFileSortIcon($fihElement);
|
addFileSortIcon($fihElement);
|
||||||
return $fileHeader;
|
return $fileHeader;
|
||||||
};
|
};
|
||||||
|
@ -1049,6 +1117,13 @@ define([
|
||||||
// NOTE: Elements in the trash are not using the same storage structure as the others
|
// NOTE: Elements in the trash are not using the same storage structure as the others
|
||||||
var displayDirectory = module.displayDirectory = function (path, force) {
|
var displayDirectory = module.displayDirectory = function (path, force) {
|
||||||
if (!appStatus.isReady && !force) { return; }
|
if (!appStatus.isReady && !force) { return; }
|
||||||
|
// Only Trash and Root are available in not-owned files manager
|
||||||
|
if (!ownFileManager() && !filesOp.isPathInTrash(path) && !filesOp.isPathInRoot(path)) {
|
||||||
|
log("TRANSLATE or REMOVE: Unable to open the selected category, displaying root"); //TODO translate
|
||||||
|
currentPath = [ROOT];
|
||||||
|
displayDirectory(currentPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
appStatus.ready(false);
|
appStatus.ready(false);
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
$content.html("");
|
$content.html("");
|
||||||
|
@ -1274,9 +1349,11 @@ define([
|
||||||
var resetTree = module.resetTree = function () {
|
var resetTree = module.resetTree = function () {
|
||||||
$tree.html('');
|
$tree.html('');
|
||||||
createTree($tree, [ROOT]);
|
createTree($tree, [ROOT]);
|
||||||
|
if (ownFileManager()) {
|
||||||
createUnsorted($tree, [UNSORTED]);
|
createUnsorted($tree, [UNSORTED]);
|
||||||
createTemplate($tree, [TEMPLATE]);
|
createTemplate($tree, [TEMPLATE]);
|
||||||
createAllFiles($tree, [FILES_DATA]);
|
createAllFiles($tree, [FILES_DATA]);
|
||||||
|
}
|
||||||
createTrash($tree, [TRASH]);
|
createTrash($tree, [TRASH]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1528,7 +1605,7 @@ define([
|
||||||
APP.homePageIframe = true;
|
APP.homePageIframe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hash = Cryptpad.getUserHash() || window.location.hash.slice(1) || localStorage.FS_hash;
|
var hash = window.location.hash.slice(1) || Cryptpad.getUserHash() || localStorage.FS_hash;
|
||||||
var secret = Cryptpad.getSecrets(hash);
|
var secret = Cryptpad.getSecrets(hash);
|
||||||
var readOnly = APP.readOnly = secret.keys && !secret.keys.editKeyStr;
|
var readOnly = APP.readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||||
|
|
||||||
|
@ -1539,12 +1616,11 @@ define([
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
validateKey: secret.keys.validateKey || undefined,
|
validateKey: secret.keys.validateKey || undefined,
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
logging: false,
|
logging: false
|
||||||
logLevel: 1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var proxy;
|
var proxy;
|
||||||
if (storeObj) { proxy = storeObj.proxy; }
|
if (storeObj && !window.location.hash.slice(1)) { proxy = storeObj.proxy; }
|
||||||
else {
|
else {
|
||||||
var rt = window.rt = module.rt = Listmap.create(listmapConfig);
|
var rt = window.rt = module.rt = Listmap.create(listmapConfig);
|
||||||
proxy = rt.proxy;
|
proxy = rt.proxy;
|
||||||
|
@ -1620,8 +1696,12 @@ define([
|
||||||
console.error('err');
|
console.error('err');
|
||||||
Cryptpad.alert(Messages.common_connectionLost);
|
Cryptpad.alert(Messages.common_connectionLost);
|
||||||
};
|
};
|
||||||
|
var onReconnect = function (info) {
|
||||||
|
setEditable(true);
|
||||||
|
Cryptpad.findOKButton().click();
|
||||||
|
};
|
||||||
|
|
||||||
if (storeObj) {
|
if (storeObj && !window.location.hash) {
|
||||||
onCreate(storeObj.info);
|
onCreate(storeObj.info);
|
||||||
onReady();
|
onReady();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1634,6 +1714,9 @@ define([
|
||||||
proxy.on('disconnect', function () {
|
proxy.on('disconnect', function () {
|
||||||
onDisconnect();
|
onDisconnect();
|
||||||
});
|
});
|
||||||
|
proxy.on('reconnect', function () {
|
||||||
|
onReconnect();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Cryptpad.onError(function (info) {
|
Cryptpad.onError(function (info) {
|
||||||
if (info) {
|
if (info) {
|
||||||
|
|
|
@ -376,6 +376,9 @@ define([
|
||||||
// the channel we will communicate over
|
// the channel we will communicate over
|
||||||
channel: secret.channel,
|
channel: secret.channel,
|
||||||
|
|
||||||
|
// the nework used for the file store if it exists
|
||||||
|
network: Cryptpad.getNetwork(),
|
||||||
|
|
||||||
// our public key
|
// our public key
|
||||||
validateKey: secret.keys.validateKey || undefined,
|
validateKey: secret.keys.validateKey || undefined,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
|
@ -629,6 +632,11 @@ define([
|
||||||
var onReady = realtimeOptions.onReady = function (info) {
|
var onReady = realtimeOptions.onReady = function (info) {
|
||||||
if (!APP.isMaximized) {
|
if (!APP.isMaximized) {
|
||||||
editor.execCommand('maximize');
|
editor.execCommand('maximize');
|
||||||
|
// We have to call it 3 times in Safari in order to have the editor fully maximized -_-
|
||||||
|
if ((''+window.navigator.vendor).indexOf('Apple') !== -1) {
|
||||||
|
editor.execCommand('maximize');
|
||||||
|
editor.execCommand('maximize');
|
||||||
|
}
|
||||||
APP.isMaximized = true;
|
APP.isMaximized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -698,6 +698,8 @@ define([
|
||||||
Cryptpad.alert(Messages.common_connectionLost);
|
Cryptpad.alert(Messages.common_connectionLost);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// don't initialize until the store is ready.
|
||||||
|
Cryptpad.ready(function () {
|
||||||
var config = {
|
var config = {
|
||||||
websocketURL: Cryptpad.getWebsocketURL(),
|
websocketURL: Cryptpad.getWebsocketURL(),
|
||||||
channel: secret.channel,
|
channel: secret.channel,
|
||||||
|
@ -708,10 +710,9 @@ define([
|
||||||
//readOnly: readOnly,
|
//readOnly: readOnly,
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
userName: 'poll',
|
userName: 'poll',
|
||||||
|
network: Cryptpad.getNetwork()
|
||||||
};
|
};
|
||||||
|
|
||||||
// don't initialize until the store is ready.
|
|
||||||
Cryptpad.ready(function () {
|
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
$('#commit, #create-user, #create-option, #publish, #admin').remove();
|
$('#commit, #create-user, #create-option, #publish, #admin').remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,8 @@ define([
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
setMyID: setMyID,
|
setMyID: setMyID,
|
||||||
transformFunction: JsonOT.validate
|
transformFunction: JsonOT.validate,
|
||||||
|
network: Cryptpad.getNetwork()
|
||||||
};
|
};
|
||||||
|
|
||||||
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
||||||
|
|
Loading…
Reference in New Issue