Fix some alginment issues

This commit is contained in:
2020-10-20 10:48:52 +02:00
parent 65299d825c
commit a6b50d2a8e
7 changed files with 34 additions and 15 deletions

View File

@@ -90,6 +90,7 @@ DirectoryElement.prototype.renderFiles = function() {
// search term will be put into visibleFiles. The visibleFiles array will then
// be rendered by renderVisibleFiles
DirectoryElement.prototype.search = function(term) {
term = term.toLowerCase()
this.lastSearchTerm = term
this.visibleFiles = []
@@ -102,8 +103,18 @@ DirectoryElement.prototype.search = function(term) {
return
}
let fileName = ""
for (let i in this.allFiles) {
if (this.allFiles[i].name.toLowerCase().includes(term.toLowerCase())) {
fileName = this.allFiles[i].name.toLowerCase()
// If there's an exact match we'll show it as the only result
if (fileName === term) {
this.visibleFiles = [i]
break
}
// If a file name contains the search term we include it in the results
if (fileName.includes(term)) {
this.visibleFiles.push(i)
}
}
@@ -112,6 +123,15 @@ DirectoryElement.prototype.search = function(term) {
this.renderVisibleFiles(true)
}
// searchSubmit opens the first file in the search results
DirectoryElement.prototype.searchSubmit = function() {
if (this.visibleFiles.length === 0) {
return // There are no files visible
}
window.location = this.getVisibleFile(0).href
}
DirectoryElement.prototype.sortBy = function(field) {
if (field === "") {
// If no sort field is provided we use the last used sort field
@@ -169,7 +189,7 @@ DirectoryElement.prototype.createFileButton = function(file, index) {
let el = document.createElement("a")
el.classList = "node"
el.href = file.href
el.target = "_blank"
// el.target = "_blank"
el.title = file.name
el.setAttribute("fileindex", index)