From 4e61b79f9ac506d29a53fb5db2a0050e6e4c40e1 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 11 Apr 2017 15:11:33 +0200 Subject: [PATCH] Clean fileObject --- www/common/fileObject.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/www/common/fileObject.js b/www/common/fileObject.js index a397cf928..202a67f4c 100644 --- a/www/common/fileObject.js +++ b/www/common/fileObject.js @@ -89,12 +89,15 @@ define([ var isPathInTrash = exp.isPathInTrash = function (path) { return path[0] && path[0] === TRASH; }; + var isInTrashRoot = exp.isInTrashRoot = function (path) { + return path[0] === TRASH && path.length === 4; + }; var isPathInFilesData = exp.isPathInFilesData = function (path) { return path[0] && path[0] === FILES_DATA; }; - var isFile = exp.isFile = function (element) { + var isFile = exp.isFile = function (element) { return typeof(element) === "string"; }; @@ -439,10 +442,6 @@ define([ return paths; }; - var isInTrashRoot = exp.isInTrashRoot = function (path) { - return path[0] === TRASH && path.length === 4; - }; - var removePadAttribute = function (f) { Object.keys(files).forEach(function (key) { var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null; @@ -486,9 +485,9 @@ define([ var parentPath = path.slice(); var key = parentPath.pop(); var parentEl = exp.findElement(files, parentPath); - if (path.length === 4 && path[0] === TRASH) { + if (isInTrashRoot(path)) { files[TRASH][path[1]].splice(path[2], 1); - } else if (path[0] === UNSORTED || path[0] === TEMPLATE) { + } else if (isPathInHrefArray(path)) { parentEl.splice(key, 1); } else { parentEl[key] = undefined;