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.

45 lines
1.5 KiB

  1. $(function () {
  2. $("#log tr.ok").on("click", function() {
  3. $("#ping-details-body").text("Updating...");
  4. $('#ping-details-modal').modal("show");
  5. $.get(this.dataset.url, function(data) {
  6. $("#ping-details-body").html(data);
  7. var htmlPre = $("#email-body-html pre");
  8. if (htmlPre.length) {
  9. var opts = {USE_PROFILES: {html: true}};
  10. var clean = DOMPurify.sanitize(htmlPre.text(), opts);
  11. var blob = new Blob([clean], {type: "text/html; charset=utf-8"});
  12. var iframe = document.createElement("iframe");
  13. iframe.sandbox = "";
  14. iframe.src = URL.createObjectURL(blob);
  15. htmlPre.replaceWith(iframe);
  16. }
  17. });
  18. return false;
  19. });
  20. function switchDateFormat(format) {
  21. $("#log tr").each(function(index, row) {
  22. var dt = moment(row.getAttribute("data-dt"));
  23. format == "local" ? dt.local() : dt.tz(format);
  24. $(".date", row).text(dt.format("MMM D"));
  25. $(".time", row).text(dt.format("HH:mm"));
  26. })
  27. }
  28. $("#format-switcher").click(function(ev) {
  29. var format = ev.target.getAttribute("data-format");
  30. switchDateFormat(format);
  31. });
  32. switchDateFormat("local");
  33. // The table is initially hidden to avoid flickering as we convert dates.
  34. // Once it's ready, set it to visible:
  35. $("#log").css("visibility", "visible");
  36. });