如何设置setInterval函数来更新味精盒?

时间:2019-03-20 07:42:50

标签: javascript jquery html

我当前正在制作一个网页,我需要实现的是,当我单击一个图标时,消息框会提示提示,并且当我返回倒数计时器时,该消息框上有一个倒数计时器。 ,它仅在触发时返回该值,但我想在消息框中进行实时倒数计时器,该怎么办?

这是JavaScript

function phyTimer3() {
  var minutes1 = Math.floor(timeleft2 / 60);
  var seconds1 = Math.floor(timeleft2 % 60);

  if (timeleft2 > 0) {
    timeleft2 -= 1;
  } else {
    autoRefresh = 1;
    localStorage.setItem("translateX", translate.translateX);
    localStorage.setItem("translateY", translate.translateY);
    localStorage.setItem("scale", scale);
    localStorage.setItem("autoRefresh", autoRefresh);
    localStorage.setItem("zoomLevel", zoomLevel);
    window.location.reload();
  }
  if (seconds1 < 10) {
    seconds1 = "0" + seconds1;
  }
  return ("Global Timer " + minutes1 + " : " + seconds1);
}



if (bs.monitoring_status == 1) {
  if (bs.cooldown_duration == '') {
    var timer1 = document.getElementById('timer2').value;
    monitoringmsg = "Zone:" + bs.zone + " Site:" + bs.site + " Current Monitoring Status is On" +
      "</br>" + "Do you want to turn it <strong>off</strong>?" + "</br>" + "Cooldown Timer : " + phyTimer3();
  } else {
    monitoringmsg = "Zone:" + bs.zone + " Site:" + bs.site + " Current Monitoring Status is On" +
      "</br>" + "Do you want to turn it <strong>off</strong>?"
  }

  $("#manualSwitch").append($("<p/>").attr("id", "monitoringon").attr("title", "Monitoring Status").html(monitoringmsg));
  $("#monitoringon").dialog({

    resizable: false,
    height: "auto",
    width: 400,
    modal: true,
    buttons: {
      'Yes': function() {

        $("#monitoring_zone_id").val(bs.zone);
        $("#monitoring_site_id").val(bs.site);

        $("#actionMonitoring").val('off');
        document.forms["brSwitch"].submit();

        $(this).dialog('close');
      },

      'Cancel': function() {

        $(this).dialog('close');
      }

    }
  });
}

函数phyTimer3是我返回分钟和秒的地方,但是显然这是行不通的,我是编程新手,我不确定哪种函数在起作用,你们可以帮我吗? ?

0 个答案:

没有答案