You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

  1. $(function () {
  2. $("#log tr.ok").on("click", function() {
  3. $("#ping-details-body").text("Updating...");
  4. $('#ping-details-modal').modal("show");
  5. var token = $('input[name=csrfmiddlewaretoken]').val();
  6. $.ajax({
  7. url: this.dataset.url,
  8. type: "post",
  9. headers: {"X-CSRFToken": token},
  10. success: function(data) {
  11. $("#ping-details-body" ).html(data);
  12. }
  13. });
  14. return false;
  15. });
  16. function switchDateFormat(format) {
  17. $("#log tr").each(function(index, row) {
  18. var dt = moment(row.getAttribute("data-dt"));
  19. format == "local" ? dt.local() : dt.utc();
  20. $(".date", row).text(dt.format("MMM D"));
  21. $(".time", row).text(dt.format("HH:mm"));
  22. })
  23. }
  24. $("#format-switcher").click(function(ev) {
  25. var format = ev.target.getAttribute("data-format");
  26. switchDateFormat(format);
  27. });
  28. switchDateFormat("local");
  29. // The table is initially hidden to avoid flickering as we convert dates.
  30. // Once it's ready, set it to visible:
  31. $("#log").css("visibility", "visible");
  32. });