1. Small fixes to main widget. 2. Covid widget removed as defunct.
This commit is contained in:
33
defunct/covid-widget.lua
Normal file
33
defunct/covid-widget.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
-- name = "Covid info"
|
||||||
|
-- description = "Cases of illness and death from covid"
|
||||||
|
-- data_source = "covid19api.com"
|
||||||
|
-- type = "widget"
|
||||||
|
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||||
|
-- version = "1.0"
|
||||||
|
|
||||||
|
equals = "<font color=\""..ui:colors().secondary_text.."\"> = </font>"
|
||||||
|
|
||||||
|
function on_alarm()
|
||||||
|
http:get("https://api.covid19api.com/summary")
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_network_result(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
|
local new = ajson:get_value(result, "object object:Global int:NewConfirmed")
|
||||||
|
local total = ajson:get_value(result, "object object:Global int:TotalConfirmed")
|
||||||
|
local newDeaths = ajson:get_value(result, "object object:Global int:NewDeaths")
|
||||||
|
local totalDeaths = ajson:get_value(result, "object object:Global int:TotalDeaths")
|
||||||
|
|
||||||
|
ui:show_lines({
|
||||||
|
"<b>Disease</b> | total"..equals..comma_value(total).." | new"..equals..comma_value(new),
|
||||||
|
"<b>Deaths</b> | total"..equals..comma_value(totalDeaths).." | new"..equals..comma_value(newDeaths)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- credit http://richard.warburton.it
|
||||||
|
function comma_value(n)
|
||||||
|
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
|
||||||
|
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
|
||||||
|
end
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
-- name = "Covid info"
|
|
||||||
-- description = "Cases of illness and death from covid"
|
|
||||||
-- data_source = "covid19api.com"
|
|
||||||
-- type = "widget"
|
|
||||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
|
||||||
-- version = "1.0"
|
|
||||||
|
|
||||||
equals = "<font color=\""..ui:colors().secondary_text.."\"> = </font>"
|
|
||||||
|
|
||||||
function on_alarm()
|
|
||||||
http:get("https://api.covid19api.com/summary")
|
|
||||||
end
|
|
||||||
|
|
||||||
function on_network_result(result)
|
|
||||||
local new = ajson:get_value(result, "object object:Global int:NewConfirmed")
|
|
||||||
local total = ajson:get_value(result, "object object:Global int:TotalConfirmed")
|
|
||||||
local newDeaths = ajson:get_value(result, "object object:Global int:NewDeaths")
|
|
||||||
local totalDeaths = ajson:get_value(result, "object object:Global int:TotalDeaths")
|
|
||||||
|
|
||||||
ui:show_lines({
|
|
||||||
"<b>Disease</b> | total"..equals..comma_value(total).." | new"..equals..comma_value(new),
|
|
||||||
"<b>Deaths</b> | total"..equals..comma_value(totalDeaths).." | new"..equals..comma_value(newDeaths)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
function comma_value(n) -- credit http://richard.warburton.it
|
|
||||||
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
|
|
||||||
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -10,11 +10,12 @@ function on_alarm()
|
|||||||
http:get("https://uselessfacts.jsph.pl/random.json?language=en")
|
http:get("https://uselessfacts.jsph.pl/random.json?language=en")
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
text = ajson:get_value(result, "object string:text")
|
text = ajson:get_value(result, "object string:text")
|
||||||
|
|
||||||
ui:show_lines{ text }
|
ui:show_lines{ text }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function on_click()
|
function on_click()
|
||||||
if text ~= nil then
|
if text ~= nil then
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ end
|
|||||||
function on_network_result(result, code)
|
function on_network_result(result, code)
|
||||||
if code >= 200 and code < 299 then
|
if code >= 200 and code < 299 then
|
||||||
res = json.decode(result)
|
res = json.decode(result)
|
||||||
|
|
||||||
ui:show_lines({ res[1].q }, { res[1].a })
|
ui:show_lines({ res[1].q }, { res[1].a })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ function on_alarm()
|
|||||||
http:get("https://api.ipify.org")
|
http:get("https://api.ipify.org")
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
ui:show_text(result)
|
ui:show_text(result)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ function on_alarm()
|
|||||||
http:get("https://api.quotable.io/random")
|
http:get("https://api.quotable.io/random")
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
quote = ajson:get_value(result, "object string:content")
|
quote = ajson:get_value(result, "object string:content")
|
||||||
author = ajson:get_value(result, "object string:author")
|
author = ajson:get_value(result, "object string:author")
|
||||||
|
|
||||||
ui:show_lines({ quote }, { author })
|
ui:show_lines({ quote }, { author })
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function on_click()
|
function on_click()
|
||||||
if quote ~= nil then
|
if quote ~= nil then
|
||||||
|
|||||||
@@ -18,19 +18,21 @@ function on_alarm()
|
|||||||
http:get(random_url)
|
http:get(random_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
local parsed = json.decode(result)
|
local parsed = json.decode(result)
|
||||||
title = parsed.query.random[1].title
|
title = parsed.query.random[1].title
|
||||||
|
|
||||||
http:get(summary_url.."&titles="..url.quote(title), "summary")
|
http:get(summary_url.."&titles="..url.quote(title), "summary")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function on_network_result_summary(result)
|
function on_network_result_summary(result, code)
|
||||||
|
if code >= 200 and code < 299 then
|
||||||
local parsed = json.decode(result)
|
local parsed = json.decode(result)
|
||||||
local extract = get_extract(parsed)
|
local extract = get_extract(parsed)
|
||||||
|
|
||||||
ui:show_lines({ smart_sub(extract, 200) }, { title })
|
ui:show_lines({ smart_sub(extract, 200) }, { title })
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function on_click()
|
function on_click()
|
||||||
system:open_browser(article_url..url.quote(title))
|
system:open_browser(article_url..url.quote(title))
|
||||||
|
|||||||
Reference in New Issue
Block a user