Update inspiration quotes widget

This commit is contained in:
Evgeny
2023-06-30 13:09:07 +04:00
parent ae15d0e730
commit 55aad881e2

View File

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