Update inspiration quotes widget
This commit is contained in:
@@ -1,24 +1,28 @@
|
|||||||
-- name = "Inspiration quotes"
|
-- name = "Inspiration quotes"
|
||||||
-- description = "inspiration.goprogram.ai"
|
-- description = "ZenQuotes.io"
|
||||||
-- data_source = "inspiration.goprogram.ai"
|
-- data_source = "https://zenquotes.io/"
|
||||||
-- type = "widget"
|
-- type = "widget"
|
||||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||||
-- version = "1.0"
|
-- version = "2.0"
|
||||||
-- foldable = "false"
|
-- foldable = "false"
|
||||||
|
|
||||||
|
local json = require "json"
|
||||||
|
|
||||||
function on_alarm()
|
function on_alarm()
|
||||||
http:get("https://inspiration.goprogram.ai/")
|
http:get("https://zenquotes.io/api/random")
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result, code)
|
||||||
quote = ajson:get_value(result, "object string:quote")
|
if code >= 200 and code < 299 then
|
||||||
author = ajson:get_value(result, "object string:author")
|
res = json.decode(result)
|
||||||
|
|
||||||
ui:show_lines({ quote }, { author })
|
ui:show_lines({ res[1].q }, { res[1].a })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_click()
|
function on_click()
|
||||||
if quote ~= nil then
|
if res ~= nil then
|
||||||
system:copy_to_clipboard(quote)
|
system:to_clipboard(res[1].q.." - "..res[1].a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user