reorganization

This commit is contained in:
Evgeny
2021-08-06 14:43:34 +03:00
parent 372ec8578d
commit 1e9b33eaea
52 changed files with 1044 additions and 20 deletions

38
ru/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

21
ru/isdayoff-ru-widget.lua Normal file
View File

@@ -0,0 +1,21 @@
-- name = "Сегодня выходной?"
-- description = "Показывает, выходной ли сегодня день."
-- data_source = "isdayoff.ru"
-- type = "widget"
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
-- version = "1.0"
function on_alarm()
local dateStr = os.date('%Y%m%d')
http:get("https://isdayoff.ru/"..dateStr)
end
function on_network_result(result)
if result == "0" then
ui:show_text("Сегодня рабочий день")
elseif result == "1" then
ui:show_text("Сегодня выходной")
else
ui:show_text("Ошибка")
end
end

17
ru/quotes-ru-widget.lua Normal file
View File

@@ -0,0 +1,17 @@
-- name = "Цитаты великих"
-- description = "Рандомные цитаты на русском языке."
-- data_source = "forismatic.com"
-- type = "widget"
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
-- version = "1.0"
function on_alarm()
http:get("http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=ru")
end
function on_network_result(result)
local quote = ajson:get_value(result, "object string:quoteText")
local author = ajson:get_value(result, "object string:quoteAuthor")
ui:show_lines({ quote }, { author })
end

55
ru/widgets-on-off.lua Normal file
View File

@@ -0,0 +1,55 @@
-- name = "Включение виджетов"
-- description = "Включает и отключает виджеты на экране при нажатии на кнопки"
-- type = "widget"
-- author = "Andrey Gavrilov"
-- version = "1.0"
-- arguments_help = "Введите список виджетов и кнопок в формате bitcoin:Биткойн timer:Таймер"
-- arguments_default = "bitcoin:Битк. timer:Тайм. stopwatch:Секунд. recorder:Дикт. calculator:Кальк."
sx = require 'pl.stringx'
function on_resume()
local args = get_args_kv()
widgets = args[1]
buttons = args[2]
colors = {}
for idx,widget in ipairs(widgets) do
if aio:is_widget_added(widget) then
colors[idx] = md_colors.red_500
else
colors[idx] = md_colors.green_500
end
end
ui:show_buttons(buttons, colors)
end
function on_click(idx)
local widget = widgets[idx]
if aio:is_widget_added(widget) then
aio:remove_widget(widget)
colors[idx] = md_colors.green_500
else
aio:add_widget(widget)
colors[idx] = md_colors.red_500
end
ui:show_buttons(buttons, colors)
end
function get_args_kv()
local keys = {}
local values = {}
local args = aio:get_args()
for idx = 1, #args, 1 do
local arg = sx.split(args[idx], ":")
keys[idx] = arg[1]
values[idx] = arg[2]
end
return { keys, values }
end