Bläddra i källkod

Fixed share bug

Toby Chui 2 år sedan
förälder
incheckning
bf04c71b60

+ 1 - 1
mod/filesystem/fssort/fssort.go

@@ -120,7 +120,7 @@ func SortDirEntryList(dirEntries []fs.DirEntry, sortMode string) []fs.DirEntry {
 }
 
 func SortModeIsSupported(sortMode string) bool {
-	return contains(sortMode, []string{"default", "reverse", "smallToLarge", "largeToSmall", "mostRecent", "leastRecent", "smart"})
+	return contains(sortMode, ValidSortModes)
 }
 
 func contains(item string, slice []string) bool {

+ 3 - 3
web/SystemAO/file_system/file_explorer.css

@@ -321,7 +321,7 @@ body.darkTheme .ui.icon.button{
     position: relative;
     width: 100%;
     background-color: none;
-    padding: 0.6em;
+    padding: 0.5em;
     padding-left: 1em;
     cursor: pointer;
 }
@@ -351,7 +351,7 @@ body.darkTheme .ui.icon.button{
     border: 1px solid transparent;
     color:var(--navi_txt);
     background-color: transparent;
-    padding: 0.4em;
+    padding: 0.5em;
     padding-left: 1em;
     width: 100%;
     text-align: left;
@@ -501,7 +501,7 @@ body.darkTheme .ui.icon.button{
 }
 
 .mobileFileOprMenuToggle{
-    padding: 1.2em;
+    padding: 1em;
     border: 0px solid transparent;
     color: var(--text_color);
     border-bottom:2px solid var(--navi_theme);

+ 45 - 27
web/SystemAO/file_system/file_explorer.html

@@ -37,16 +37,16 @@
                     <button class="fileoprSmallBtn" title="Rename" onclick="rename();"><i class="teal i cursor icon"></i> <span locale="fileopr/Rename">Rename</span></button>
                 </div>
             </div>
-            <button class="fileOprBtn" title="Upload" onclick="upload();"><img class="opricon" src="img/opr/upload.svg"><p class="oprtxt" locale="fileopr/Upload">Upload</p></button>
-            <button class="fileOprBtn" title="Download" onclick="downloadFile();"><img class="opricon" src="img/opr/download.svg"><p class="oprtxt" locale="fileopr/Download">Download</p></button>
+            <button class="fileOprBtn" title="Upload" onclick="upload(); exitMultiSelectMode();"><img class="opricon" src="img/opr/upload.svg"><p class="oprtxt" locale="fileopr/Upload">Upload</p></button>
+            <button class="fileOprBtn" title="Download" onclick="downloadFile(); exitMultiSelectMode();"><img class="opricon" src="img/opr/download.svg"><p class="oprtxt" locale="fileopr/Download">Download</p></button>
             <div class="fileoprGroupDivider" style="display: inline-block; vertical-align: top; height: 80px;"></div>
-            <button class="twolines fileOprBtn" title="New Folder" onclick="newFolder();"><img class="opricon" src="img/opr/new_folder.svg"><p class="oprtxt" locale="fileopr/New Folder">New<br>Folder</p></button>
+            <button class="twolines fileOprBtn" title="New Folder" onclick="newFolder(); exitMultiSelectMode();"><img class="opricon" src="img/opr/new_folder.svg"><p class="oprtxt" locale="fileopr/New Folder">New<br>Folder</p></button>
             <div class="fileoprGroupDivider desktopOnly" style="display: inline-block; vertical-align: top;">
                 <button class="fileoprSmallBtn" title="New File" onclick="newfile();"><i class="file outline icon"></i> <span locale="fileopr/New File">New File</span></button><br>
                 <button class="fileoprSmallBtn" title="Create Zip" onclick="zipFile();"><i class="brown zip file icon"></i> <span locale="fileopr/Create Zip">Create Zip</span></button><br>
                 <button class="fileoprSmallBtn" title="Unzip Here" onclick="unzipHere();"><i class="inbox icon"></i> <span locale="fileopr/Unzip Here">Unzip Here</span></button><br>
             </div>
-            <div  class="fileoprGroupDivider desktopOnly" style="display: inline-block; vertical-align: top;">
+            <div class="fileoprGroupDivider desktopOnly" style="display: inline-block; vertical-align: top;">
                 <button class="fileoprSmallBtn" title="Refresh" onclick="refreshList();"><i class="green refresh icon"></i> <span locale="fileopr/Refresh">Refresh</span></button><br>
                 <button class="fileoprSmallBtn" title="Home" onclick="openHomeDir();"><i class="home icon"></i> <span locale="fileopr/Home">Home</span></button><br>
                 <button class="fileoprSmallBtn" title="File Info" onclick="showFileProperties();"><i class="blue info circle icon"></i> <span locale="fileopr/File Info">File Info</span></button><br>
@@ -56,7 +56,7 @@
             <div class="fileoprGroupDivider" style="display: inline-block; vertical-align: top; height: 80px;"></div>
             <button class="mobileOnly mobileFileOprMenu" onclick="toggleMobileSidebar(true);">
                 <i class="ui large bars icon"></i>
-            </button> 
+            </button>
             <div style="display: inline-block; vertical-align: top;">
                 <select id="sortingMethodSelector" title="Sorting Method" class="ui basic borderless mini dropdown" onchange="updateSortingMethods();" autocomplete="off" style="min-width: 10em;">
                     <option value="default" locale="menu/sort/asc">Ascending</option>
@@ -96,6 +96,9 @@
                 <button class="fileoprSmallBtnMobile" title="Multi Select" onclick="toggleCtrl(); toggleMobileSidebar(false);"> <i class="mouse pointer icon"></i> <span locale="fileopr/Multi Select">Multi-select</span></button><br>
                 <button class="fileoprSmallBtnMobile" title="Multi Select" onclick="selectAll(); toggleMobileSidebar(false);"> <i class="plus square icon"></i> <span locale="fileopr/Select All">Select All</span></button><br>
                 <button class="fileoprSmallBtnMobile" title="Clear Selection" onclick="clearSelection(); toggleMobileSidebar(false, exitMultiSelectMode);"> <i class="remove icon"></i> <span locale="fileopr/Clear Select">Clear Selection</span></button><br><button class="fileoprSmallBtnMobile" title="New File" onclick="newfile();"><i class="file outline icon"></i> <span locale="fileopr/New File">New File</span></button><br>
+                <button class="fileoprSmallBtnMobile" title="Open with" onclick="openWith();"><i class="external icon"></i> <span locale="fileopr/Open with">Open With</span></button><br>
+                <button class="fileoprSmallBtnMobile" title="Cut" onclick="cut();"><i class="blue cut icon"></i> <span locale="fileopr/Cut">Cut</span></button><br>
+                <button class="fileoprSmallBtnMobile" title="Rename" onclick="rename();"><i class="teal i cursor icon"></i> <span locale="fileopr/Rename">Rename</span></button>
                 <button class="fileoprSmallBtnMobile" title="Create Zip" onclick="zipFile(); toggleMobileSidebar(false, exitMultiSelectMode);"><i class="brown zip file icon"></i> <span locale="fileopr/Create Zip">Create Zip</span></button><br>
                 <button class="fileoprSmallBtnMobile" title="Unzip Here" onclick="unzipHere(); toggleMobileSidebar(false, exitMultiSelectMode);"><i class="inbox icon"></i> <span locale="fileopr/Unzip Here">Unzip Here</span></button><br>
                 <button class="fileoprSmallBtnMobile" title="Refresh" onclick="refreshList(); toggleMobileSidebar(false);"><i class="green refresh icon"></i> <span locale="fileopr/Refresh">Refresh</span></button><br>
@@ -891,6 +894,10 @@
                     hideManualOpenPathInput();
                 }
 
+                if (isMobile && ctrlHold){
+                    exitMultiSelectMode();
+                }
+
                 //Backup the current selected files if it is an refresh operation
                 let selectedFiles = [];
                 let currentScrollTop = JSON.parse(JSON.stringify($("#folderView").scrollTop()));
@@ -1170,7 +1177,7 @@
 
                         }
                        
-                        $("#folderList").append(`<div class="fileObject item" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="folder">
+                        $("#folderList").append(`<div class="fileObject item" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event,true);" type="folder">
                             <span style="display:inline-block !important;word-break: break-all; width:100%;" class="${textclass}">
                                 <i class="${icon} icon" style="margin-right:12px; color:#eab54e;"></i>  <span class="filename">${displayName}</span> ${shareicon}
                             </span></div>`);
@@ -1191,7 +1198,7 @@
                             displayName = displayName.substring(0,16) + "...";
                         }
                         $("#folderList").append(`
-                        <div class="fileObject card" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="folder" style="width:${gridSize}px; display:inline-block !important;vertical-align:top; height:15em; margin-top:0px !important; overflow:hidden;">
+                        <div class="fileObject card" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event,true);" type="folder" style="width:${gridSize}px; display:inline-block !important;vertical-align:top; height:15em; margin-top:0px !important; overflow:hidden;">
                             <div class="image" style="text-align: center;">
                                 <img draggable="true"ondragstart="disableDrag(event);" src="../../img/desktop/files_icon/${filesIconTheme}/folder.png" style="height: 148px; width: 148px; display: inline-block;">
                                 <div class="shareOverlay ${isShared?"visible":""}">${shareicon}</div>
