blob: 48c2a842521169c628bf83d809ee003f194b7819 (
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
|
<!-- ++ BEGIN ++ Radicale ++ btn_startstop.htm ++ -->
<script type="text/javascript">//<![CDATA[
// show XHR.poll/XHR.get response on button
function _data2elements(x) {
var btn = document.getElementById("cbid.radicale.<%=section%>._startstop");
if ( ! btn ) { return; } // security check
if (x.responseText == "0") {
btn.value = "<%:Start%>";
btn.className = "cbi-button cbi-button-apply";
btn.disabled = false;
} else {
btn.value = "PID: " + x.responseText;
btn.className = "cbi-button cbi-button-reset";
btn.disabled = false;
}
}
// event handler for start/stop button
function onclick_startstop(id) {
// do start/stop
var btnXHR = new XHR();
btnXHR.post('<%=url([[admin/services/radicale/startstop]])%>', { token: '<%=token%>' },
function(x) { _data2elements(x); }
);
}
XHR.poll(-1, '<%=url([[admin/services/radicale/status]])%>', null,
function(x, data) { _data2elements(x); }
);
//]]></script>
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then
-- We need to garantie that function cfgvalue run first to set missing parameters
%>
<!-- style="font-size: 100%;" needed for openwrt theme to fix font size -->
<!-- type="button" onclick="..." enable standard onclick functionalty -->
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)"
<%=
attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled")
%> />
<% end %>
<%+cbi/valuefooter%>
<!-- ++ END ++ Radicale ++ btn_startstop.htm ++ -->
|