|
@@ -765,7 +765,28 @@
|
|
|
border-top: 1px solid var(--fs-line);
|
|
border-top: 1px solid var(--fs-line);
|
|
|
flex-shrink: 0;
|
|
flex-shrink: 0;
|
|
|
flex-wrap: wrap;
|
|
flex-wrap: wrap;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ }
|
|
|
|
|
+ /* A typed folder path that could not be opened, floated above the footer */
|
|
|
|
|
+ .fsPathError{
|
|
|
|
|
+ display: none;
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ left: 14px;
|
|
|
|
|
+ right: 14px;
|
|
|
|
|
+ bottom: 100%;
|
|
|
|
|
+ margin-bottom: 6px;
|
|
|
|
|
+ z-index: 120;
|
|
|
|
|
+ padding: 8px 12px;
|
|
|
|
|
+ border-radius: 8px;
|
|
|
|
|
+ background: var(--fs-toast-error-bg);
|
|
|
|
|
+ /* !important: ao.css repaints every div under a themed body */
|
|
|
|
|
+ color: var(--fs-toast-error-fg) !important;
|
|
|
|
|
+ box-shadow: 0 4px 14px var(--fs-shadow);
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ word-break: break-all;
|
|
|
}
|
|
}
|
|
|
|
|
+ .fsPathError.show{ display: block; }
|
|
|
|
|
+ .fsFooter #filename.invalid{ border-color: var(--fs-toast-error-bg); }
|
|
|
.fsFooterLabel{
|
|
.fsFooterLabel{
|
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
|
color: var(--fs-text);
|
|
color: var(--fs-text);
|
|
@@ -1087,6 +1108,7 @@
|
|
|
|
|
|
|
|
<!-- Footer -->
|
|
<!-- Footer -->
|
|
|
<div class="fsFooter">
|
|
<div class="fsFooter">
|
|
|
|
|
+ <div class="fsPathError" id="pathError" role="alert"></div>
|
|
|
<span class="fsFooterLabel" id="filenameLabel" locale="footer/filename">File name(N):</span>
|
|
<span class="fsFooterLabel" id="filenameLabel" locale="footer/filename">File name(N):</span>
|
|
|
<input id="filename" type="text" spellcheck="false" autocomplete="off" placeholder="New Filename">
|
|
<input id="filename" type="text" spellcheck="false" autocomplete="off" placeholder="New Filename">
|
|
|
<select id="filterSelect" onchange="renderFileList();"></select>
|
|
<select id="filterSelect" onchange="renderFileList();"></select>
|
|
@@ -1145,6 +1167,10 @@
|
|
|
|
|
|
|
|
The result is handed back either through the float window parent callback
|
|
The result is handed back either through the float window parent callback
|
|
|
(inside the ArozOS desktop) or through localStorage[listenerUUID].
|
|
(inside the ArozOS desktop) or through localStorage[listenerUUID].
|
|
|
|
|
+
|
|
|
|
|
+ A folder path may also be typed into the name field: "file" and "new"
|
|
|
|
|
+ pickers open that folder, a "folder" picker returns it, see
|
|
|
|
|
+ openTypedPath().
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------ */
|
|
@@ -1341,6 +1367,7 @@
|
|
|
}else{
|
|
}else{
|
|
|
$("#filename").val("newfile.txt");
|
|
$("#filename").val("newfile.txt");
|
|
|
}
|
|
}
|
|
|
|
|
+ lastPlainFilename = $("#filename").val();
|
|
|
/*
|
|
/*
|
|
|
This picker writes a new file rather than opening an
|
|
This picker writes a new file rather than opening an
|
|
|
existing one, so the confirm button says so.
|
|
existing one, so the confirm button says so.
|
|
@@ -1353,9 +1380,11 @@
|
|
|
$("#confirmBtn").attr("locale", "footer/create")
|
|
$("#confirmBtn").attr("locale", "footer/create")
|
|
|
.text(applocale.getString("footer/create", "Create"));
|
|
.text(applocale.getString("footer/create", "Create"));
|
|
|
}else if (type == "folder"){
|
|
}else if (type == "folder"){
|
|
|
- //A filename has no meaning when picking a folder
|
|
|
|
|
- $("#filename").hide();
|
|
|
|
|
- $("#filenameLabel").hide();
|
|
|
|
|
|
|
+ //The name field takes a folder name or path here. Left empty,
|
|
|
|
|
+ //the folder being browsed is the one picked
|
|
|
|
|
+ $("#filenameLabel").attr("locale", "footer/folder")
|
|
|
|
|
+ .text(applocale.getString("footer/folder", "Folder:"));
|
|
|
|
|
+ $("#filename").attr("placeholder", applocale.getString("footer/folderhint", "Current folder, or type a path"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
buildFilterOptions();
|
|
buildFilterOptions();
|
|
@@ -1561,10 +1590,16 @@
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------ */
|
|
|
/* Directory listing */
|
|
/* Directory listing */
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------ */
|
|
|
- function listDir(dir, pushHistory){
|
|
|
|
|
|
|
+ //preloaded: the listing of "dir" when the caller has already fetched it
|
|
|
|
|
+ function listDir(dir, pushHistory, preloaded){
|
|
|
if (pushHistory === undefined){
|
|
if (pushHistory === undefined){
|
|
|
pushHistory = true;
|
|
pushHistory = true;
|
|
|
}
|
|
}
|
|
|
|
|
+ //A folder picker's name field belongs to the folder it was typed in
|
|
|
|
|
+ if (type == "folder" && dir != currentDir){
|
|
|
|
|
+ $("#filename").val("");
|
|
|
|
|
+ }
|
|
|
|
|
+ clearPathError();
|
|
|
currentDir = dir;
|
|
currentDir = dir;
|
|
|
if (pushHistory){
|
|
if (pushHistory){
|
|
|
//Drop anything ahead of the cursor before appending, so that
|
|
//Drop anything ahead of the cursor before appending, so that
|
|
@@ -1598,6 +1633,13 @@
|
|
|
$("#loadingPlaceholder").addClass("show");
|
|
$("#loadingPlaceholder").addClass("show");
|
|
|
clearDetails();
|
|
clearDetails();
|
|
|
|
|
|
|
|
|
|
+ if (preloaded !== undefined){
|
|
|
|
|
+ $("#loadingPlaceholder").removeClass("show");
|
|
|
|
|
+ currentFileList = preloaded || [];
|
|
|
|
|
+ renderFileList();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$.ajax({
|
|
$.ajax({
|
|
|
url: "../../system/file_system/listDir",
|
|
url: "../../system/file_system/listDir",
|
|
|
data: {dir: dir, sort: "default", showHidden: showHidden ? "true" : "false"},
|
|
data: {dir: dir, sort: "default", showHidden: showHidden ? "true" : "false"},
|
|
@@ -2380,6 +2422,16 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function confirmSelection(){
|
|
function confirmSelection(){
|
|
|
|
|
+ var typedPath = getTypedPath();
|
|
|
|
|
+ if (typedPath != ""){
|
|
|
|
|
+ openTypedPath(typedPath);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ confirmListedSelection();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Confirm what is highlighted, or the name typed for it
|
|
|
|
|
+ function confirmListedSelection(){
|
|
|
var files = [];
|
|
var files = [];
|
|
|
$("#fileArea").find(".fileObject.selected").each(function(){
|
|
$("#fileArea").find(".fileObject.selected").each(function(){
|
|
|
files.push({
|
|
files.push({
|
|
@@ -2415,17 +2467,7 @@
|
|
|
//Check for special cases
|
|
//Check for special cases
|
|
|
if (files.length == 0 && type == "folder"){
|
|
if (files.length == 0 && type == "folder"){
|
|
|
//Select the current path as target instead
|
|
//Select the current path as target instead
|
|
|
- var currentPathname = currentDir.split("/");
|
|
|
|
|
- currentPathname.pop();
|
|
|
|
|
- currentPathname = currentPathname.pop();
|
|
|
|
|
- if (currentPathname == ""){
|
|
|
|
|
- currentPathname = currentDir;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- files.push({
|
|
|
|
|
- filename: currentPathname,
|
|
|
|
|
- filepath: currentDir
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ files.push(folderResult(currentDir));
|
|
|
}else if (files.length == 0 && type == "new"){
|
|
}else if (files.length == 0 && type == "new"){
|
|
|
//Push this new file into the return structure
|
|
//Push this new file into the return structure
|
|
|
var newFilename = $("#filename").val();
|
|
var newFilename = $("#filename").val();
|
|
@@ -2470,6 +2512,152 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //The result entry for a whole folder, "dir" ending with "/"
|
|
|
|
|
+ function folderResult(dir){
|
|
|
|
|
+ var segments = dir.split("/");
|
|
|
|
|
+ segments.pop();
|
|
|
|
|
+ return {
|
|
|
|
|
+ filename: segments.pop() || dir,
|
|
|
|
|
+ filepath: dir
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ------------------------------------------------------------------ */
|
|
|
|
|
+ /* Typed paths */
|
|
|
|
|
+ /* ------------------------------------------------------------------ */
|
|
|
|
|
+ /*
|
|
|
|
|
+ The name field also takes a location: a full path such as
|
|
|
|
|
+ "user:/Document/", a path relative to the folder on screen ("../Photo")
|
|
|
|
|
+ or the name of a folder in it. A file picker ("file" and "new") goes
|
|
|
|
|
+ to that folder. A folder picker returns it as the result.
|
|
|
|
|
+ */
|
|
|
|
|
+ var typedPathPending = false;
|
|
|
|
|
+ var lastPlainFilename = ""; //Put back in "new" mode after a path replaced it
|
|
|
|
|
+
|
|
|
|
|
+ function looksLikePath(value){
|
|
|
|
|
+ return /[\/\\]/.test(value) || /^[^:]+:$/.test(value) || value == "." || value == "..";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //What the name field asks to open as a folder, "" when it is to be
|
|
|
|
|
+ //read as the name of a selection
|
|
|
|
|
+ function getTypedPath(){
|
|
|
|
|
+ var value = $("#filename").val().trim();
|
|
|
|
|
+ if (value == ""){
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ var listed = getFileObjectByName(value);
|
|
|
|
|
+ if (type == "folder"){
|
|
|
|
|
+ //A highlighted folder filled the field itself, and a name that is
|
|
|
|
|
+ //on screen is picked from the listing without asking the server
|
|
|
|
|
+ var highlighted = $("#fileArea").find(".fileObject.selected").length > 0;
|
|
|
|
|
+ return (highlighted || (listed != null && listed.IsDir)) ? "" : value;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (looksLikePath(value)){
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ return (listed != null && listed.IsDir) ? value : "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Turn typed text into a virtual directory path ending with "/".
|
|
|
|
|
+ //Relative text is read from baseDir, a leading "/" from its drive root
|
|
|
|
|
+ function resolveTypedPath(value, baseDir){
|
|
|
|
|
+ var path = value.replace(/\\/g, "/");
|
|
|
|
|
+ var root;
|
|
|
|
|
+ var rest;
|
|
|
|
|
+ var absolute = path.match(/^([^\/:]+:)(\/.*)?$/);
|
|
|
|
|
+ if (absolute != null){
|
|
|
|
|
+ root = absolute[1] + "/";
|
|
|
|
|
+ rest = absolute[2] || "";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ var base = baseDir.match(/^([^\/:]+:)\/?(.*)$/);
|
|
|
|
|
+ root = base[1] + "/";
|
|
|
|
|
+ rest = path.charAt(0) == "/" ? path : base[2] + "/" + path;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var segments = [];
|
|
|
|
|
+ rest.split("/").forEach(function(segment){
|
|
|
|
|
+ if (segment == ".."){
|
|
|
|
|
+ segments.pop();
|
|
|
|
|
+ }else if (segment != "" && segment != "."){
|
|
|
|
|
+ segments.push(segment);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return segments.length == 0 ? root : root + segments.join("/") + "/";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function openTypedPath(typed){
|
|
|
|
|
+ if (typedPathPending){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ var fromDir = currentDir;
|
|
|
|
|
+ var target = resolveTypedPath(typed, fromDir);
|
|
|
|
|
+ typedPathPending = true;
|
|
|
|
|
+
|
|
|
|
|
+ //Listing it is what tells whether it is a folder this user can open
|
|
|
|
|
+ $.ajax({
|
|
|
|
|
+ url: "../../system/file_system/listDir",
|
|
|
|
|
+ data: {dir: target, sort: "default", showHidden: showHidden ? "true" : "false"},
|
|
|
|
|
+ success: function(data){
|
|
|
|
|
+ typedPathPending = false;
|
|
|
|
|
+ if (currentDir != fromDir || $("#filename").val().trim() != typed){
|
|
|
|
|
+ //The user has moved on while this was being asked
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data != null && data.error !== undefined){
|
|
|
|
|
+ //"subfolder/name.ext" still saves into the subfolder
|
|
|
|
|
+ var fullPath = /^[^\/\\:]+:/.test(typed);
|
|
|
|
|
+ var folderOnly = /[\/\\]$/.test(typed);
|
|
|
|
|
+ if (type == "new" && !fullPath && !folderOnly){
|
|
|
|
|
+ confirmListedSelection();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ showPathError(target);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == "folder"){
|
|
|
|
|
+ deliverSelection([folderResult(target)]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $("#filename").removeClass("invalid").val(type == "new" ? lastPlainFilename : "");
|
|
|
|
|
+ var here = fromDir.replace(/\/?$/, "/");
|
|
|
|
|
+ listDir(target, target != here, data);
|
|
|
|
|
+ },
|
|
|
|
|
+ error: function(){
|
|
|
|
|
+ typedPathPending = false;
|
|
|
|
|
+ showPathError(target);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function showPathError(path){
|
|
|
|
|
+ $("#pathError").text(applocale.getString("message/cannotopenfolder", "Folder not found or cannot be opened") +
|
|
|
|
|
+ ": " + path.replace(/([^:])\/$/, "$1")).addClass("show");
|
|
|
|
|
+ $("#filename").addClass("invalid").focus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function clearPathError(){
|
|
|
|
|
+ $("#pathError").removeClass("show");
|
|
|
|
|
+ $("#filename").removeClass("invalid");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $("#filename").on("focus", function(){
|
|
|
|
|
+ var value = $(this).val();
|
|
|
|
|
+ if (value.trim() != "" && !looksLikePath(value.trim())){
|
|
|
|
|
+ lastPlainFilename = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ //What is typed takes over from whatever was highlighted
|
|
|
|
|
+ $("#filename").on("input", function(){
|
|
|
|
|
+ clearPathError();
|
|
|
|
|
+ var selected = $("#fileArea").find(".fileObject.selected");
|
|
|
|
|
+ if (selected.length > 0){
|
|
|
|
|
+ selected.removeClass("selected");
|
|
|
|
|
+ setWindowTitleForSelection(0);
|
|
|
|
|
+ clearDetails();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------ */
|
|
|
/* Replace prompt (new file mode) */
|
|
/* Replace prompt (new file mode) */
|
|
|
/* ------------------------------------------------------------------ */
|
|
/* ------------------------------------------------------------------ */
|