[Countdown Mobile] Countdown

[Countdown Mobile] Countdown

  
Forge Component
(0)
Published on 26 Feb by Pedro Rodrigues
0 votes
Published on 26 Feb by Pedro Rodrigues

Hello Guys


I'm a new user of the Outsystems and I'm workin in a mobile app. The app need to comunicate with and Arduine by Bluetooth (that's ok), and I need to send a time in seconds to the arduino, like a countdonw, but I don't know how to put the countdown in the app. I would like to imput a button to start the coutdown and the time in coutdown is setted by the user, but I don't know how to do this.

Thanks


Hi Rubens,

The Countdown Mobile, doesn't work like you want. But I think the change you need to make to the webblock is minimal. If you want to ensure that the countdown starts based on user input and then pressing a button you could try following:

  1. Edit the Countdown Mobile app and remove the OnReady client action from the OnReady event.
  2. Rename OnReady client action to OnParameterChanged and select it on the OnParameterChanged event
  3. Edit the javascript flow in the OnParamterChanged client action, add the code shown in bold:

   jQuery(function () {  
     var untilDate = new Date($parameters.Year,$parameters.Month,$parameters.Day,$parameters.Hour,$parameters.Minute,$parameters.Second);
     try {
        jQuery($parameters.defaultCountdownId).countdown('destroy');
     } catch(err) {}

     jQuery($parameters.defaultCountdownId).countdown({until:untilDate, format: $parameters.Format, padZeroes: 'true', timeSeparator: ':',  labels: $parameters.Labels, compact: $parameters.Compact, onExpiry: $actions.OnCountdownFinished});
});

The inserted code ensures any running counter is destroyed prior to start a new counter (if user would change the counter and presses the button again to start the counter.

With the above changes you can make your app set the UntilDate for the webblock when the user presses a button.

Regards,

Daniel