clock_status.htm 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. XHR.poll(-1, '<%=url('admin/system/clock_status')%>', null,
  4. function(x, rv)
  5. {
  6. var s = document.getElementById('<%=self.option%>-clock-status');
  7. if (s)
  8. {
  9. s.innerHTML = rv.timestring || '?';
  10. }
  11. }
  12. );
  13. function sync_clock(btn)
  14. {
  15. btn.disabled = true;
  16. btn.value = '<%:Synchronizing...%>';
  17. (new XHR()).post('<%=url('admin/system/clock_status')%>',
  18. { token: '<%=token%>', set: Math.floor((new Date()).getTime() / 1000) },
  19. function()
  20. {
  21. btn.disabled = false;
  22. btn.value = '<%:Sync with browser%>';
  23. }
  24. );
  25. return false;
  26. }
  27. function btn_action(action)
  28. {
  29. if (action.name === "do_ntp_restart")
  30. {
  31. new XHR.get('<%=luci.dispatcher.build_url("admin", "system", "ntp_restart")%>', null,
  32. function(x)
  33. {
  34. if (!x)
  35. {
  36. return;
  37. }
  38. });
  39. }
  40. }
  41. //]]></script>
  42. <span id="<%=self.option%>-clock-status"><em><%:Collecting data...%></em></span>
  43. <input type="button" class="cbi-button cbi-button-apply" value="<%:Sync with browser%>" onclick="return sync_clock(this)" />
  44. <% if require("nixio.fs").access("/etc/init.d/sysntpd") then %>
  45. <input type="button" class="cbi-button cbi-button-apply" name="do_ntp_restart" value="<%:Sync with NTP-Server%>" onclick="btn_action(this)" />
  46. <% end %>
  47. <%+cbi/valuefooter%>