Add step-by-step tutorial
This commit is contained in:
25
samples/search-engine-selector.lua
Normal file
25
samples/search-engine-selector.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- name = "Search Engine Selector"
|
||||
-- type = "search"
|
||||
|
||||
local lastQuery = ""
|
||||
|
||||
function on_search(query)
|
||||
lastQuery = query
|
||||
local results = {}
|
||||
if #query > 0 then
|
||||
table.insert(results, "Search Google for: " .. query)
|
||||
table.insert(results, "Search Bing for: " .. query)
|
||||
end
|
||||
search:show_lines(results)
|
||||
end
|
||||
|
||||
function on_click(index)
|
||||
if index == 1 then
|
||||
system:open_browser("https://www.google.com/search?q=" .. lastQuery)
|
||||
return true
|
||||
elseif index == 2 then
|
||||
system:open_browser("https://www.bing.com/search?q=" .. lastQuery)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
Reference in New Issue
Block a user