summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/modelfunctions.lua24
-rw-r--r--lib/viewfunctions.lua4
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua
index 0648f23..1cd19a9 100644
--- a/lib/modelfunctions.lua
+++ b/lib/modelfunctions.lua
@@ -59,3 +59,27 @@ function getfiledetails(file)
end
return cfe({ type="group", value={filename=filename, filecontent=filecontent, filesize=filesize, mtime=mtime}, label="Config file details" })
end
+
+function validateselect(select)
+ for i,option in ipairs(select.option) do
+ if option == select.value then
+ return true
+ end
+ end
+ select.errtxt = "Invalid selection"
+ return false
+end
+
+function validatemulti(multi)
+ local reverseoption = {}
+ for i,option in ipairs(multi.option) do
+ reverseoption[option] = i
+ end
+ for i,value in ipairs(multi.value) do
+ if not reverseoption[value] then
+ multi.errtxt = "Invalid selection"
+ return false
+ end
+ end
+ return true
+end
diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua
index 45701d6..dd2fcda 100644
--- a/lib/viewfunctions.lua
+++ b/lib/viewfunctions.lua
@@ -183,7 +183,9 @@ function displaycommandresults(commands, session)
if #cmdresult > 0 then
io.write("<H1>Command Result</H1>\n<DL>\n")
for i,result in ipairs(cmdresult) do
- io.write(result.value:gsub("\n", "<BR>") .. "\n")
+ if result.value ~= "" then io.write(result.value:gsub("\n", "<BR>") .. "\n") end
+ if result.descr then io.write('<P CLASS="descr">' .. string.gsub(result.descr, "\n", "<BR>") .. "</P>\n") end
+ if result.errtxt then io.write('<P CLASS="error">' .. string.gsub(result.errtxt, "\n", "<BR>") .. "</P>\n") end
end
io.write("</DL>\n")
end