* Search screen with keyboard and suggestions * Clear search on visibility change * Search page works * Local search history * Use built-in delete function * Changelog * Animation * Adjust suggestions * Web play video always goes to home
42 lines
923 B
Plaintext
42 lines
923 B
Plaintext
function SaveSearchHistory(q as string, maxItems = 10 as integer)
|
|
history = RegistryUtils.Read("search_history")
|
|
if history <> invalid
|
|
history = ParseJson(history)
|
|
else
|
|
history = []
|
|
end if
|
|
|
|
index = ArrayIndexOf(history, q)
|
|
if index <> -1
|
|
history.Delete(index)
|
|
end if
|
|
|
|
history.Unshift(q)
|
|
|
|
if history.Count() > maxItems
|
|
history.Pop()
|
|
end if
|
|
|
|
history = FormatJson(history)
|
|
|
|
RegistryUtils.Write("search_history", history)
|
|
end function
|
|
|
|
function GetSavedSearchHistory(q as string) as object
|
|
history = RegistryUtils.Read("search_history")
|
|
if history = invalid
|
|
return []
|
|
end if
|
|
history = ParseJson(history)
|
|
if q = ""
|
|
return history
|
|
end if
|
|
result = []
|
|
for each keyword in history
|
|
if keyword.InStr(q) = 0
|
|
result.push(keyword)
|
|
end if
|
|
end for
|
|
return result
|
|
end function
|