blob: 7a66a7b545854b932a26bd2d1153cf533a819774 (
plain)
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
|
<% local form, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
<%
-- Function to mark params that overridden the default set in a param group
function markoverride(c)
if c.type == "group" then
for n,v in pairs(c.value) do
markoverride(v)
end
elseif c.groupdefault and c.value ~= c.groupdefault then
if c.class then
c.class = c.class .." groupdefaultoverride"
else
c.class = "groupdefaultoverride"
end
elseif c.default and c.value ~= c.default then
if c.class then
c.class = c.class .." defaultoverride"
else
c.class = "defaultoverride"
end
end
end
%>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
<script type="text/javascript">
<% -- Since we're including deletedevice as a component, we break the automatic redirect
if session.deletedeviceresult and not session.deletedeviceresult.errtxt and viewlibrary.check_permission("listdevices") then
-- Use JavaScript to redirect to the listdevices page
%>
window.location.assign("<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller) %>/listdevices");
<%
end
%>
function showsection() {
$("#"+$(this).attr("class")).toggle();
if ($(this).next().next("a").length == 1) {
$(this).next().next().toggle();
}
$(this).remove();
}
function hideunuseddivs() {
var previoussection = "";
var previousnumber = 0;
$("div").filter(function(){
var id = $(this).attr("id");
// We're looking for an id that starts with section_
if ((id != null) && (id.indexOf("section_") === 0)) {
return true;
}
return false;
}).each(function(i){
var id = $(this).attr("id");
var currentnumber = id.match(/\d+$/);
var currentsection
if (currentnumber != null) {
var len = id.length;
var numlen = currentnumber[0].length;
currentsection = id.substr(8, id.length-8-currentnumber[0].length);
currentnumber = currentnumber[0].toString();
} else {
currentsection = id.substr(8);
currentnumber = 0;
}
if ((currentsection == previoussection) && (currentnumber != previousnumber) && (0 == $(this).find(".defaultoverride").length) && (0 == $(this).find(".groupdefaultoverride").length)) {
$(this).toggle();
$('<a href="javascript:;" class="'+id+'"><img src="<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>tango/16x16/actions/list-add.png"> Add '+$(this).children().first().text()+'</a>').insertAfter($(this)).click(showsection);
if ($(this).prev("a").length == 1) {
// If the previous sibling is also an Add link, hide this one
$(this).next().toggle();
}
}
previoussection = currentsection;
previousnumber = currentnumber;
});
}
$(document).ready(function() {
$(".deletedevice").click(function(){ return confirm("Are you sure you want to delete this device?")});
$(".groupdefaultoverride").siblings().select("contains('Default:')").addClass("error");
hideunuseddivs();
});
</script>
<% if form and form.value and form.value.device_id and form.value.device_id.value ~= "" then %>
<% if viewlibrary.check_permission("editdevice") then %>
<a href='<%= page_info.script..page_info.prefix..page_info.controller.."/editdevice?device_id="..html.html_escape(form.value.device_id.value) %>'><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/categories/applications-system.png' title="Edit Class of Service"></img> <big>Edit Class of Service </big></a>
<% end %>
<% if viewlibrary.check_permission("deletedevice") then %>
<a href='<%= page_info.script..page_info.prefix..page_info.controller.."/deletedevice?submit=true&device_id="..html.html_escape(form.value.device_id.value) %>' class="deletedevice"><img src='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/emblems/emblem-unreadable.png' title="Delete this Device"></img> <big>Delete this Device </big></a>
<% end %>
<% end %>
<%
form.value.device_id.readonly = "true"
if not form.errtxt and form.value.groupdefaultoverride.value then
form.errtxt = "Warning: Class defaults have been overridden for this device"
end
form.value.groupdefaultoverride = nil
-- Mark the parameters where the group default is overridden
for n,v in pairs(form.value) do
markoverride(v)
end
htmlviewfunctions.displayitem(form, page_info)
%>
|