-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search.lua
48 lines (41 loc) · 1.29 KB
/
Search.lua
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
---@class WBL
local WBL = LibStub("AceAddon-3.0"):GetAddon("Warband-Bank-Log")
local function SearchLogEntry(self, logEntry, results)
local searchString = string.lower(self:GetText())
if string.find(string.lower(logEntry.link), searchString) then
table.insert(results, logEntry)
return
end
if string.find(string.lower(logEntry.name), searchString) then
table.insert(results, logEntry)
return
end
if string.find(string.lower(logEntry.changeType), searchString) then
table.insert(results, logEntry)
return
end
end
function WBL:Search_EnterPressed(self)
self:ClearFocus()
local results = {}
for index, logEntry in ipairs(WBL.Logs) do
SearchLogEntry(self, logEntry, results)
end
WBL.DataProvider:Flush()
if #results > 0 then
WBL.DataProvider:InsertTable(results)
WBL.Display.BaseFrame.Container.ScrollBox:SetScrollPercentage(100)
end
end
function WBL:ClearSearch()
if not WBL.DataProvider then
return
end
WBL.DataProvider:Flush()
if #WBL.Logs > 0 then
WBL.DataProvider:InsertTable(WBL.Logs)
end
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
WBL.Display.BaseFrame.SearchBox:SetText("")
WBL.Display.BaseFrame.SearchBox:ClearFocus()
end