diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-06-18 20:07:55 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-06-18 20:07:55 +0000 |
commit | 151f597ce365349add8c21fff63902be0084645f (patch) | |
tree | fdfa505adeaea2d4bb0e8c604a0439b211016111 /tinydns-status-html.lsp | |
parent | f0dcd211ed5fca855655d8b60b588b1d193e92fd (diff) | |
download | acf-tinydns-151f597ce365349add8c21fff63902be0084645f.tar.bz2 acf-tinydns-151f597ce365349add8c21fff63902be0084645f.tar.xz |
Rewrite of tinydns to simplify code and use new cfe model.
Added js to filter records.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1219 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'tinydns-status-html.lsp')
-rw-r--r-- | tinydns-status-html.lsp | 183 |
1 files changed, 103 insertions, 80 deletions
diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp index 28c7ee2..c006939 100644 --- a/tinydns-status-html.lsp +++ b/tinydns-status-html.lsp @@ -1,100 +1,123 @@ -<? local form = ... +<? local view, viewlibrary = ... require("viewfunctions") ?> + +<script type="text/javascript" src="/js/jquery-latest.js"></script> +<script type="text/javascript"> + last_phrase = "" + $(function(){ + $("#filter").keyup(function(){ + var phrase = this.value; + if (phrase == last_phrase) return false; + last_phrase = phrase; + var elems = $("#records").find("li"); + elems.each(function(){ + var elem = this + if (elem.innerText.indexOf(phrase)>=0) { + jQuery(elem).show(); + } else { + jQuery(elem).hide(); + }; + }) + }) + $("#filter-list").submit(function(){ + return false; + }).focus(); + }); +</script> + <? --[[ DEBUG INFORMATION io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") -io.write(html.cfe_unpack(form)) +io.write(html.cfe_unpack(view)) io.write("</span>") --]] ?> -<H1>SYSTEM INFO</H1> +<? if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("basicstatus") +end ?> + +<H1>PROGRAM SPECIFIC OPTIONS/INFORMATION</H1> +<H2>Locations</H2> <DL> <? -local myform = form.status -local tags = { "status", "version", "autostart", } -displayinfo(myform,tags,"viewonly") -?> +if (view) and (view['%']) then + local val = view['%'] ?> + <DT<? if (val.errtxt) then io.write(" class='error'") end ?>><?= val.label ?></DT> + + <DD> + <? local currentloc = "" + for i,loc in ipairs(val) do + if currentloc ~= loc[1] then ?> + <IMG SRC='/skins/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B><?= loc[1] ?></B> + <? end + currentloc = loc[1] ?> + <BR><SPAN STYLE='margin-left:30px;'><?= loc[2] ?></SPAN><BR> + <? if (loc.errtxt) then ?><P CLASS='error'><?= string.gsub(loc.errtxt, "\n", "<BR>") ?></P><? end ?> + <? end ?> + </DD> +<? end ?> </DL> <? -local myform = form.config.locations -?> -<H2>PROGRAM SPECIFIC OPTIONS/INFORMATION</H2> -<H3>Locations</H3> -<? -io.write("<DL>") -if (myform) and (myform.value) then - local val = myform - io.write("\n\t<DT") - if (val.errtxt) then - io.write(" class='error'") +local function doListIndents(next, indent) + local newentry = {} + for mt in string.gmatch(next, "([^.]+)") do + table.insert(newentry, mt) end - io.write(">" .. val.label .. "</DT>") - - io.write("\n\t\t<DD>") - for k,v in pairs(myform.value) do - io.write("<IMG SRC='/skins/static/tango/16x16/places/start-here.png' width='16' height='16' alt> <B>" .. tostring(k) .. "</B>") - for kk,vv in pairs(v) do - io.write(tostring("<BR><SPAN STYLE='margin-left:30px;'>" .. vv .. "</SPAN>\n")) - end - io.write("<BR>") + local revnewentry = {} + for j=#newentry,1,-1 do + table.insert(revnewentry, newentry[j]) end - - if (val.descr) and (#val.descr > 0) then io.write("\n\t\t<P CLASS='descr'>" .. string.gsub(val.descr, "\n", "<BR>") .. "</P>") end - if (val.errtxt) then io.write("\n\t\t<P CLASS='error'>" .. string.gsub(val.errtxt, "\n", "<BR>") .. "</P>") end - io.write("\n\t\t</DD>") -end -io.write("</DL>") -?> - -<? -local function recurseoutput(table,cnt) - if not (cnt) then cnt=0 end - cnt = cnt + 1 - for k,v in pairs(table or {}) do - if (table[k].label) then - if not (tonumber(k)) or (v.value) then --- if v.label then - io.write("\n\t\t\t<IMG SRC='/skins/static/tango/16x16/devices/computer.png' width='16' height='16' alt STYLE='margin-left:"..cnt.. - "0px'><SPAN STYLE=''> " .. tostring(v.label) .. "</SPAN><BR>") - io.write("\n\t\t\t<TABLE STYLE='margin-left:90px;'>") - for k1,v1 in pairs(v.option) do - if (v1.label) then - io.write("\n\t\t\t\t<TR>\n\t\t\t\t\t<TD WIDTH='160px' STYLE='border:none;'>".. tostring(v1.label) .. - ":</TD>\n\t\t\t\t\t<TD STYLE='border:none;'>".. tostring(v1.value) .."</TD>\n\t\t\t\t</TR>") - end - end - io.write("\n\t\t\t</TABLE>") --- end - else - io.write("\n\t\t\t<SPAN STYLE='margin-left:"..cnt.."0px;font-weight:bold;'> ".. - tostring(table[k].label) .. "</SPAN><BR>") - recurseoutput(v,cnt) - end - end + local i=1 + while indent[i] and revnewentry[i] == indent[i] do + i=i+1 end -end -?> - -<H3>Records</H3> -<? -local tags = {"nsourdomain", "nsdomain", "host", "alias", "mx", "ptr", "cname", "soa", "generic", "all" } -local myform = form.config.settings -io.write("<DL>") -for k,v in pairs(tags) do - local myform = myform[v] - if (myform) and (myform.value) then - io.write("\n\t<DT") - io.write(">" .. myform.label .. "</DT>") - io.write("\n\t\t<DD>") - - for k,v in pairs(myform.value) do - recurseoutput(v) - end - io.write("\n\t\t</DD>") + local ending = #indent-(i-1) + local starting = #newentry-(i-1) + for j=1,ending do + io.write("</li></ul>\n") + end + for j=1,starting do + io.write("<ul><li STYLE='margin-left:10px;'><strong>") + io.write(table.concat(newentry, ".", #newentry-(i+j-2), #newentry)) + io.write("</strong>\n") end + return revnewentry end -io.write("</DL>") ?> + +<H2>Records</H2> +<form id="filter-list">Filter: <input name="filter" id="filter" value="" maxlength="30" size="30" type="text"></form> +<DL id="records"> +<? +local tags = {".", "&", "=", "+", "@", "'", "^", "C", "Z", ":" } +for i,entrytype in ipairs(tags) do + local myview = view[entrytype] + if (myview) then ?> + <DT><?= myview.label ?></DT> + <DD><ul> + <? local indent = {} + for j,entry in ipairs(myview) do + indent = doListIndents(entry[1], indent) ?> + <ul><li STYLE='margin-left:10px;'><IMG SRC='/skins/static/tango/16x16/devices/computer.png' width='16' height='16'><?= tostring(entry[1]) ?><BR> + <TABLE STYLE='margin-left:<?= tostring(7-#indent) ?>0px;'> + <? for k=2,#entry do + local option = entry[k] + if (option) and option ~= "" then ?> + <TR><TD WIDTH='160px' STYLE='border:none;'><?= myview.fieldlabels[k] ?>:</TD> + <TD STYLE='border:none;'><?= option ?></TD></TR> + <? end + end ?> + </TABLE> + <? if entry.errtxt then ?> + <P CLASS='error'><?= string.gsub(entry.errtxt, "\n", "<BR>") ?></P> + <? end ?> + </li></ul> + <? end + doListIndents("", indent) ?> + </ul></DD> + <? end +end ?> +</DL> |