Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Countdown timer

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Countdown timer

Thanks for sharing.

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

Countdown timer

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 =)

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Countdown timer

Hi Alex,

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

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

Countdown timer

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!!!!!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Countdown timer

Alex,

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

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

Countdown timer

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 =)

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Countdown timer

Alex,

We'll test this.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Countdown timer

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.

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

Countdown timer

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

Return to “Issues”