Page 1 of 3

Countdown timer

Posted: Thu Aug 08, 2013 3:30 pm
by Johnny

Hi, keep in mind im not a javascript programmer in the code below, I want show you my idea of a countdown timer.

If someone can make it beter or other method please advice. I can add it work in a html block. Show it is working on the app.

code
<script>
function cdtd() {
var xmas = new Date("August 10, 2013 00:00:00");
var now = new Date();
var timeDiff = xmas&#46;getTime() - now&#46;getTime();
if (timeDiff <= 0) {
clearTimeout(timer);
document&#46;write("Christmas is here!");
&#47;&#47; Run any code needed for countdown completion here
}
var seconds = Math&#46;floor(timeDiff &#47; 1000);
var minutes = Math&#46;floor(seconds &#47; 60);
var hours = Math&#46;floor(minutes &#47; 60);
var days = Math&#46;floor(hours &#47; 24);
hours %= 24;
minutes %= 60;
seconds %= 60;
document&#46;getElementById("daysBox")&#46;innerHTML = days;
document&#46;getElementById("hoursBox")&#46;innerHTML = hours;
document&#46;getElementById("minsBox")&#46;innerHTML = minutes;
document&#46;getElementById("secsBox")&#46;innerHTML = seconds;
var timer = setTimeout('cdtd()',1000);
}<&#47;script>
Days Remaining:
<div id="daysBox"><&#47;div>
Hours Remaining:
<div id="hoursBox"><&#47;div>
Minutes Remaining:
<div id="minsBox"><&#47;div>
Seconds Remaining:
<div id="secsBox"><&#47;div>
<script type="text&#47;javascript">cdtd();<&#47;script>

/code

thank you


Countdown timer

Posted: Thu Aug 08, 2013 3:45 pm
by maxkatz

Thanks for sharing.


Countdown timer

Posted: Sun Jan 26, 2014 8:00 pm
by Alex GG

Hello Appery team!
I ́m implementing a countdown timer in my list of business promotions:
I have tried with 3 different plugins, including the one in this post:
I have manage to make all of them work in a list of one element: Image

Image

As you can see, the clock is always counting. But If I bind the $ of the service to the mobile list, to get all items...The clock of all items STOPS... like this:

Image

the counter is frozen,...

No errors in CONSOLE...
Can you guide on how to solve this issue? or if its a bug, or what I ́m trying to do is not possible...Although I ́ve seen this implementation working on another APPS..

thanks in advance =)


Countdown timer

Posted: Mon Jan 27, 2014 3:47 pm
by Kateryna Grynko

Hi Alex,

Could you please post some screenshots of your service mapping? What code do you use?


Countdown timer

Posted: Mon Jan 27, 2014 6:22 pm
by Alex GG

Hello Katya,
I ́ve tried different ways...but the result is always the same...the if I bond the $ to the mobile list,,,counter frozens...
this is my code with static date:
Image
this is the mapping with just the busines name:

Image

and this is the preview:

Image

if I unbind the $ to the mobile list: this is the preview:

Image

and if I bind the end_date from DB to a local JS and add the code using value as the variable, like this: (dont mind of the name of the fild last_rate, it contains this :
Sat Feb 26 2014 00:00:00 GMT-0600
the code is this
$('#clockk').timeTo(new Date(value));

this is the preview:

Image

If you wish I can share the APP...Or any suggestion??

thankss!!!!!


Countdown timer

Posted: Mon Jan 27, 2014 6:29 pm
by Kateryna Grynko

Alex,

Yes, please share with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a


Countdown timer

Posted: Mon Jan 27, 2014 7:15 pm
by Alex GG

Ready!
In Screen 1 and screen 2 are examples of the time counters...
In screen 3, is a facebook share button, that works on browser, but not on mobile phone,,I tested on a Sony Xperya, V 6.2.

If you can help me how to solve this 2 issues, please..

Regards =)


Countdown timer

Posted: Mon Jan 27, 2014 7:23 pm
by Kateryna Grynko

Alex,

We'll test this.


Countdown timer

Posted: Tue Jan 28, 2014 12:11 pm
by Maryna Brodina

Hello! The problem is how you define and call function. Every time your function is redefined, besides that every time you create the same elements with the same ids in each item. To implement it you have to know what is closure in js. If you want we can create test project for you, but providing an explanation is outside the cope of our support.


Countdown timer

Posted: Tue Jan 28, 2014 3:45 pm
by Alex GG

Hello Maryna, how much it cost to create the test project for me?