@@ -1209,7 +1216,7 @@
 
                         //Convert the unix timestamp to datetime
                         var date = new Date(modTime * 1000);
-                        $("#folderList").find(".folderDetailList").append(`<tr class="fileObject details" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="folder">
+                        $("#folderList").find(".folderDetailList").append(`<tr class="fileObject details" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event,true);" type="folder">
                             <td><i class="${icon} icon" style="margin-right:12px; color:#eab54e;"></i> <span class="filename">${filename}</span></td>
                             <td class="light-text">${date.toLocaleDateString("default") + " " + date.toLocaleTimeString("default")}</td>
                             <td>${isSharedIcon}</td>
@@ -1293,7 +1300,7 @@
                             }
                             filename = ao_module_codec.decodeUmFilename(filename);
                         }
-                        $("#fileList").append(`<div class="fileObject item" draggable="true" ondragstart="onFileObjectDragStart(this,event);"  fileID="${fl + i}"  filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);"  type="${fileType}" filesize="${filesize}" displaysize="${Displaysize}">
+                        $("#fileList").append(`<div class="fileObject item" draggable="true" ondragstart="onFileObjectDragStart(this,event);"  fileID="${fl + i}"  filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event, true);"  type="${fileType}" filesize="${filesize}" displaysize="${Displaysize}">
                             <span style="display:inline-block !important;word-break: break-all;text-overflow: ellipsis !important;overflow: hidden;" class="${textclass}">
                                 <i class="${icon} icon" style="margin-right:12px;"></i>  
                                 <span class="filename">${displayName}</span>  ${shareicon}
