Add Tasker command search and edit sunrise widget #16

Closed
sriramsv wants to merge 3 commits from master into master
Showing only changes of commit ab059d2302 - Show all commits

View File

@@ -9,11 +9,14 @@
local json = require "json"
local date = require "date"
global_loc = {}
l1 = {}
l2 = {}
function on_resume()
if global_loc ~=nil then
l2=settings:get_kv()
if next(l2) == nil then
ui:show_text("Tap to request location")
else
get_sunrise_sunset(l2)
end
end
@@ -24,15 +27,24 @@ end
function on_location_result(location)
if location ~= nil then
ui:show_text(location[1].." "..location[2])
global_loc = location
url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1"
http:get(url)
l1.lat = location[1]
l1.long = location[2]
settings:set_kv(l1)
get_sunrise_sunset(l1)
else
ui:show_text("Error")
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)
local t = json.decode(result)
local table = {