luci-app-*: use default poll interval
[project/luci.git] / applications / luci-app-radicale / luasrc / view / radicale / btn_startstop.htm
1
2 <!-- ++ BEGIN ++ Radicale ++ btn_startstop.htm ++ -->
3 <script type="text/javascript">//<![CDATA[
4
5 // show XHR.poll/XHR.get response on button
6 function _data2elements(x) {
7 var btn = document.getElementById("cbid.radicale.<%=section%>._startstop");
8 if ( ! btn ) { return; } // security check
9 if (x.responseText == "0") {
10 btn.value = "<%:Start%>";
11 btn.className = "cbi-button cbi-button-apply";
12 btn.disabled = false;
13 } else {
14 btn.value = "PID: " + x.responseText;
15 btn.className = "cbi-button cbi-button-reset";
16 btn.disabled = false;
17 }
18 }
19
20 // event handler for start/stop button
21 function onclick_startstop(id) {
22 // do start/stop
23 var btnXHR = new XHR();
24 btnXHR.post('<%=url([[admin/services/radicale/startstop]])%>', { token: '<%=token%>' },
25 function(x) { _data2elements(x); }
26 );
27 }
28
29 XHR.poll(-1, '<%=url([[admin/services/radicale/status]])%>', null,
30 function(x, data) { _data2elements(x); }
31 );
32
33 //]]></script>
34
35 <%+cbi/valueheader%>
36
37 <% if self:cfgvalue(section) ~= false then
38 -- We need to garantie that function cfgvalue run first to set missing parameters
39 %>
40 <!-- style="font-size: 100%;" needed for openwrt theme to fix font size -->
41 <!-- type="button" onclick="..." enable standard onclick functionalty -->
42 <input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)"
43 <%=
44 attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled")
45 %> />
46 <% end %>
47
48 <%+cbi/valuefooter%>
49 <!-- ++ END ++ Radicale ++ btn_startstop.htm ++ -->