applications/luci-olsr: Update all statuspages; use json reloading on overview, neigh...
[project/luci.git] / applications / luci-olsr / luasrc / controller / olsr.lua
index 6d6dc1ace2c9a7c4ffaa4b0647adaa9335fb358e..a47496b31a9a5c15fd7ec3decad8801fb5489699 100644 (file)
@@ -91,30 +91,29 @@ function index()
        )
 end
 
        )
 end
 
-function action_neigh()
-       local data = fetch_txtinfo("links")
+local function compare_links(a, b)
+       local c = tonumber(a.Cost)
+       local d = tonumber(b.Cost)
 
 
-       if not data or not data.Links then
-               luci.template.render("status-olsr/error_olsr")
-               return nil
+       if not c or c == 0 then
+               return false
        end
 
        end
 
-       local function compare(a, b)
-               local c = tonumber(a.Cost)
-               local d = tonumber(b.Cost)
-
-               if not c or c == 0 then
-                       return false
-               end
+       if not d or d == 0 then
+               return true
+       end
+       return c < d
+end
 
 
-               if not d or d == 0 then
-                       return true
-               end
+function action_neigh(json)
+       local data = fetch_txtinfo("links")
 
 
-               return c < d
+       if not data or not data.Links then
+               luci.template.render("status-olsr/error_olsr")
+               return nil
        end
 
        end
 
-       table.sort(data.Links, compare)
+       table.sort(data.Links, compare_links)
 
        luci.template.render("status-olsr/neighbors", {links=data.Links})
 end
 
        luci.template.render("status-olsr/neighbors", {links=data.Links})
 end