@@ -1376,7 +1383,7 @@
 
                         var date = new Date(modTime * 1000);
 
-                        $("#fileList").find(".fileDetailList").append(`<tr class="fileObject details" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event);" type="file">
+                        $("#fileList").find(".fileDetailList").append(`<tr class="fileObject details" draggable="true" ondragstart="onFileObjectDragStart(this,event);" ondrop="dropToFolder(event)" ondragover="allowDrop(event)" fileID="${i}" filename="${filename}" filepath="${filepath}" ondblclick="openthis(this,event,true);" type="file">
                             <td><i class="${icon} icon" style="margin-right:12px;"></i>  <span class="filename">${filename}</span></td>
                             <td class="light-text">${ext}</td>
                             <td class="light-text">${Displaysize}</td>
@@ -1568,6 +1575,7 @@
             var lastClickedFileID = 0;
             function bindFileObjectEvents(){
                 $(".fileObject").off("click").on("click",function(evt){
+                    evt.stopImmediatePropagation();
                     if (renameMode && $(this).find(".renameinput").length == 0){
                         exitRenameModeWithConfirm();
                         return;
@@ -1576,23 +1584,15 @@
                         evt.stopImmediatePropagation();
                     }
 
-                    if (!ctrlHold && isMobile && !ctrlHold){
-                        //If on mobile, click means open (only on not muilti selection mode)
-                        evt.preventDefault();
-                        evt.stopImmediatePropagation();
-                        openthis(this,evt);
-
-                        //Deselect everything if in multi-select mode
-                        if (ctrlHold){
-                            ctrlHold = false;
-                            updateCtrlDisplay();
-                        }
-                        return
-                    }
-
                     if (ctrlHold == true){
                         if ($(this).hasClass("selected")){
                             $(this).removeClass("selected");
+
+                            //if there are no more selected files on the page
+                            //exit multi-select mode
+                            if ($(".fileObject.selected").length == 0){
+                                exitMultiSelectMode();
+                            }
                         }else{
                             $(this).addClass("selected");
                         }
@@ -1615,7 +1615,18 @@
                                 $(this).addClass("selected");
                             }
                         });
+                    }else if(!ctrlHold && isMobile){
+                        //If on mobile, click means open (only on not muilti selection mode)
+                        evt.preventDefault();
+                        evt.stopImmediatePropagation();
+                        openthis(this,evt);
 
+                        //Deselect everything if in multi-select mode
+                        if (ctrlHold){
+                            ctrlHold = false;
+                            updateCtrlDisplay();
+                        }
+                        return
                     }else{
                         //Nothing is pressed. Deselect everything and add this only
                         $(".fileObject.selected").removeClass("selected");
@@ -2875,11 +2886,16 @@
                 openFolderInNewWindow(foldersToBeOpened);
             }
 
-            function openthis(object,evt=null){
+            function openthis(object,evt=null, isDoubleClick=false){
                 if (evt !== null){
                     evt.preventDefault();
                 }
 
+                if (isDoubleClick && isMobile && ctrlHold){
+                    //User is clicking too fast or touch screen is too sensitive! ignore this double click
+                    return;
+                }
+
                 if (renameMode && $(object).find(".renameinput").length > 0){
                     //This object is currently under rename. Ignore input
                     return;
@@ -3605,14 +3621,15 @@
                     var thisFilename = $(this).attr("filename");
                     selectedFiles.push(thisFilepath);
                     selectedFileObjects.push({"filepath": thisFilepath, "filename": thisFilename});
-
                 });
 
                 if (selectedFiles.length == 0){
+                    msgbox("question", applocale.getString("message/No file selected", "No file selected"));
                     console.log("No file is selected for sharing");
                     return;
-                }else if (selectedFiles > 1){
+                }else if (selectedFiles.length > 1){
                     //Try to share more than 1 files, which is not supported
+                    msgbox("yellow exclamation", applocale.getString("message/Multiple files share is currently not supported", "Multiple files share is currently not supported"));
                     console.log("Multi share is current not supported");
                     return
                 }
@@ -3710,6 +3727,7 @@
             function exitMultiSelectMode(){
                 if (ctrlHold){
                     ctrlHold = false;
+                    $(".fileObject.selected").removeClass("selected");
                     updateCtrlDisplay();
                 }
             }

+ 1 - 0
web/SystemAO/locale/file_explorer.json

@@ -232,6 +232,7 @@
                 "message/Incompatible File System Type: Try SHIFT + DELETE to delete file permanently":"檔案系統不支援檔案回收:請使用 SHIFT + DELETE 以永久移除檔案",
                 "message/Recursive copy operation.":"遞歸複製操作",
                 "message/Source and destination paths are identical.":"目的地與來源路徑相同",
+                "message/Multiple files share is currently not supported":"不支援多個檔案分享",
 
                 "message/noMatchResults":"找不到匹配的檔案",
                 "message/noMatchResultsDesc":"伺服器找不到與此關鍵字匹配的檔案",