hey Pmario,

Sorry abt the lack of clarity, I shall explain.

Use Case: some sort of quizzing platform where a countdown is initiated 
once the quiz starts and once the time is up navigate to a tiddler where 
responses can be submitted

I tried doing something in the last few hours (I have no idea abt 
javascript but somehow managed by looking at other examples, most notably 
http://tiddlytime.tiddlyspot.com/)




/*\
title: $:/plugins/timer.js
type: application/javascript
module-type: macro

\*/
(function () {

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

// Export name and synchronous status
exports.name = "timer";
exports.params = [];

exports.run = function() {
// Set the date we're counting down to
var countDownDate = new Date().getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get todays date and time
  var now = new Date().getTime();

  // Find the distance between now an the count down date
  var distance = now - countDownDate;

  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 
60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  return new $tw.Tiddler($:/temp/time,{"text": days + "d " + hours + "h " + 
minutes + "m " + seconds + "s "});

  // If the count down is over, write some text 
    if (distance > 60000) {
        clearInterval(x);
  return new $tw.Tiddler($:/temp/timeup,{"text": Time Up});
    }
    
}, 1000);
};

})();



cheers



On Sunday, December 10, 2017 at 4:27:43 PM UTC+5:30, PMario wrote:
>
> On Sunday, December 10, 2017 at 8:00:05 AM UTC+1, [email protected] 
> wrote:
>>
>> it would be also good to get the minutes and seconds in seperate temp 
>> tiddlers as the timer progresses so that after a particular time has passed 
>> some action can be made to happen ..
>>
>
> IMO you need to be a bit more specific, about what you want.
>
> Do you want 1 timer or several active at the same time?
> Should they be pausable / deletable while active?
> What "action" do you want, after the timer has stopped? 
> What should happen, if the tab, that contains the timer is not visible?
>
> ToDoNow plugin contains something that's called a "deadline" 
> https://tid.li/tw5/plugins.html
> Do you want something like this?
>
> -m
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e84ae432-6606-4658-9d31-177495699835%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to