X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-olsr%2Fluasrc%2Fcontroller%2Folsr.lua;h=a47496b31a9a5c15fd7ec3decad8801fb5489699;hp=6d6dc1ace2c9a7c4ffaa4b0647adaa9335fb358e;hb=b1ef4c398bc2d35b333331ac5f823bc17bf56ff2;hpb=b0dbb7bd3d6fcc54115191868c06769b92acda09 diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua index 6d6dc1ace2..a47496b31a 100644 --- a/applications/luci-olsr/luasrc/controller/olsr.lua +++ b/applications/luci-olsr/luasrc/controller/olsr.lua @@ -91,30 +91,29 @@ function index() ) 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 - 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 - table.sort(data.Links, compare) + table.sort(data.Links, compare_links) luci.template.render("status-olsr/neighbors", {links=data.Links}) end