From b29400710f59d7f5c6b0a059a753c64125dce06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 23 Dec 2016 20:46:27 +0200 Subject: [PATCH] Fix race conditions in preview code. --- static/js/checks.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/static/js/checks.js b/static/js/checks.js index ebd212ac..b76d9919 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -97,21 +97,17 @@ $(function () { }); function showSimple() { - console.log("show simple"); $("#update-timeout-form").show(); $("#update-cron-form").hide(); } function showCron() { - console.log("show cron"); $("#update-timeout-form").hide(); $("#update-cron-form").show(); } var currentPreviewHash = ""; function updateCronPreview() { - console.log("requested to update cron preview"); - var schedule = $("#schedule").val(); var tz = $("#tz").val(); var hash = schedule + tz; @@ -145,11 +141,13 @@ $(function () { graceSlider.noUiSlider.set(this.dataset.grace); // Cron + currentPreviewHash = ""; $("#cron-preview").html("

Updating...

"); $("#schedule").val(this.dataset.schedule); document.getElementById("tz").selectize.setValue(this.dataset.tz); var minutes = parseInt(this.dataset.grace / 60); $("#update-timeout-grace-cron").val(minutes); + updateCronPreview(); this.dataset.kind == "simple" ? showSimple() : showCron(); $('#update-timeout-modal').modal({"show":true, "backdrop":"static"}); @@ -161,8 +159,7 @@ $(function () { $(".kind-cron").click(showCron); $("#schedule").on("keyup", updateCronPreview); - $("#tz").on("change", updateCronPreview); - + $("#tz").selectize({onChange: updateCronPreview}); $(".check-menu-remove").click(function() { $("#remove-check-form").attr("action", this.dataset.url); @@ -217,7 +214,6 @@ $(function () { }); $('[data-toggle="tooltip"]').tooltip(); - $("#tz").selectize(); $(".usage-examples").click(function(e) { var a = e.target;