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
This commit is contained in:
Matt Pass
2014-09-17 12:10:18 +01:00
parent f3b89056ac
commit 4314ca2917

View File

@@ -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);
}