This commit is contained in:
Evgeny
2021-08-04 21:33:51 +03:00
parent 259ef63496
commit 5f893021ff
7 changed files with 87 additions and 18 deletions

38
holydays-ru-widget.lua Normal file
View File

@@ -0,0 +1,38 @@
-- name = "Праздники"
-- description = "Виджет отображает предстоящие праздники."
-- data_source = "https://date.nager.at/"
-- type = "widget"
-- author = "Andrey Gavrilov"
-- version = "1.0"
--API--
local api_url = "https://date.nager.at/api/v3/NextPublicHolidays/RU"
--Настройка автосворачивания виджета--
local auto_folding = false
local lines = {}
local json = require "json"
local sx = require "pl.stringx"
function on_resume()
if auto_folding then
ui:set_folding_flag(true)
ui:show_lines(lines)
end
end
function on_alarm()
http:get(api_url)
end
function on_network_result(result)
local t = json.decode(result)
for i = 1, #t, 1 do
local date = sx.replace(t[i].date, "-", ".")
local name = t[i].localName
lines[i] = date.." - "..name
end
ui:show_lines(lines)
end