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.

109 lines
3.1 KiB

10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
  1. $(function () {
  2. var secsToText = function(total) {
  3. total = Math.floor(total / 60);
  4. var m = total % 60; total = Math.floor(total / 60);
  5. var h = total % 24; total = Math.floor(total / 24);
  6. var d = total % 7; total = Math.floor(total / 7);
  7. var w = total;
  8. var result = "";
  9. if (w) result += w + (w == 1 ? " week " : " weeks ");
  10. if (d) result += d + (d == 1 ? " day " : " days ");
  11. if (h) result += h + (h == 1 ? " hour " : " hours ");
  12. if (m) result += m + (m == 1 ? " minute " : " minutes ");
  13. return result;
  14. }
  15. var periodSlider = document.getElementById("period-slider");
  16. noUiSlider.create(periodSlider, {
  17. start: [20],
  18. connect: "lower",
  19. range: {
  20. 'min': [60, 60],
  21. '30%': [3600, 3600],
  22. '82.80%': [86400, 86400],
  23. 'max': 604800
  24. },
  25. pips: {
  26. mode: 'values',
  27. values: [60, 1800, 3600, 43200, 86400, 604800],
  28. density: 5,
  29. format: {
  30. to: secsToText,
  31. from: function() {}
  32. }
  33. }
  34. });
  35. periodSlider.noUiSlider.on("update", function(a, b, value) {
  36. var rounded = Math.round(value);
  37. $("#period-slider-value").text(secsToText(rounded));
  38. $("#update-timeout-timeout").val(rounded);
  39. });
  40. var graceSlider = document.getElementById("grace-slider");
  41. noUiSlider.create(graceSlider, {
  42. start: [20],
  43. connect: "lower",
  44. range: {
  45. 'min': [60, 60],
  46. '30%': [3600, 3600],
  47. '82.80%': [86400, 86400],
  48. 'max': 604800
  49. },
  50. pips: {
  51. mode: 'values',
  52. values: [60, 1800, 3600, 43200, 86400, 604800],
  53. density: 5,
  54. format: {
  55. to: secsToText,
  56. from: function() {}
  57. }
  58. }
  59. });
  60. graceSlider.noUiSlider.on("update", function(a, b, value) {
  61. var rounded = Math.round(value);
  62. $("#grace-slider-value").text(secsToText(rounded));
  63. $("#update-timeout-grace").val(rounded);
  64. });
  65. $('[data-toggle="tooltip"]').tooltip();
  66. $(".my-checks-name").click(function() {
  67. var $this = $(this);
  68. $("#update-name-form").attr("action", $this.data("url"));
  69. $("#update-name-input").val($this.data("name"));
  70. $('#update-name-modal').modal("show");
  71. $("#update-name-input").focus();
  72. return false;
  73. });
  74. $(".timeout-grace").click(function() {
  75. var $this = $(this);
  76. $("#update-timeout-form").attr("action", $this.data("url"));
  77. periodSlider.noUiSlider.set($this.data("timeout"))
  78. graceSlider.noUiSlider.set($this.data("grace"))
  79. $('#update-timeout-modal').modal({"show":true, "backdrop":"static"});
  80. return false;
  81. });
  82. $(".check-menu-remove").click(function() {
  83. var $this = $(this);
  84. $("#remove-check-form").attr("action", $this.data("url"));
  85. $(".remove-check-name").text($this.data("name"));
  86. $('#remove-check-modal').modal("show");
  87. return false;
  88. });
  89. });