Merge pull request #1906 from ldir-EDB0/typofix
[oweals/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_system / reboot.htm
1 <%#
2  Copyright 2008 Steven Barth <steven@midlink.org>
3  Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
4  Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%+header%>
8
9 <h2 name="content"><%:Reboot%></h2>
10
11 <p><%:Reboots the operating system of your device%></p>
12
13 <%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
14         <p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
15 <%- end -%>
16
17 <hr />
18
19 <script type="text/javascript">//<![CDATA[
20         var tries = 0;
21
22         function ok() {
23                 window.location = '<%=controller%>/admin';
24         }
25
26         function check() {
27                 if (tries++ < 12)
28                         window.setTimeout(ping, 5000);
29                 else
30                         alert('<%:Device unreachable%>');
31         }
32
33         function ping() {
34                 var img = document.createElement('img');
35
36                 img.onload = ok;
37                 img.onerror = check;
38                 img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
39
40                 document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
41         }
42
43         function reboot(button) {
44                 button.style.display = 'none';
45                 document.getElementById('reboot-message').parentNode.style.display = '';
46
47                 (new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
48         }
49 //]]></script>
50
51 <input class="cbi-button cbi-button-action important" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
52
53 <p class="alert-message" style="display:none">
54         <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
55         <span id="reboot-message"><%:Device is rebooting...%></span>
56 </p>
57
58 <%+footer%>