'*************************************************************
'** GenerateSearchSuggestions()
'*************************************************************
Function GenerateSearchSuggestions(partSearchText As String) As Object
suggestions = CreateObject("roArray", 1, true)
length = len(partSearchText)
if length > 6
suggestions.Push("ghost in the shell")
suggestions.Push("parasite dolls")
suggestions.Push("final fantasy")
suggestions.Push("ninja scroll")
suggestions.Push("space ghost")
suggestions.Push("hellboy")
else if length > 5
suggestions.Push("parasite dolls")
suggestions.Push("final fantasy")
suggestions.Push("ninja scroll")
suggestions.Push("space ghost")
suggestions.Push("hellboy")
else if length > 4
suggestions.Push("final fantasy")
suggestions.Push("ninja scroll")
suggestions.Push("space ghost")
suggestions.Push("hellboy")
else if length > 3
suggestions.Push("ninja scroll")
suggestions.Push("space ghost")
suggestions.Push("hellboy")
else if length > 2
suggestions.Push("space ghost")
suggestions.Push("hellboy")
else if length > 1
suggestions.Push("hellboy")
else if length > 0
suggestions.Push("transformers")
endif
return suggestions
End Function
'*************************************************************
'** showSearchScreen()
'*************************************************************
Function showSearchScreen() As Dynamic
screen = CreateObject("roSearchScreen")
history = CreateObject("roSearchHistory")
inHistoryMode = true
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetBreadcrumbText("Search", "With History")
screen.SetSearchTermHeaderText("Recent Searches")
screen.SetSearchButtonText("Search")
screen.SetClearButtonText("Clear history")
screen.SetClearButtonEnabled(true) 'enable for search history
screen.SetSearchTerms(history.GetAsArray())
screen.SetEmptySearchTermsText("No searches available")
screen.Show()
while true
waitformsg:
msg = wait(0, screen.GetMessagePort())
print "message received"
if type(msg) <> "roSearchScreenEvent" then
print "Unexpected message class: "; type(msg)
goto waitformsg
endif
if msg.isScreenClosed() return invalid
if msg.isPartialResult()
partialResult = msg.GetMessage()
print "partial result "; partialResult
if not isnullorempty(partialResult)
searchSuggestions = GenerateSearchSuggestions(partialResult)
printList(searchSuggestions)
if searchSuggestions <> invalid
'do SetSearchTerms() before SetEmptySearchTermsText() so that the new empty
'search terms text doesn't flash on screen
screen.SetSearchTerms(searchSuggestions)
if inHistoryMode
'do only on 1st mode switch
screen.SetSearchTermHeaderText("Search Suggestions")
screen.SetEmptySearchTermsText("No suggestions available")
screen.SetClearButtonEnabled(false) 'user cannot clear search suggestions
inHistoryMode = false
endif
endif
endif
else if msg.isFullResult()
fullSearchResult = msg.GetMessage()
print "full result: "; fullSearchResult
if not isnullorempty(fullSearchResult)
history.Push(fullSearchResult)
endif
return fullSearchResult
else if msg.isCleared()
print "history cleared"
history.Clear()
endif
end while
End Function
Function showHomeScreen(screen) As Integer
if validateParam(screen, "roPosterScreen", "showHomeScreen") = false return -1
initCategoryList()
screen.SetContentList(m.Categories.Kids)
screen.SetFocusedListItem(3)
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roPosterScreenEvent" then
print "showHomeScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isListFocused() then
print "list focused | index = "; msg.GetIndex(); " | category = "; m.curCategory
else if msg.isListItemSelected() then
if m.categories.kids[msg.getindex()].title="Search" then
ShowMySearchScreen()
else
print "list item selected | index = "; msg.GetIndex()
kid = m.Categories.Kids[msg.GetIndex()]
if kid.type = "special_category" then
displaySpecialCategoryScreen()
else
displayCategoryPosterScreen(kid)
end if
end if
else if msg.isScreenClosed() then
return -1
end if
end If
end while
return 0
End Function