From 4314ca29178f95cd2e441851c4945c04144460c8 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 17 Sep 2014 12:10:18 +0100 Subject: [PATCH] Path fixes for add and delete actions When adding files, location should be a slash if not set Remove any initial double slashes When removing files, location should be blank if not set. Then replace iceRoot with a slash, before reducing double slashes at start, slashes for pipes and tack together with file to make the targetElem, which is what we end up looking for --- lib/ice-coder.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index a522281..8f4be48 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1000,7 +1000,7 @@ var ICEcoder = { // Update the file manager tree list on demand updateFileManagerList: function(action,location,file,perms,oldName,uploaded,fileOrFolder) { - var actionElemType, cssStyle, perms, targetElem, locNest, newText, innerLI, newUL, newLI, elemType, nameLI, shortURL, newMouseOver; + var actionElemType, cssStyle, perms, targetElem, locNest, newText, innerLI, newUL, newLI, elemType, nameLI, shortURL, newMouseOver; // Adding files if (action=="add" && !top.get('filesFrame').contentWindow.document.getElementById(location.replace(top.iceRoot,"").replace(/\/$/, "").replace(/\//g,"|")+"|"+file)) { @@ -1010,8 +1010,9 @@ var ICEcoder = { perms = actionElemType=="file" ? 664 : 705; // Identify our target element & the first child element in it's location - if (!location) {location=""} + if (!location) {location="/"} location = location.replace(top.iceRoot,"/"); + location = location.replace("//","/"); targetElem = top.get('filesFrame').contentWindow.document.getElementById(location.replace(/\//g,"|")); locNest = targetElem.parentNode.parentNode.nextSibling; newText = document.createTextNode("\n"); @@ -1101,10 +1102,12 @@ var ICEcoder = { // Deleting files if (action=="delete") { - // Simply get our target and make it dissapear - targetElem = top.get('filesFrame').contentWindow.document.getElementById( - (top.iceRoot == "" ? location.replace(/\/$/, "").replace(/\//g,"|") : "") - +"|"+file).parentNode.parentNode; + if (!location) {location=""} + location = location.replace(top.iceRoot,"/"); + location = location.replace("//","/"); + location = location.replace(/\/$/, "").replace(/\//g,"|"); + targetElem = (location +"|"+file).replace("||","|"); + targetElem = top.get('filesFrame').contentWindow.document.getElementById(targetElem).parentNode.parentNode; top.ICEcoder.openCloseDir(targetElem.childNodes[0],false); targetElem.parentNode.removeChild(targetElem); }