Fix file upload and remove unnecessary dependencies
This commit is contained in:
parent
664625a6ef
commit
bd85f1b003
@ -129,7 +129,7 @@ define([
|
|||||||
|
|
||||||
common.getMetadata = function (cb) {
|
common.getMetadata = function (cb) {
|
||||||
postMessage("GET_METADATA", null, function (obj) {
|
postMessage("GET_METADATA", null, function (obj) {
|
||||||
if (obj.error) { return void cb(obj.error); }
|
if (obj && obj.error) { return void cb(obj.error); }
|
||||||
cb(null, obj);
|
cb(null, obj);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -291,7 +291,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
// When opening a new pad or renaming it, store the new title
|
// When opening a new pad or renaming it, store the new title
|
||||||
common.setPadTitle = function (title, padHref, cb) {
|
common.setPadTitle = function (title, padHref, path, cb) {
|
||||||
var href = padHref || window.location.href;
|
var href = padHref || window.location.href;
|
||||||
var parsed = Hash.parsePadUrl(href);
|
var parsed = Hash.parsePadUrl(href);
|
||||||
if (!parsed.hash) { return; }
|
if (!parsed.hash) { return; }
|
||||||
@ -302,7 +302,8 @@ define([
|
|||||||
|
|
||||||
postMessage("SET_PAD_TITLE", {
|
postMessage("SET_PAD_TITLE", {
|
||||||
href: href,
|
href: href,
|
||||||
title: title
|
title: title,
|
||||||
|
path: path
|
||||||
}, function (obj) {
|
}, function (obj) {
|
||||||
if (obj && obj.error) {
|
if (obj && obj.error) {
|
||||||
console.log("unable to set pad title");
|
console.log("unable to set pad title");
|
||||||
|
|||||||
@ -568,7 +568,7 @@ define([
|
|||||||
Store.addPad({
|
Store.addPad({
|
||||||
href: href,
|
href: href,
|
||||||
title: title,
|
title: title,
|
||||||
path: store.data && store.data.initialPath
|
path: data.path || (store.data && store.data.initialPath)
|
||||||
}, cb);
|
}, cb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,8 +58,7 @@ define([
|
|||||||
|
|
||||||
if (noStore) { return void onComplete(href); }
|
if (noStore) { return void onComplete(href); }
|
||||||
|
|
||||||
common.initialPath = path;
|
common.setPadTitle(title || "", href, path, function (err) {
|
||||||
common.renamePad(title || "", href, function (err) {
|
|
||||||
if (err) { return void console.error(err); }
|
if (err) { return void console.error(err); }
|
||||||
onComplete(href);
|
onComplete(href);
|
||||||
common.setPadAttribute('fileType', metadata.type, null, href);
|
common.setPadAttribute('fileType', metadata.type, null, href);
|
||||||
|
|||||||
@ -234,7 +234,7 @@ define([
|
|||||||
sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
|
sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
|
||||||
currentTitle = newTitle;
|
currentTitle = newTitle;
|
||||||
setDocumentTitle();
|
setDocumentTitle();
|
||||||
Cryptpad.setPadTitle(newTitle, undefined, function (err) {
|
Cryptpad.setPadTitle(newTitle, undefined, undefined, function (err) {
|
||||||
cb(err);
|
cb(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
define([
|
define([
|
||||||
'jquery',
|
|
||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
'/common/common-realtime.js',
|
'/common/common-realtime.js',
|
||||||
'/common/common-constants.js',
|
'/common/common-constants.js',
|
||||||
'/customize/messages.js'
|
'/customize/messages.js'
|
||||||
], function ($, AppConfig, Util, Hash, Realtime, Constants, Messages) {
|
], function (AppConfig, Util, Hash, Realtime, Constants, Messages) {
|
||||||
var module = {};
|
var module = {};
|
||||||
|
|
||||||
var ROOT = module.ROOT = "root";
|
var ROOT = module.ROOT = "root";
|
||||||
@ -101,7 +100,7 @@ define([
|
|||||||
};
|
};
|
||||||
for (var f in element) {
|
for (var f in element) {
|
||||||
if (trashRoot) {
|
if (trashRoot) {
|
||||||
if ($.isArray(element[f])) {
|
if (Array.isArray(element[f])) {
|
||||||
element[f].forEach(addSubfolder);
|
element[f].forEach(addSubfolder);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -119,7 +118,7 @@ define([
|
|||||||
};
|
};
|
||||||
for (var f in element) {
|
for (var f in element) {
|
||||||
if (trashRoot) {
|
if (trashRoot) {
|
||||||
if ($.isArray(element[f])) {
|
if (Array.isArray(element[f])) {
|
||||||
element[f].forEach(addFile);
|
element[f].forEach(addFile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -148,14 +147,14 @@ define([
|
|||||||
return data.filename || data.title || NEW_FILE_NAME;
|
return data.filename || data.title || NEW_FILE_NAME;
|
||||||
};
|
};
|
||||||
exp.getPadAttribute = function (href, attr, cb) {
|
exp.getPadAttribute = function (href, attr, cb) {
|
||||||
cb = cb || $.noop;
|
cb = cb || function () {};
|
||||||
var id = exp.getIdFromHref(href);
|
var id = exp.getIdFromHref(href);
|
||||||
if (!id) { return void cb(null, undefined); }
|
if (!id) { return void cb(null, undefined); }
|
||||||
var data = getFileData(id);
|
var data = getFileData(id);
|
||||||
cb(null, clone(data[attr]));
|
cb(null, clone(data[attr]));
|
||||||
};
|
};
|
||||||
exp.setPadAttribute = function (href, attr, value, cb) {
|
exp.setPadAttribute = function (href, attr, value, cb) {
|
||||||
cb = cb || $.noop;
|
cb = cb || function () {};
|
||||||
var id = exp.getIdFromHref(href);
|
var id = exp.getIdFromHref(href);
|
||||||
if (!id) { return void cb("E_INVAL_HREF"); }
|
if (!id) { return void cb("E_INVAL_HREF"); }
|
||||||
if (!attr || !attr.trim()) { return void cb("E_INVAL_ATTR"); }
|
if (!attr || !attr.trim()) { return void cb("E_INVAL_ATTR"); }
|
||||||
@ -167,7 +166,7 @@ define([
|
|||||||
// PATHS
|
// PATHS
|
||||||
|
|
||||||
var comparePath = exp.comparePath = function (a, b) {
|
var comparePath = exp.comparePath = function (a, b) {
|
||||||
if (!a || !b || !$.isArray(a) || !$.isArray(b)) { return false; }
|
if (!a || !b || !Array.isArray(a) || !Array.isArray(b)) { return false; }
|
||||||
if (a.length !== b.length) { return false; }
|
if (a.length !== b.length) { return false; }
|
||||||
var result = true;
|
var result = true;
|
||||||
var i = a.length - 1;
|
var i = a.length - 1;
|
||||||
@ -265,7 +264,7 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (var e in root) {
|
for (var e in root) {
|
||||||
if (!$.isArray(root[e])) {
|
if (!Array.isArray(root[e])) {
|
||||||
error("Trash contains a non-array element");
|
error("Trash contains a non-array element");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -967,7 +966,7 @@ define([
|
|||||||
var addToClean = function (obj, idx, el) {
|
var addToClean = function (obj, idx, el) {
|
||||||
if (typeof(obj) !== "object") { toClean.push(idx); return; }
|
if (typeof(obj) !== "object") { toClean.push(idx); return; }
|
||||||
if (!isFile(obj.element, true) && !isFolder(obj.element)) { toClean.push(idx); return; }
|
if (!isFile(obj.element, true) && !isFolder(obj.element)) { toClean.push(idx); return; }
|
||||||
if (!$.isArray(obj.path)) { toClean.push(idx); return; }
|
if (!Array.isArray(obj.path)) { toClean.push(idx); return; }
|
||||||
if (typeof obj.element === "string") {
|
if (typeof obj.element === "string") {
|
||||||
// We have an old file (href) which is not in filesData: add it
|
// We have an old file (href) which is not in filesData: add it
|
||||||
var id = Util.createRandomInteger();
|
var id = Util.createRandomInteger();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user