cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Timer on Mashup - Timer should run based on click event (Button)

vr-6
4-Participant

Timer on Mashup - Timer should run based on click event (Button)

Hi,

Is there is any way to run timer on Mashup ? Timer should run based on button click event. Thanks in advance.

5 REPLIES 5
tkawasaki
15-Moonstone
(To:vr-6)

You can achieve that by creating a Service like below in a Thing and then bind this service to "Clicked" of a button Widget in your Mashup.

===============

function sleep(time) {

  var d1 = new Date().getTime();

  var d2 = new Date().getTime();

  while (d2 < d1 + time) {

    d2 = new Date().getTime();

   }

   return;

}

//Set how long you want to set sleep in ms

sleep(1000);

===============

ankigupta
5-Regular Member
(To:vr-6)

Hi Velkumar R​,

I suppose that you can use Autorefresh here. It can be switch on off on click event.

Please share your usecase in more detail to help me suggest more in this regard.

vr-6
4-Participant
(To:ankigupta)

Hi Ankit,

When user click start button, timer should run on mashup and when user click stop button on mashup timer should stop. (Like StopWatch)

You just need to call Timer Thing EnableTimer and DisableTimer services.

ankigupta
5-Regular Member
(To:vr-6)

Velkumar R​,

I suppose that you want a Timer widget on Mashup. I just checked the Marketplace and can't find a widget with similar functionality.

You can create your own custom widget with the required functionality.

Second option could be to use a Value Display widget and create a custom service to get the difference between the last click and current time. Use the output f this service as input to value Display widget and call the service every second to update the data.

I personally think that calling the service every second won't be a good idea.

Top Tags