2
0

reboot.htm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. <%+header%>
  7. <h2 name="content"><%:Reboot%></h2>
  8. <br />
  9. <p><%:Reboots the operating system of your device%></p>
  10. <%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
  11. <p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
  12. <%- end -%>
  13. <hr />
  14. <script type="text/javascript">//<![CDATA[
  15. var tries = 0;
  16. function ok() {
  17. window.location = '<%=controller%>/admin';
  18. }
  19. function check() {
  20. if (tries++ < 12)
  21. window.setTimeout(ping, 5000);
  22. else
  23. alert('<%:Device unreachable%>');
  24. }
  25. function ping() {
  26. var img = document.createElement('img');
  27. img.onload = ok;
  28. img.onerror = check;
  29. img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
  30. document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
  31. }
  32. function reboot(button) {
  33. button.style.display = 'none';
  34. document.getElementById('reboot-message').parentNode.style.display = '';
  35. (new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
  36. }
  37. //]]></script>
  38. <input class="cbi-button cbi-button-apply" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
  39. <p class="alert-message" style="display:none">
  40. <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
  41. <span id="reboot-message"><%:Device is rebooting...%></span>
  42. </p>
  43. <%+footer%>