27 lines
647 B
Lua
27 lines
647 B
Lua
-- name = "Chuck Norris jokes (experimental)"
|
|
-- description = "icndb.com"
|
|
-- data_source = "icndb.com"
|
|
-- type = "widget"
|
|
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
|
-- version = "1.0"
|
|
|
|
function on_alarm()
|
|
local response = shttp:get("http://api.icndb.com/jokes/random")
|
|
|
|
if response.error ~= nil then
|
|
ui:show_text(response.error)
|
|
return
|
|
end
|
|
|
|
if response.code >= 200 and response.code < 300 then
|
|
joke = ajson:get_value(response.body, "object object:value string:joke")
|
|
ui:show_text(joke)
|
|
end
|
|
end
|
|
|
|
function on_click()
|
|
if joke ~= nil then
|
|
system:copy_to_clipboard(joke)
|
|
end
|
|
end
|