Add Tasker command search and edit sunrise widget #16
@@ -9,11 +9,14 @@
|
|||||||
local json = require "json"
|
local json = require "json"
|
||||||
local date = require "date"
|
local date = require "date"
|
||||||
|
|
||||||
global_loc = {}
|
l1 = {}
|
||||||
|
l2 = {}
|
||||||
function on_resume()
|
function on_resume()
|
||||||
if global_loc ~=nil then
|
l2=settings:get_kv()
|
||||||
|
if next(l2) == nil then
|
||||||
ui:show_text("Tap to request location")
|
ui:show_text("Tap to request location")
|
||||||
|
else
|
||||||
|
get_sunrise_sunset(l2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -24,15 +27,24 @@ end
|
|||||||
|
|
||||||
function on_location_result(location)
|
function on_location_result(location)
|
||||||
if location ~= nil then
|
if location ~= nil then
|
||||||
ui:show_text(location[1].." "..location[2])
|
l1.lat = location[1]
|
||||||
global_loc = location
|
l1.long = location[2]
|
||||||
url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1"
|
settings:set_kv(l1)
|
||||||
http:get(url)
|
get_sunrise_sunset(l1)
|
||||||
else
|
else
|
||||||
ui:show_text("Error")
|
ui:show_text("Error")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function get_sunrise_sunset(location)
|
||||||
|
if location~=nil then
|
||||||
|
url="https://api.sunrise-sunset.org/json?lat="..location.lat.."&lng="..location.long.."&date=today&formatted=1"
|
||||||
|
http:get(url)
|
||||||
|
else
|
||||||
|
ui:show_text("Location Empty")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function on_network_result(result)
|
function on_network_result(result)
|
||||||
local t = json.decode(result)
|
local t = json.decode(result)
|
||||||
local table = {
|
local table = {
|
||||||
|
|||||||
Reference in New Issue
Block a user