0

This question might already been discussed but I couldn't find quite what I was looking for.

I'm working on Adobe Edge Animate with HTML+JS. This is a full JS question so that's why I'm posting it here. I wrote a bit of code to have dialogue box appear at a specific time during the day. The dialogue has two buttons: "Play Video Now" and "Remind me in 10 mins"

Here is the code:

function updateClock() {
    var d = new Date(); // current date
    var m = d.getMinutes();
    var h = d.getHours();

    console.log(h, ":", m);

    // call this function again in 1000ms
    sym.updateClock = setTimeout(updateClock, 1000);

    if (h == 9 && m == 0) { //at 9hrs 00 min 

        //run the dialogue for the morning pause
        sym.play(1000);
    } else {
        sym.stop(1000);
    }
}

updateClock(); // initial call

Then I have to bind the snooze button so it adds 10 minutes to my conditional statement. I know I have to add some sort of "count" variable, but I don't know exactly how to do it.

(function(symbolName) {
      Symbol.bindElementAction(compId, symbolName, "${_snoze_btn}", "click", function(sym, e) {

      }
rvighne
  • 20,755
  • 11
  • 51
  • 73
JotaSolano
  • 65
  • 9
  • 2
    You don't want to just call setTimeout with 10 minutes worth of milliseconds? 600000? – iabw Aug 31 '14 at 18:19

1 Answers1

0

pretty sure you just want this -

(function(symbolName) {
  Symbol.bindElementAction(compId, symbolName, "${_snoze_btn}", "click", function(sym, e) {
    // remind again again in 10 minutes
    popupPlayOrSnoozeDialogTimer = setTimeout(popupPlayOrSnoozeDialogTimer, 600000);
  });
}())

If you want to add 10 minutes to the current timeout until that function is called again, check out this answer or look at new Date().valueOf()

Community
  • 1
  • 1
iabw
  • 1,108
  • 1
  • 9
  • 24
  • Hi! Well this line of code doesn't do anything (as far as I can see). By pressing the button Snooze, I should also be able to "sym.play(1000) 10 minutes later), but that line is not a conditional, it only sets a 10 minute Timeout. Can I add a conditional in the form of "if PlayOrSnoozeDialogTimer = True, then play 1000" ? – JotaSolano Sep 02 '14 at 00:28