|
@@ -2950,35 +2950,21 @@
|
|
|
$("#createNewFileName").parent().removeClass("error");
|
|
|
//Update the newfile list
|
|
|
$("#newFile").find(".newfilelist").html("");
|
|
|
- $.ajax({
|
|
|
- url: "../../system/file_system/newItem",
|
|
|
- success: function(data){
|
|
|
- if (data.error !== undefined){
|
|
|
- return;
|
|
|
- }
|
|
|
- for (var i =0; i < data.length; i++){
|
|
|
- var desc = data[i].Desc;
|
|
|
- var ext = data[i].Ext;
|
|
|
- var icon = ao_module_utils.getIconFromExt(ext);
|
|
|
- $("#newFile").find(".newfilelist").append(`<div class="item newFileFormat" ext="${ext}"><i class="${icon} icon" style="margin-right:12px;"></i> ${desc}</div>`);
|
|
|
- }
|
|
|
- //Initialize the new file as txt
|
|
|
- var filename = "newfile";
|
|
|
- var finalFilename = filename;
|
|
|
- var i = 0;
|
|
|
- while (currentFilelist.includes(finalFilename)){
|
|
|
- finalFilename = finalFilename + "(" + i + ")";
|
|
|
- i++;
|
|
|
- }
|
|
|
- $("#createNewFileName").val(finalFilename + ".txt");
|
|
|
-
|
|
|
- //Hook events for on click
|
|
|
- $(".newFileFormat").off("click").on("click",function(data){
|
|
|
- $(".newFileFormat").removeClass("selected");
|
|
|
- $(this).addClass("selected");
|
|
|
-
|
|
|
- //Parse the newfilename
|
|
|
- var selectedExt = $(this).attr("ext");
|
|
|
+ requestCSRFToken(function(token){
|
|
|
+ $.ajax({
|
|
|
+ url: "../../system/file_system/newItem",
|
|
|
+ data: {csrft: token},
|
|
|
+ success: function(data){
|
|
|
+ if (data.error !== undefined){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (var i =0; i < data.length; i++){
|
|
|
+ var desc = data[i].Desc;
|
|
|
+ var ext = data[i].Ext;
|
|
|
+ var icon = ao_module_utils.getIconFromExt(ext);
|
|
|
+ $("#newFile").find(".newfilelist").append(`<div class="item newFileFormat" ext="${ext}"><i class="${icon} icon" style="margin-right:12px;"></i> ${desc}</div>`);
|
|
|
+ }
|
|
|
+ //Initialize the new file as txt
|
|
|
var filename = "newfile";
|
|
|
var finalFilename = filename;
|
|
|
var i = 0;
|
|
@@ -2986,9 +2972,26 @@
|
|
|
finalFilename = finalFilename + "(" + i + ")";
|
|
|
i++;
|
|
|
}
|
|
|
- $("#createNewFileName").val(filename + "." + selectedExt);
|
|
|
- });
|
|
|
- }
|
|
|
+ $("#createNewFileName").val(finalFilename + ".txt");
|
|
|
+
|
|
|
+ //Hook events for on click
|
|
|
+ $(".newFileFormat").off("click").on("click",function(data){
|
|
|
+ $(".newFileFormat").removeClass("selected");
|
|
|
+ $(this).addClass("selected");
|
|
|
+
|
|
|
+ //Parse the newfilename
|
|
|
+ var selectedExt = $(this).attr("ext");
|
|
|
+ var filename = "newfile";
|
|
|
+ var finalFilename = filename;
|
|
|
+ var i = 0;
|
|
|
+ while (currentFilelist.includes(finalFilename)){
|
|
|
+ finalFilename = finalFilename + "(" + i + ")";
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ $("#createNewFileName").val(filename + "." + selectedExt);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -3039,27 +3042,31 @@
|
|
|
//OK to proceed.
|
|
|
$("#createNewFolder").parent().removeClass("error").addClass("success");
|
|
|
$("#newFolder").find(".duplicateWarning").hide();
|
|
|
- $.ajax({
|
|
|
- url: "../../system/file_system/newItem",
|
|
|
- data: {type: "folder", src: currentPath, filename: newFoldername},
|
|
|
- success: function(data){
|
|
|
- if (data.error !== undefined){
|
|
|
- msgbox("remove", data.error);
|
|
|
- }else{
|
|
|
- msgbox("checkmark","New folder created.");
|
|
|
- refreshList();
|
|
|
- }
|
|
|
- $("#newFolder").fadeOut('fast');
|
|
|
- hideAllPopupWindows();
|
|
|
- if (currentPath == "user:/"){
|
|
|
- //Reload the User root folder list
|
|
|
- initRootDirs();
|
|
|
+ requestCSRFToken(function(token){
|
|
|
+ $.ajax({
|
|
|
+ url: "../../system/file_system/newItem",
|
|
|
+ data: {type: "folder", src: currentPath, filename: newFoldername, csrft: token},
|
|
|
+ success: function(data){
|
|
|
+ if (data.error !== undefined){
|
|
|
+ msgbox("remove", data.error);
|
|
|
+ }else{
|
|
|
+ msgbox("checkmark","New folder created.");
|
|
|
+ refreshList();
|
|
|
+ }
|
|
|
+ $("#newFolder").fadeOut('fast');
|
|
|
+ hideAllPopupWindows();
|
|
|
+ if (currentPath == "user:/"){
|
|
|
+ //Reload the User root folder list
|
|
|
+ initRootDirs();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function confirmNewFile(){
|
|
|
var filename = $("#createNewFileName").val();
|
|
|
if (filename == ""){
|
|
@@ -3074,18 +3081,21 @@
|
|
|
}
|
|
|
$("#createNewFileName").parent().removeClass("error");
|
|
|
//Ok to proceed
|
|
|
- $.ajax({
|
|
|
- url: "../../system/file_system/newItem",
|
|
|
- data: {type: "file", src: currentPath, filename:filename},
|
|
|
- success: function(data){
|
|
|
- if (data.error !== undefined){
|
|
|
- msgbox("remove",data.error);
|
|
|
- }else{
|
|
|
- msgbox("checkmark",filename + " created.");
|
|
|
- refreshList();
|
|
|
+ requestCSRFToken(function(token){
|
|
|
+ $.ajax({
|
|
|
+ url: "../../system/file_system/newItem",
|
|
|
+ data: {type: "file", src: currentPath, filename:filename,csrft: token},
|
|
|
+ success: function(data){
|
|
|
+ if (data.error !== undefined){
|
|
|
+ msgbox("remove",data.error);
|
|
|
+ }else{
|
|
|
+ msgbox("checkmark",filename + " created.");
|
|
|
+ refreshList();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
+
|
|
|
hideAllPopupWindows();
|
|
|
$("#newFile").fadeOut('fast');
|
|
|
}
|