|
@@ -621,6 +621,20 @@
|
|
|
i.blue{
|
|
|
color: #345eeb;
|
|
|
}
|
|
|
+
|
|
|
+ .fileObject.whiteTheme.hotSearchHighlight{
|
|
|
+ background-color: #d2f2f7 !important;
|
|
|
+ }
|
|
|
+ .fileObject.darkTheme.hotSearchHighlight span{
|
|
|
+ background-color: #d2f2f7 !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fileObject.darkTheme.hotSearchHighlight{
|
|
|
+ background-color: #100f16 !important;
|
|
|
+ }
|
|
|
+ .fileObject.darkTheme.hotSearchHighlight span{
|
|
|
+ background-color: #100f16 !important;
|
|
|
+ }
|
|
|
</style>
|
|
|
</head>
|
|
|
<body class="whiteTheme">
|
|
@@ -1138,8 +1152,13 @@
|
|
|
let useLocalstorage = lscheck();
|
|
|
let overwriteMode = "keep"; //Overwrite mode, support {skip, overwrite, keep}
|
|
|
let thumbRenderWebSocket = null;
|
|
|
+
|
|
|
+ //Searching related
|
|
|
let searchCaseSensitive = false;
|
|
|
let searchMode = false;
|
|
|
+ let hotSearchBuffer = "";
|
|
|
+ let hotSearchTimer = null;
|
|
|
+ let hotSearchOffsetIndex = 0;
|
|
|
|
|
|
//Keypress listeners
|
|
|
let ctrlHold = false;
|
|
@@ -2191,14 +2210,20 @@
|
|
|
$(".fileObject").each(function(){
|
|
|
if ($(this).attr("filename") == targetFileName){
|
|
|
$(this).addClass("selected");
|
|
|
- //Trying to vertically align the directory from its parent list
|
|
|
- $("#folderView").stop().finish().animate({
|
|
|
- scrollTop: $(this).offset().top - $("#folderView").offset().top - (window.innerHeight - $("#navibar").height())/2 + $(this).height()
|
|
|
- }, 300);
|
|
|
+ scrollToFileLocation(this);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ function scrollToFileLocation(DOMElement){
|
|
|
+ //Trying to vertically align the directory from its parent list
|
|
|
+ let topPos = $("#folderView").scrollTop() + $(DOMElement).offset().top - $("#folderView").height()/2 - $(DOMElement).height()/2 - 28;
|
|
|
+ window.debug = $(DOMElement);
|
|
|
+ $("#folderView").stop().animate({
|
|
|
+ scrollTop: topPos
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+
|
|
|
function loadListModeFromDB(callback = undefined){
|
|
|
//Get list mode from storage
|
|
|
loadPreference("file_explorer/listmode",function(data){
|
|
@@ -3895,7 +3920,28 @@
|
|
|
hideAllPopupWindows();
|
|
|
$(".fileObject.selected").removeClass("selected");
|
|
|
}else{
|
|
|
- //console.log(event.which);
|
|
|
+ //Handle generic file search by consecutive typing
|
|
|
+ if (hotSearchTimer != null){
|
|
|
+ clearTimeout(hotSearchTimer);
|
|
|
+ }
|
|
|
+ $(".fileObject.selected").removeClass("selected");
|
|
|
+ hotSearchTimer = setTimeout(function(){
|
|
|
+ hotSearchBuffer = "";
|
|
|
+ hotSearchTimer = null;
|
|
|
+ //Move the file to "selected" mode
|
|
|
+ $(".hotSearchHighlight").addClass("selected");
|
|
|
+ $(".hotSearchHighlight").removeClass("hotSearchHighlight");
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ if (hotSearchBuffer.length > 0 && event.key == hotSearchBuffer.substr(hotSearchBuffer.length - 1, 1)){
|
|
|
+ //Jump to next result
|
|
|
+ hotSearchOffsetIndex++;
|
|
|
+ }else{
|
|
|
+ hotSearchOffsetIndex = 0;
|
|
|
+ hotSearchBuffer+= event.key;
|
|
|
+ }
|
|
|
+
|
|
|
+ handleHotSearch(hotSearchBuffer, hotSearchOffsetIndex);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -4775,6 +4821,35 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function handleHotSearch(starting, offset){
|
|
|
+ if (offset < 0){
|
|
|
+ offset = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ starting = starting.toLowerCase();
|
|
|
+ $(".hotSearchHighlight").removeClass("hotSearchHighlight");
|
|
|
+ let files = $(".fileObject");
|
|
|
+ let matchingFiles = [];
|
|
|
+ for (var i = 0; i < files.length; i++){
|
|
|
+ let thisFile = files[i];
|
|
|
+ if ($(thisFile).attr("filename") != undefined && $(thisFile).attr("filename").length > starting.length && $(thisFile).attr("filename").substr(0, starting.length).toLowerCase() == starting){
|
|
|
+ matchingFiles.push(thisFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Loopback if offset overflow
|
|
|
+ let newOffset = offset;
|
|
|
+ if (offset > matchingFiles.length - 1){
|
|
|
+ newOffset =offset % matchingFiles.length;
|
|
|
+ }
|
|
|
+
|
|
|
+ var targetHighlightingFile = matchingFiles[newOffset];
|
|
|
+ $(targetHighlightingFile).addClass("hotSearchHighlight");
|
|
|
+ scrollToFileLocation($(targetHighlightingFile));
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function handleSearch(){
|
|
|
var keyword = $("#searchInput").val();
|
|
|
$("#folderList").html(`<div class="ts basic segment ${currentTheme}">
|