1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
<% local view, viewlibrary = ...
require("viewfunctions")
%>
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript">
var last_phrase = "";
function filterPage(){
var phrase = $("#filter").val();
if (phrase != last_phrase){
last_phrase = phrase;
$("#records li").each(function(){
var elem = jQuery(this);
if (elem.text().indexOf(phrase)>=0) {
elem.show();
} else {
elem.hide();
}
});
}
}
function toggleEntry(){
$(this).find("table").toggle();
$(this).find("pre").toggle();
}
function editEntry(){
window.location.href = "edit?" + this.id;
}
var filterTimer;
$(function(){
$("#filter").keyup(function(){
window.clearTimeout(filterTimer);
filterTimer = window.setTimeout("filterPage();",250);
});
$("#filter-list").submit(function(){
return false;
}).focus();
$("#records pre").hide();
$("#records li").not(":has(ul)").click(toggleEntry);
$("#records li").not(":has(ul)").dblclick(editEntry);
$("#locations li").not(":has(ul)").dblclick(editEntry);
});
</script>
<H1>DNS Entries
<% if view.filename then io.write(" for "..html.html_escape(string.gsub(view.filename, "^.*/", ""))) end %>
</H1>
<H2>Locations</H2>
<DL id="locations">
<ul>
<% local currentloc = ""
for i,loc in ipairs(view.value) do
if loc.type == '%' then
if currentloc ~= loc[1] then
if currentloc ~= "" then %>
</ul>
<% end %>
<li><IMG SRC='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/places/start-here.png' width='16' height='16' alt> <B><%= html.html_escape(loc[1]) %></B></li>
<ul STYLE='margin-left:30px';>
<% end
currentloc = loc[1] %>
<li id='filename=<%= html.html_escape(loc.filename) %>;linenumber=<%= html.html_escape(loc.linenumber) %>'>
<%= html.html_escape(loc[2]) %><% if loc[2] == "" then io.write('*') end %>
<% if (loc.errtxt) then %><P CLASS='error'><%= string.gsub(html.html_escape(loc.errtxt), "\n", "<BR>") %></P><% end %>
</li>
<% end
end %>
<% if currentloc == "" then %>
No locations defined
<% else %>
</ul>
<% end %>
</ul>
</DL>
<%
local function doListIndents(next, indent)
local newentry = {}
for mt in string.gmatch(next, "([^.]+)") do
table.insert(newentry, mt)
end
local revnewentry = {}
for j=#newentry,1,-1 do
table.insert(revnewentry, newentry[j])
end
local i=1
while indent[i] and revnewentry[i] == indent[i] do
i=i+1
end
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(html.html_escape(table.concat(newentry, ".", #newentry-(i+j-2), #newentry)))
io.write("</strong>\n")
end
return revnewentry
end
%>
<H2>Records</H2>
<DL id="records">
<form id="filter-list">Filter: <input name="filter" id="filter" value="" maxlength="30" size="30" type="text"></form>
<ul>
<% local indent = {}
for j,entry in ipairs(view.value) do
if entry.type ~= '%' then
indent = doListIndents(entry[1], indent) %>
<ul><li STYLE='margin-left:10px;' id='filename=<%= html.html_escape(entry.filename) %>;linenumber=<%= html.html_escape(entry.linenumber) %>'>
<IMG SRC='<%= html.html_escape(page_info.staticdir) %>/tango/16x16/devices/computer.png' width='16' height='16'><%= html.html_escape(entry.label) %><BR>
<pre><%= html.html_escape(entry.configline) %></pre>
<TABLE STYLE='margin-left:<%= html.html_escape(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;'><%= html.html_escape(view.fieldlabels[entry.type][k]) %>:</TD>
<TD STYLE='border:none;'><%= html.html_escape(option) %></TD></TR>
<% end
end %>
</TABLE>
<% if entry.errtxt then %>
<P CLASS='error'><%= string.gsub(html.html_escape(entry.errtxt), "\n", "<BR>") %></P>
<% end %>
</li></ul>
<% end
end
if #indent == 0 then %>
No records defined
<% else
doListIndents("", indent)
end %>
</ul>
</DL>
|