swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function nameForPath(path) {
return String(path || "").split("/").pop().replace(/\.[^/.]+$/, "")
}
function labelForPath(path) {
return nameForPath(path).replace(/[-_]+/g, " ").replace(/\b\w/g, function(match) { return match.toUpperCase() })
}
function loadRows(rows) {
var images = []
var seen = {}
var paths = String(rows || "").split("\n")
for (var i = 0; i < paths.length; i++) {
var row = paths[i]
if (!row) continue
var columns = row.split("\t")
var path = columns[0]
if (!path) continue
var fileName = path.split("/").pop()
if (seen[fileName]) continue
seen[fileName] = true
images.push({
filePath: path,
fileName: fileName,
thumbnailPath: columns[1] || path
})
}
return images
}
function itemMatches(images, index, filterText) {
if (!Array.isArray(images) || index < 0 || index >= images.length) return false
var needle = String(filterText || "").toLowerCase()
if (!needle) return true
var path = String(images[index].filePath || "")
return nameForPath(path).toLowerCase().indexOf(needle) !== -1
|| labelForPath(path).toLowerCase().indexOf(needle) !== -1
}
function firstMatchingIndex(images, filterText) {
var values = Array.isArray(images) ? images : []
for (var i = 0; i < values.length; i++) {
if (itemMatches(values, i, filterText)) return i
}
return -1
}
function filteredPosition(images, index, filterText) {
if (!filterText) return index
var position = 0
for (var i = 0; i < index; i++) {
if (itemMatches(images, i, filterText)) position++
}
return position
}
function selectedFilteredPosition(images, selectedIndex, filterText) {
if (!filterText) return selectedIndex
return itemMatches(images, selectedIndex, filterText) ? filteredPosition(images, selectedIndex, filterText) : 0
}
function indexForSelectedImage(images, selectedImage) {
var values = Array.isArray(images) ? images : []
for (var i = 0; i < values.length; i++) {
if (values[i].filePath === selectedImage) return i
}
return 0
}
function nextSelectedIndexForFilter(images, selectedIndex, filterText) {
if (itemMatches(images, selectedIndex, filterText)) return selectedIndex
return firstMatchingIndex(images, filterText)
}
if (typeof module !== "undefined") {
module.exports = {
nameForPath: nameForPath,
labelForPath: labelForPath,
loadRows: loadRows,
itemMatches: itemMatches,
firstMatchingIndex: firstMatchingIndex,
filteredPosition: filteredPosition,
selectedFilteredPosition: selectedFilteredPosition,
indexForSelectedImage: indexForSelectedImage,
nextSelectedIndexForFilter: nextSelectedIndexForFilter
}
}