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,10 +10,11 @@ function on_alarm()
|
||||
http:get("https://uselessfacts.jsph.pl/random.json?language=en")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
text = ajson:get_value(result, "object string:text")
|
||||
|
||||
ui:show_lines{ text }
|
||||
function on_network_result(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
text = ajson:get_value(result, "object string:text")
|
||||
ui:show_lines{ text }
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
|
||||
@@ -15,7 +15,6 @@ end
|
||||
function on_network_result(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
res = json.decode(result)
|
||||
|
||||
ui:show_lines({ res[1].q }, { res[1].a })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,8 @@ function on_alarm()
|
||||
http:get("https://api.ipify.org")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
ui:show_text(result)
|
||||
function on_network_result(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
ui:show_text(result)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,11 +10,13 @@ function on_alarm()
|
||||
http:get("https://api.quotable.io/random")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
quote = ajson:get_value(result, "object string:content")
|
||||
author = ajson:get_value(result, "object string:author")
|
||||
function on_network_result(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
quote = ajson:get_value(result, "object string:content")
|
||||
author = ajson:get_value(result, "object string:author")
|
||||
|
||||
ui:show_lines({ quote }, { author })
|
||||
ui:show_lines({ quote }, { author })
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
|
||||
@@ -13,11 +13,11 @@ local primary_color = aio:colors().primary_color
|
||||
local secondary_color = aio:colors().secondary_color
|
||||
|
||||
local bottom_buttons = {
|
||||
"fa:note_sticky", -- notes tab
|
||||
"fa:list-check", -- tasks tab
|
||||
"fa:pipe", -- separator
|
||||
"fa:note_sticky", -- notes tab
|
||||
"fa:list-check", -- tasks tab
|
||||
"fa:pipe", -- separator
|
||||
"fa:note_medical", -- new note button
|
||||
"fa:square_plus" -- new task button
|
||||
"fa:square_plus" -- new task button
|
||||
}
|
||||
|
||||
local notes_list = {}
|
||||
|
||||
@@ -18,18 +18,20 @@ function on_alarm()
|
||||
http:get(random_url)
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local parsed = json.decode(result)
|
||||
title = parsed.query.random[1].title
|
||||
|
||||
http:get(summary_url.."&titles="..url.quote(title), "summary")
|
||||
function on_network_result(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
local parsed = json.decode(result)
|
||||
title = parsed.query.random[1].title
|
||||
http:get(summary_url.."&titles="..url.quote(title), "summary")
|
||||
end
|
||||
end
|
||||
|
||||
function on_network_result_summary(result)
|
||||
local parsed = json.decode(result)
|
||||
local extract = get_extract(parsed)
|
||||
|
||||
ui:show_lines({ smart_sub(extract, 200) }, { title })
|
||||
function on_network_result_summary(result, code)
|
||||
if code >= 200 and code < 299 then
|
||||
local parsed = json.decode(result)
|
||||
local extract = get_extract(parsed)
|
||||
ui:show_lines({ smart_sub(extract, 200) }, { title })
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
|
||||
Reference in New Issue
Block a user