libs/web: add placeholder support to DynamicList widgets
[oweals/luci.git] / libs / web / luasrc / view / cbi / apply_xhr.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9         http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <% export("cbi_apply_xhr", function(id, configs) -%>
16 <fieldset class="cbi-section" id="cbi-apply-<%=id%>">
17         <legend><%:Applying changes%></legend>
18         <script type="text/javascript"><![CDATA[
19                 var apply_xhr = new XHR();
20
21                 apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null,
22                         function() {
23                                 var intv = window.setInterval(
24                                         function() {
25                                                 apply_xhr.abort();
26                                                 apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
27                                                         function(x) {
28                                                                 if( x.responseText == 'finish' )
29                                                                 {
30                                                                         window.clearInterval(intv);
31
32                                                                         var e = document.getElementById('cbi-apply-<%=id%>-status');
33                                                                         if( e )
34                                                                         {
35                                                                                 e.innerHTML = '<%:Configuration applied.%>';
36                                                                                 window.setTimeout(function() { e.parentNode.style.display = 'none' }, 1000);
37                                                                         }
38                                                                 }
39                                                                 else
40                                                                 {
41                                                                         var e = document.getElementById('cbi-apply-<%=id%>-status');
42                                                                         if( e && x.responseText ) e.innerHTML = x.responseText;
43
44                                                                 }
45                                                         }
46                                                 );
47                                         }, 1000
48                                 )
49                         }
50                 );
51         ]]></script>
52
53         <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
54         <span id="cbi-apply-<%=id%>-status"><%:Waiting for router...%></span>
55 </fieldset>
56 <%-     end) %>