Files
aiolauncher_scripts/main/random-joke-widget.lua
2021-09-10 13:54:19 +03:00

24 lines
619 B
Lua

-- name = "Random jokes"
-- description = "official-joke-api.appspot.com"
-- data_source = "official-joke-api.appspot.com"
-- type = "widget"
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
-- version = "1.0"
function on_alarm()
http:get("https://official-joke-api.appspot.com/random_joke")
end
function on_network_result(result)
setup = ajson:get_value(result, "object string:setup")
punchline = ajson:get_value(result, "object string:punchline")
ui:show_lines({setup, punchline})
end
function on_click()
if setup ~= nil then
system:copy_to_clipboard(setup.."\n"..punchline)
end
end