|
|
@@ -596,17 +596,98 @@
|
|
|
//Intiiation functions
|
|
|
$(document).ready(function(){
|
|
|
$("#contextmenu").css("display", "hidden");
|
|
|
+
|
|
|
+ //Function to complete initialization after applocale is ready
|
|
|
+ function completeInitialization(){
|
|
|
+ initRootDirs();
|
|
|
+ initSystemInfo();
|
|
|
+ initUploadMode();
|
|
|
+ $(".dropdown").dropdown();
|
|
|
+ $("#sortingMethodSelector").dropdown("set selected", sortMode);
|
|
|
+ updateSelectedObjectsCount();
|
|
|
+ initWindowSizes(false);
|
|
|
+
|
|
|
+ //Initialize view mode buttons
|
|
|
+ updateViewmodeButtons();
|
|
|
+
|
|
|
+ //Initialize system theme
|
|
|
+ loadPreference("file_explorer/theme",function(data){
|
|
|
+ if (data.error === undefined){
|
|
|
+ if (data == "darkTheme"){
|
|
|
+ toggleDarkTheme();
|
|
|
+ }else{
|
|
|
+ //White theme
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //Initialize properties view
|
|
|
+ if (localStorage.getItem("file_explorer/viewProperties") == "true"){
|
|
|
+ $("#togglePropertiesViewBtn").click();
|
|
|
+ }
|
|
|
+
|
|
|
+ //Initialize directory views based on hash
|
|
|
+ if (window.location.hash != ""){
|
|
|
+ //Check if the hash is standard open protocol. If yes, translate it
|
|
|
+ if (ao_module_loadInputFiles() === null){
|
|
|
+ //Window location hash set. List the desire directory
|
|
|
+ currentPath = window.location.hash.substring(1,window.location.hash.length);
|
|
|
+ if (currentPath.substring(currentPath.length -1) != "/"){
|
|
|
+ currentPath = currentPath + "/";
|
|
|
+ }
|
|
|
+ currentPath = decodeURIComponent(currentPath);
|
|
|
+ loadListModeFromDB(function(){
|
|
|
+ listDirectory(currentPath);
|
|
|
+ });
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //This is ao_module load file input. Handle the file opening
|
|
|
+ var filelist = ao_module_loadInputFiles();
|
|
|
+ if (filelist.length > 0){
|
|
|
+ filelist = filelist[0];
|
|
|
+ //Check if this is folder or file. Only opendir when it is folder
|
|
|
+ //Updates 27-12-2020: Open folder and highlight the file if it is file
|
|
|
+ if (filelist.filename.includes(".") == false){
|
|
|
+ //Try to open it and overwrite the hash to filesystem hash
|
|
|
+ loadListModeFromDB(function(){
|
|
|
+ listDirectory(filelist.filepath);
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ //File. Open its parent folder and highlight the target file if exists
|
|
|
+ var parentdir = filelist.filepath.split("/");
|
|
|
+ let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
|
|
|
+ parentdir.pop();
|
|
|
+ parentdir = parentdir.join("/");
|
|
|
+ loadListModeFromDB(function(){
|
|
|
+ listDirectory(parentdir, function(){
|
|
|
+ if (focusFilename != ""){
|
|
|
+ //Timeout to give the DOM time to render
|
|
|
+ //DO NOT REPLACE THIS WITH listDirectoryAndHighlight
|
|
|
+ //Additional delay are required on page load
|
|
|
+ setTimeout(function(){
|
|
|
+ focusFileObject(focusFilename);
|
|
|
+ }, 300);
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //Initialized directory views
|
|
|
+ loadListModeFromDB(function(){
|
|
|
+ listDirectory(currentPath);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (applocale){
|
|
|
//Applocale found. Do localization
|
|
|
applocale.init("../locale/file_explorer.json", function(){
|
|
|
applocale.translate();
|
|
|
- initRootDirs();
|
|
|
- initSystemInfo();
|
|
|
- initUploadMode();
|
|
|
- $(".dropdown").dropdown();
|
|
|
- $("#sortingMethodSelector").dropdown("set selected", sortMode);
|
|
|
- updateSelectedObjectsCount();
|
|
|
- initWindowSizes(false);
|
|
|
+ completeInitialization();
|
|
|
});
|
|
|
}else{
|
|
|
//Applocale not found. Is this a trim down version of ArozOS?
|
|
|
@@ -615,10 +696,7 @@
|
|
|
return original;
|
|
|
}
|
|
|
}
|
|
|
- initRootDirs();
|
|
|
- initSystemInfo();
|
|
|
- initUploadMode();
|
|
|
- $(".dropdown").dropdown();
|
|
|
+ completeInitialization();
|
|
|
}
|
|
|
|
|
|
if (isMobile){
|
|
|
@@ -648,82 +726,6 @@
|
|
|
$(".mobileOnly").hide();
|
|
|
$(".desktopOnly").show();
|
|
|
}
|
|
|
- //Initialize view mode buttons
|
|
|
- updateViewmodeButtons();
|
|
|
- loadListModeFromDB();
|
|
|
-
|
|
|
- //Initialize system theme
|
|
|
- loadPreference("file_explorer/theme",function(data){
|
|
|
- if (data.error === undefined){
|
|
|
- if (data == "darkTheme"){
|
|
|
- toggleDarkTheme();
|
|
|
- }else{
|
|
|
- //White theme
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //Initialize properties view
|
|
|
- if (localStorage.getItem("file_explorer/viewProperties") == "true"){
|
|
|
- $("#togglePropertiesViewBtn").click();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (window.location.hash != ""){
|
|
|
- //Check if the hash is standard open protocol. If yes, translate it
|
|
|
- if (ao_module_loadInputFiles() === null){
|
|
|
- //Window location hash set. List the desire directory
|
|
|
- currentPath = window.location.hash.substring(1,window.location.hash.length);
|
|
|
- if (currentPath.substring(currentPath.length -1) != "/"){
|
|
|
- currentPath = currentPath + "/";
|
|
|
- }
|
|
|
- currentPath = decodeURIComponent(currentPath);
|
|
|
- loadListModeFromDB(function(){
|
|
|
- listDirectory(currentPath);
|
|
|
- });
|
|
|
-
|
|
|
- }else{
|
|
|
- //This is ao_module load file input. Handle the file opening
|
|
|
- var filelist = ao_module_loadInputFiles();
|
|
|
- if (filelist.length > 0){
|
|
|
- filelist = filelist[0];
|
|
|
- //Check if this is folder or file. Only opendir when it is folder
|
|
|
- //Updates 27-12-2020: Open folder and highlight the file if it is file
|
|
|
- if (filelist.filename.includes(".") == false){
|
|
|
- //Try to open it and overwrite the hash to filesystem hash
|
|
|
- loadListModeFromDB(function(){
|
|
|
- listDirectory(filelist.filepath);
|
|
|
- });
|
|
|
- }else{
|
|
|
- //File. Open its parent folder and highlight the target file if exists
|
|
|
- var parentdir = filelist.filepath.split("/");
|
|
|
- let focusFilename = JSON.parse(JSON.stringify(filelist.filename));
|
|
|
- parentdir.pop();
|
|
|
- parentdir = parentdir.join("/");
|
|
|
- loadListModeFromDB(function(){
|
|
|
- listDirectory(parentdir, function(){
|
|
|
- if (focusFilename != ""){
|
|
|
- //Timeout to give the DOM time to render
|
|
|
- //DO NOT REPLACE THIS WITH listDirectoryAndHighlight
|
|
|
- //Additional delay are required on page load
|
|
|
- setTimeout(function(){
|
|
|
- focusFileObject(focusFilename);
|
|
|
- }, 300);
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
-
|
|
|
- //Initialized directory views
|
|
|
- loadListModeFromDB(function(){
|
|
|
- listDirectory(currentPath);
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -909,8 +911,12 @@
|
|
|
if (recordPreviousPage){
|
|
|
viewHistory.push(currentPath);
|
|
|
}
|
|
|
-
|
|
|
- window.location.hash = path;
|
|
|
+
|
|
|
+ if (!ao_module_virtualDesktop){
|
|
|
+ //Update the window hash
|
|
|
+ window.location.hash = encodeURIComponent(path);
|
|
|
+ }
|
|
|
+
|
|
|
updatePathDisplay(path);
|
|
|
currentPath = path;
|
|
|
|
|
|
@@ -2363,6 +2369,17 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //Check if filename contains web-unsafe characters
|
|
|
+ function filenameContainsIllegalCharacters(filename){
|
|
|
+ var illegalChars = ['/', '\\', '?', '%', '*', ':', '|', '"', '<', '>'];
|
|
|
+ for (var i = 0; i < illegalChars.length; i++){
|
|
|
+ if (filename.includes(illegalChars[i])){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
function confirmRename(oldName=undefined, newName=undefined){
|
|
|
renameMode = false;
|
|
|
if (oldName == undefined){
|
|
|
@@ -2373,6 +2390,12 @@
|
|
|
newName = $("#renameBox").find(".newfn").val().trim();
|
|
|
}
|
|
|
|
|
|
+ //Check for illegal characters
|
|
|
+ if (filenameContainsIllegalCharacters(newName)){
|
|
|
+ msgbox("red remove", applocale.getString("message/illegalCharacters", "Filename contains illegal characters"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (newName == oldName){
|
|
|
msgbox("red remove",applocale.getString("message/newFilenameIdentical", "New filename is identical to the original filename."));
|
|
|
hideAllPopupWindows();
|
|
|
@@ -3208,8 +3231,9 @@
|
|
|
}
|
|
|
|
|
|
//Check for invalid characters
|
|
|
- if (newFoldername.includes("%")){
|
|
|
+ if (filenameContainsIllegalCharacters(newFoldername)){
|
|
|
$("#createNewFolder").parent().addClass("error");
|
|
|
+ msgbox("red remove", applocale.getString("message/illegalCharacters", "Folder name contains illegal characters"));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -3253,7 +3277,16 @@
|
|
|
//Filename not set
|
|
|
$("#createNewFileName").parent().addClass("error");
|
|
|
return;
|
|
|
- }else if(currentFilelist.includes(filename)){
|
|
|
+ }
|
|
|
+
|
|
|
+ //Check for illegal characters
|
|
|
+ if (filenameContainsIllegalCharacters(filename)){
|
|
|
+ $("#createNewFileName").parent().addClass("error");
|
|
|
+ msgbox("red remove", applocale.getString("message/illegalCharacters", "Filename contains illegal characters"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(currentFilelist.includes(filename)){
|
|
|
//File with this name already exists
|
|
|
$("#createNewFileName").parent().addClass("error");
|
|
|
$("#newFile").find(".duplicateWarning").show();
|