I am fairly new to Opnenwrt. I am trying to modify luci to display a file with auto refresh capability.
So, i am generating a file at tmp/xxxx and it's updating every 4 seconds. I have managed to display it on Luci but i want auto-refresh functionality.
I am currently using this code in usr/lib/lua/luci/controller/admin/chng.lua to generate 2 new tabs, xxxx will be used for displaying the file.
module("luci.controller.admin.chng", package.seeall)
function index()
entry({"admin", "chng"}, firstchild(), "Chng", 60).depedent=false
entry({"admin", "chng", "tab_one"}, template("yyy"),_("yyy"), 1)
entry({"admin", "chng", "tab_two"}, form("xxxx"),_("xxxx"), 2)
end
And to display I am using following code at usr/lib/lua/luci/model/cbi/xxxx.lua to display the file in simple text format(or as it is in the file).
<%#local fs = require "nixio.fs"
local sys = require "luci.sys"
f = SimpleForm("rc", translate("Look This Is It!!"))
t = f:field(TextValue, "rcs")
t.rmempty = true
t.rows = 20
function t.cfgvalue()
return fs.readfile("/tmp/kamnu")
end
return f
-%>
which is similar to the startup tab of the luci(that displays rc.local file), can someone help me to make this auto refreshing i found that "XHR.poll" can be used but i cant figure it out as I don't have experience with html and javascript, please help me.