Fix lint errors

pull/1/head
yflory 8 years ago
parent b36484931d
commit a57f7c6ce7

@ -2,8 +2,7 @@ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/cryptget.js', '/common/cryptget.js',
'/common/userObject.js', '/common/userObject.js',
'json.sortify' ], function (Cryptpad, Crypt, FO) {
], function (Cryptpad, Crypt, FO, Sortify) {
var exp = {}; var exp = {};
var getType = function (el) { var getType = function (el) {

@ -133,18 +133,6 @@ define([
return data.filename || data.title || NEW_FILE_NAME; return data.filename || data.title || NEW_FILE_NAME;
}; };
var getIdFromHref = exp.getIdFromHref = function (href) {
var result;
getFiles([FILES_DATA]).some(function (id) {
if (files[FILES_DATA][id].href === href) {
result = id;
return true;
}
return;
});
return result;
};
// PATHS // PATHS
var comparePath = exp.comparePath = function (a, b) { var comparePath = exp.comparePath = function (a, b) {
@ -282,6 +270,18 @@ define([
return Cryptpad.deduplicateString(ret); return Cryptpad.deduplicateString(ret);
}; };
var getIdFromHref = exp.getIdFromHref = function (href) {
var result;
getFiles([FILES_DATA]).some(function (id) {
if (files[FILES_DATA][id].href === href) {
result = id;
return true;
}
return;
});
return result;
};
// SEARCH // SEARCH
var _findFileInRoot = function (path, file) { var _findFileInRoot = function (path, file) {
if (!isPathIn(path, [ROOT, TRASH])) { return []; } if (!isPathIn(path, [ROOT, TRASH])) { return []; }
@ -415,7 +415,7 @@ define([
}; };
// FILES DATA // FILES DATA
var pushFileData = exp.pushData = function (data, cb) { exp.pushData = function (data, cb) {
if (typeof cb !== "function") { cb = function () {}; } if (typeof cb !== "function") { cb = function () {}; }
var todo = function () { var todo = function () {
var id = Cryptpad.createRandomInteger(); var id = Cryptpad.createRandomInteger();
@ -535,7 +535,7 @@ define([
} }
// Add to root if path is ROOT or if no path // Add to root if path is ROOT or if no path
var filesList = getFiles([ROOT, TRASH, 'hrefArray']); var filesList = getFiles([ROOT, TRASH, 'hrefArray']);
if (path && isPathIn(newPath, [ROOT]) || filesList.indexOf(href) === -1) { if (path && isPathIn(newPath, [ROOT]) || filesList.indexOf(id) === -1) {
parentEl = find(newPath || [ROOT]); parentEl = find(newPath || [ROOT]);
if (parentEl) { if (parentEl) {
var newName = getAvailableName(parentEl, Cryptpad.createChannelId()); var newName = getAvailableName(parentEl, Cryptpad.createChannelId());
@ -618,7 +618,6 @@ define([
var allFilesPaths = paths.filter(function(x) { return isPathIn(x, [FILES_DATA]); }); var allFilesPaths = paths.filter(function(x) { return isPathIn(x, [FILES_DATA]); });
if (!Cryptpad.isLoggedIn()) { if (!Cryptpad.isLoggedIn()) {
var toSplice = [];
allFilesPaths.forEach(function (path) { allFilesPaths.forEach(function (path) {
var el = find(path); var el = find(path);
if (!el) { return; } if (!el) { return; }
@ -717,8 +716,7 @@ define([
if (typeof cb === "function") { cb(); } if (typeof cb === "function") { cb(); }
return; return;
} }
var oldName = getTitle(element, 'name'); if (getTitle(element, 'name') === newName) { return; }
if (oldName === newName) { return; }
data.filename = newName; data.filename = newName;
if (typeof cb === "function") { cb(); } if (typeof cb === "function") { cb(); }
}; };
@ -771,7 +769,6 @@ define([
delete files[UNSORTED]; delete files[UNSORTED];
return; return;
} }
var root = find([ROOT]);
us.forEach(function (el) { us.forEach(function (el) {
if (typeof el !== "string") { if (typeof el !== "string") {
return; return;
@ -916,7 +913,9 @@ define([
delete tr[el]; delete tr[el];
} else { } else {
toClean = []; toClean = [];
tr[el].forEach(function (obj, idx) { addToClean(obj, idx, el); }); for (var j=0; j<tr[el].length; j++) {
addToClean(tr[el][j], j, el);
}
for (var i = toClean.length-1; i>=0; i--) { for (var i = toClean.length-1; i>=0; i--) {
tr[el].splice(toClean[i], 1); tr[el].splice(toClean[i], 1);
} }
@ -969,7 +968,7 @@ define([
root[newName] = id; root[newName] = id;
continue; continue;
} }
}; }
toClean.forEach(function (id) { toClean.forEach(function (id) {
spliceFileData(id); spliceFileData(id);
}); });

@ -1511,7 +1511,7 @@ define([
} }
}; };
// _WORKGROUP_ : do not display title, atime and ctime in workgroups since we don't have files data // _WORKGROUP_ : do not display title, atime and ctime in workgroups since we don't have files data
var getFileListHeader = function (displayTitle) { var getFileListHeader = function () {
var $fihElement = $('<li>', {'class': 'file-header header listElement element'}); var $fihElement = $('<li>', {'class': 'file-header header listElement element'});
//var $fihElement = $('<span>', {'class': 'element'}).appendTo($fileHeader); //var $fihElement = $('<span>', {'class': 'element'}).appendTo($fileHeader);
var $fhIcon = $('<span>', {'class': 'icon'}); var $fhIcon = $('<span>', {'class': 'icon'});
@ -1659,7 +1659,6 @@ define([
var keys = filesOp.getFiles([FILES_DATA]); var keys = filesOp.getFiles([FILES_DATA]);
var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), true); var sortedFiles = sortElements(false, [FILES_DATA], keys, Cryptpad.getLSAttribute(SORT_FILE_BY), !getSortFileDesc(), true);
sortedFiles.forEach(function (id) { sortedFiles.forEach(function (id) {
var file = filesOp.getFileData(id);
var $icon = getFileIcon(id); var $icon = getFileIcon(id);
var ro = filesOp.isReadOnlyFile(id); var ro = filesOp.isReadOnlyFile(id);
// ro undefined maens it's an old hash which doesn't support read-only // ro undefined maens it's an old hash which doesn't support read-only

@ -1,8 +1,7 @@
define([ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/userObject.js', '/common/userObject.js',
'json.sortify', ],function (Cryptpad, FO) {
],function (Cryptpad, FO, sortify) {
var module = {}; var module = {};
var href1 = "/pad/#/1/edit/a798u+miu2tg5b-QaP9SvA/UIPoGUPewZscBUFhNIi+eBBM/"; var href1 = "/pad/#/1/edit/a798u+miu2tg5b-QaP9SvA/UIPoGUPewZscBUFhNIi+eBBM/";
@ -126,7 +125,7 @@ define([
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF" && files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
&& typeof files.template[0] === "number" && typeof files.template[0] === "number"
&& typeof files.filesData[files.template[0]] === "object" && typeof files.filesData[files.template[0]] === "object"
&& !files.filesData[files.template[0]].filename && !files.filesData[files.template[0]].filename;
return cb(res); return cb(res);
}, "DRIVE1: migration and fixFiles without unsorted"); }, "DRIVE1: migration and fixFiles without unsorted");
@ -169,7 +168,7 @@ define([
} }
var fileKey = Object.keys(files.root.Folder2)[0]; var fileKey = Object.keys(files.root.Folder2)[0];
var fileKey2 = Object.keys(files.root).filter(function (x) { var fileKey2 = Object.keys(files.root).filter(function (x) {
return typeof files.root[x] === "number" return typeof files.root[x] === "number";
})[0]; })[0];
if (!fileKey || !fileKey2) { return cb(); } if (!fileKey || !fileKey2) { return cb(); }
var fileId = files.root.Folder2[fileKey]; var fileId = files.root.Folder2[fileKey];
@ -179,7 +178,7 @@ define([
&& files.filesData[fileId].filename === "FileName" && files.filesData[fileId].filename === "FileName"
&& typeof fileId2 === "number" && typeof fileId2 === "number"
&& typeof files.filesData[fileId2] === "object" && typeof files.filesData[fileId2] === "object"
&& !files.filesData[fileId2].filename && !files.filesData[fileId2].filename;
return cb(res); return cb(res);
}, "DRIVE2: migration and fixFiles with unsorted"); }, "DRIVE2: migration and fixFiles with unsorted");

Loading…
Cancel
Save