Talk:Countdown

Doesn't work
I don't really get it, I have no leading zeros and it to display on EST time but it doesn't do anything. (It's still localized) The timer is here. edit: I think I managed to fix the localized time, but leading zeros aren't removed.¿ Vosavo  Talk  Contributions         The essence of your mind is intrinsically pure. 16:32, April 10, 2016 (UTC)

Misc
It doesn't seem to work.--  Chris  talk   blog  16:08, August 9, 2010 (UTC)

Is there a way to remove the "T minus" part of the countdown?  Neocarleen  •  Talk

Update to Code
I'd like to propose an update to the code. My modified code here determines whether it should be sigular or plural (1 second instead of 1 seconds).


 * I've added the code. Feel free to remove it if I shouldn't have.

Error
Okay, the message when the countdown isn't working is displaying. But what do I do now? 19:24, March 29, 2012 (UTC)

No more counting up!
I'd like to offer some improvement for the code. You can see my version here. It adds another where you can make a custom message to display once the countdown is finished. The timer now will not count up once the countdown has finished and this message will be displayed instead. Land Raider 20:34, July 1, 2012 (UTC)


 * I considered changing the code a while back to work this way. The version of the code I run at Casualty Wiki has been customised so it knows when an episode is on air or has finished airing. However, after some reflection and looking at how other wikis use the code, I decided not to - as some wikis actually do use countups instead of countdowns. Your idea has merit, so I will look into integrating it into version 2.

Countdown code need to be checked
The current countdown script works really slow and need to be improved. Currently the script use is also really messy so maybe we beter make an total new version for it

What code should be used (my opinion, if possible)
 January 01 2013 00:00:00

And with all options:

 until the new year...; display:ymdhms;" style="...">January 01 2013 00:00:00

--Jens Ingels (talk) 00:59, August 16, 2012 (UTC)


 * By 'script', are you referring to the html used to insert the countdown, or the JavaScript itself?
 * I agree that the current html is messy, but any change to how the html is used would mean a separate version of the JavaScript would be needed, as a lot of wikis use the current format. This would be possible, but I just want to clarify what you think should be done. I personally think the script is rather quick.
 * (edit) I see a flaw in your 'better' html. The reason the 'JavaScript disabled' text is separate... is because it needs to display when JavaScript isn't working properly. You can't use JavaScript to say there isn't any JavaScript! ;)

With the script speed I'm talking about the switch between non JavaScript and when the script is activated. Currently it takes an long time (like 1-2 seconds) te replace the alternative text to the countdown what's in my opinion really slow. The code is just an example how it could display beter, I never said it could be an working code. Couldn't there be an save cookie option or something that can speedup the loading time ones you visited the page the first time.--Jens Ingels (talk) 15:57, August 17, 2012 (UTC)


 * The script loads virtually instantly on the wikis I use it on. Either your 1-2 seconds is an over estimate, or the wiki you have it applied to has a lot of js to load. Would you mind linking me to the wiki you run the script on, and a page with a countdown so I can test?
 * The main bulk of the countdown code was developed by an old user, but from what I understand of it, it seems very efficient as it is. If you want to suggest some actual script changes then of course, feel free, as I don't know the extent of your js knowledge.

2 Questions

 * 1) Is the "JavaScript disabled" thingy really necessary?
 * 2) Why does the countdown count up after it's finished?

I added a Dutch translation btw. --


 * When the code was first written, I suspect it was more necessary than it is today. However, this is still useful to to wikis, as alternate text if for some reason the code isn't working. For example, this template counts down to the next episode of a show. if you look closely, you will see that the alternate text provides the same information, but without the live countdown: "will air on 15 December 2012 at 21:00". However, you can just not use the 'nocountdown' bit, and it will work fine.
 * This is by design. I have seen some wikis use the code to count up - not many, but enough to justify keeping the functionality in this way. The main reason I haven't changed a lot of things in this code is because of it's wide usage on other wikis. At Casualty Wiki, I ran a customised version of the code. When the countdown reaches zero, it displays a line of text instead. While this can easily be done here, it would need to be customisable on a per-countdown basis - requiring another span tag in the syntax. While this isn't a big problem, compatibility is something I have always put first when considering changes to the code.
 * I am not a very good coder. I will be the first to admit that - and it is often obvious when others look at my codes. I 'adopted' the Countdown script as I needed it to be more versatile at the time. If you think you can improve the script without breaking the compatibility, feel free to suggest changes. I've done a lot of patchwork editing on this, and I'm sure it can be streamlined.
 * Thanks for the translation.


 * The "JavaScript disabled" thing is already optional. It cannot be removed from the code of course, but if it was up to me, I'd remove it from the documentation at least. There was a time when Wikia was usable without JavaScript but that's a distant memory :)


 * If some wikis count on counting up, then it must stay, but I think other options should be provided:


 * remove the countdown
 * let it stay at zero
 * show alternate content


 * All of these can be done without breaking compatibility.


 * If you don't mind I'll write something... --


 * I've altered the documentation. Feel free to write something, but could you run it by me first in this talk page? It just helps me keep on top of everything. Cheers.


 * No problem. You've taken this addon in your care. I respect that.


 * This is a bit unorthodox, but since it's apparently possible to have more than one countdown per page I'd suggest adding the data directly to the wikitext instead of the JS code. That might be simpler...


 * So I propose to add three (optional) new attributes to the countdown span:


 * data-end &mdash; specifies how the end should be handled:
 * value: "continue" (default) &mdash; continue counting
 * value: "stop" &mdash; stop at zero
 * value: "remove" &mdash; remove the countdown
 * value: "toggle" &mdash; set another tag's display to "inline" and the countdown's to "none"
 * value: "callback" &mdash; call a JavaScript function
 * data-toggle &mdash; another inline tag to show instead (to be used with data-end="toggle")
 * data-callback &mdash; a JavaScript function to call (to be used with data-end="callback")


 * Example:


 * I hope this is sufficiently flexible without making things complicated.


 * (I've already tested it btw: The wikitext parser does not discard attributes with a "data-" prefix.)




 * This seems practical - I assume it defaults to countup if no data-end is defined?
 * I would like to see the script in action before we commit it to the dev version. There's no rush toany of this, but when/if you get a chance to code it, put on a sandbox or something so I can take a look.


 * Alright. Here's the my rewrite proposal: w:c:pecoes:Countdown.js and you can test it here: w:c:pecoes:Countdown  . If you want to test the callback, try "demo". The demo function will show an alert when the countdown ends. --  (Files have been removed)


 * Yeah, I'm perfectly happy with that. It's nice to see the script rewritten actually. I certainly would not have been able to overhaul the script like this, so thank you.


 * If you think it is ready, feel free to update the code page and documentation. Something that might be useful to add to the code though is checks to see if we need days/hours/minutes and remove the largest interval once it reaches zero. A simple delta > 0 should do. What are your thoughts?

Yeah. That's easy to do. Personally I like the leading zeros. They give the countdown more gravitas :)

I will have to add another option then. This may not be the last option request, so I'd rather use something generic like


 * I just read Jens Ingels post... he seems to want more formatting options for the output. Has that been requested a lot? Cause that would be a boatload of work :( --


 * I haven't really seen any requests similar to what Jens is describing. I think the code is fine as it is...

Suggestion: Short counter
I use a customised version of Splarka's original countdown script, with a short form of the countdown "d days, h:m:s" to save space. It would be convenient if this script had a short option. -452 18:54, March 26, 2013 (UTC)


 * I could alter the script so that it would accept a custom format function. Something like this:

Chinese localization
There should be more localization options for Chinese language.

For example, 263 days, 19 hours, 10 minutes and 14 seconds = 263天19小時10分14秒

We don't have spaces and commas between "words". Please add an option to skip those. Sammylau (talk) 20:51, April 11, 2013 (UTC)
 * This can probably be resolved my modifications discussed above about different countdown formats. Not sure if Pecoes got any further with it though.


 * Take a look at this library and tell me if it's possible to format a chinese date with it, please! --


 * I'd suggest a more "universal" way to solve this problem. Many Asian languages doesn't need these spaces and commas too.
 * Add an option in the translation part:


 * Then add more conditions into the output function:


 * Sammylau (talk) 23:33, April 11, 2013 (UTC)


 * I can see how that would work, yes. That's certainly a good suggestion, but it's less universal than the library I suggested above. With that library everybody could format the time how he/she sees fit for their wiki. Check out the request by 452 above as an example. He apparently wants even more flexibility than your suggestion can provide. Now, if I knew he'd be the last one to make such a request, I'd say "I'm terribly sorry, but I cannot accommodate absolutely everybody" and leave it at that. But chances are, he's just the first one to make such a request...


 * Since you obviously have some programming skill, I'd be grateful, if you could take a quick look at that library and tell me, if it's possible to properly format a chinese date with it! --

Simply, yes. The library should fix everything. A little hold back for me is that is you need to explain that in depth to let people know how to format it properly. Sammylau (talk) 07:05, April 12, 2013 (UTC)


 * Yes, I agree. The explanations over there are far too short. It needs more detail. Thanks for testing it though! I'll convert the code. --

Customization
Is it possible to customize the countdown so that you can use the span tags under specific parts? Sort of like  being big and in bold, and the rest are smaller, in italics. Maybe even the option to use D:H:M:S, too. I want to do it but I really don't know how I would be able to pull it off. Is it possible, then? Masatoshino (talk) 16:51, April 29, 2013 (UTC)

Putting it in a template
Hi there... I'm trying to put your code into a template so that I can use it on a page like this:. For some reason, I can't get it to work properly =( If/When you have time, would you mind having a look for me please. Much appreciated http://img255.imageshack.us/img255/6670/squirrel3kk9.gif Wolbee 12:15, July 2, 2013 (UTC)

Can someone help me?
Can someone tell me what code I would use to add months and years to my count down timers?

HurricaneTeen6900 (talk) 21:50, August 11, 2013 (UTC)HurricaneTeen6900HurricaneTeen6900 (talk) 21:50, August 11, 2013 (UTC)

ISSUE: Using the countdown timer as a count up timer
Greeting everyone, I have an issue with the countdown timer in a page of my wiki. I've been using the coundown timer template as a "count up timer", because of the lack of a code for it (and my poor knowledge of programming). [Watch here a view from Google Chrome] The problem is that, in some dates, it appears "FECHA ERRÓNEA" (WRONG DATE). Here is the JS of the countdown. --See ya': http://images1.wikia.nocookie.net/__cb20110901220935/codesah/images/a/ad/Ajente02_Firma.JPG 22:42, September 12, 2013 (UTC)

div Tag Limits Functionality
For a while I was frustrated with the options, such as no-leading-zeros and the various data-end settings not working, and it turned out that the  tag I was using to change the font size is what caused the problem. I just wanted to point out that putting the countdown inside  tags creates such problems, in case anyone else has the issue. --Kelerik (talk) 17:06, January 27, 2014 (UTC)

Support Countdown on wikia mobile display
hi,

would it be possible to make the countdown behave properly on mobile browsers (i.e. in chrome on andriod, the countdown isn't displayed properly). Rlsf (talk) 06:53, March 3, 2014 (UTC)
 * JavaScript is not loaded in the mobile skin (unless you use some hack for it).~Ultimate Supreme  08:44, March 3, 2014 (UTC)

Malay countdown display
Can you put countdown display for Malay? (code:ms) ms: { and: 'dan', second: 'saat', seconds: 'saat', minute: 'minit', minutes: 'minit', hour: 'jam', hours: 'jam', day: 'hari', days: 'hari' }  SNN95 |Talk to me beybeh! 02:25, March 5, 2014 (UTC)


 * Done :) \


 * Thanks!  SNN95 |Talk to me beybeh! 18:50, March 7, 2014 (UTC)

Vietnam countdown display
vi: { and: 'và', second: 'giây', seconds: 'giây', minute: 'phút', minutes: 'phút', hour: 'giờ', hours: 'giờ', day: 'ngày', days: 'ngày' }


 * Added in, sorry about the delay.

Multiple counters on same page
I am using two counters on the same page that count down to different end dates. But when I specify an date-end for one of them, the other ends at the same time. Is there a way to make each counter independent of the other for the end conditions?

Cornbread4 (talk) 13:35, May 23, 2014 (UTC)Cornbread4


 * Have you tried:

Only January 01 2015 00:00:00 until the new year...

Only January 01 2016 00:00:00 until the next new year...
 * The source appears to support this, but I have not tested it. -452 (talk) 13:46, May 23, 2014 (UTC)


 * It removes both times once the first date has passed. I'm trying to think of a way to set them up as unique entries wihout having to embed another page, but no luck so far.
 * Cornbread4 (talk) 14:13, May 25, 2014 (UTC)Cornbread4


 * Oh, I understand what you mean now, sorry.
 * I also see the problem:
 *                c.remove; 
 * "c" is the .countdown span rather than the .countdowndate span - it should probably be changed to :
 *                countdowns[i].node.remove; 
 * For now, you should be able to sidestep the problem by changing "remove" to "stop" which should stop the first countdown while allowing the second to continue.
 * Again, I haven't tested any of this, so this information might be incorrect. -452 (talk) 22:42, May 25, 2014 (UTC)

Countdown Template
I don't know if this is useful to anyone else, but I created a template on the Clash of Clans wiki that makes it a little easier for folks to add countdowns to their pages. I'm happy to include it here if you would want to make it part of the countdown page. It requires this code but defaults a lot of the more popular options. The link is here: w:c:clashofclans:Template:Countdown http://images2.wikia.nocookie.net/__cb20130823072743/spottra/images/thumb/e/ea/Spsig.png/60px-Spsig.png ( talk ) 12:30, May 25, 2014 (UTC-8)

BUG: multiple countdowns on page may throw exception
There appears to be a bug if there are multiple countdowns on a page where an ended (i.e. any behaviour other than to continue counting up) timer is followed by at least one other live timer later on the page. A JS exception will be thrown which kills all subsequent updates for all remaining live timers on the page. This may be related to issue described by Cornbread4 above.

The sequence of events for a page with timers A and B is as follows: Propose a fix whereby end(n) returns a value indicating whether or not that timer should be removed from countdowns instead of simply splicing countdowns. update can splice countdowns to remove any ended timers after the iterator is finished. --Asaba (talk) 19:56, June 15, 2014 (UTC)
 * A and B are initially both ticking down, although A is approaching end
 * On the first update after passing the end time for A, iterate over countdowns = [ A, B ], find that A is ended, and call end(0)
 * end(0) performs appropriate action to end that timer, then removes A from countdowns, leaving countdowns = [ B ], and returns
 * Iterator in update continues to B, and calls end(1) because the array being iterated over is still [ A, B ]
 * end(1) throws an exception as soon as it tries to access countdowns[1]
 * uncaught exception kills update prematurely, and the next tick will not fire


 * Here's a fixed version of the end(n) and update functions:

function end(i) { var c = countdowns[i].node.parent; switch (c.attr('data-end')) { case 'remove': c.remove; return true; case 'stop': output(i, 0); return true; case 'toggle': var toggle = c.attr('data-toggle'); if (toggle && $(toggle).length) { $(toggle).css('display', 'inline'); c.css('display', 'none'); return true; }               break; case 'callback': var callback = c.attr('data-callback'); if (callback && $.isFunction(module[callback])) { output(i, 0); module[callback].call(c); return true; }               break; }       countdowns[i].countup = true; output(i, 0); return false; }   function update  { var now = Date.now; var countdownsToRemove = []; $.each(countdowns.slice(0), function (i, countdown) {           var diff = Math.floor((countdown.date - now) / 1000);            if (diff <= 0 && !countdown.countup) {                if (end(i)) countdownsToRemove.push(i);            } else {                output(i, Math.abs(diff));            }        }); var x;       while((x = countdownsToRemove.pop) != null) { countdowns.splice(x, 1); };       if (countdowns.length) { window.setTimeout(function {                update;            }, 1000); }   }


 * --Asaba (talk) 02:08, June 20, 2014 (UTC)


 * Your explanation of the issue seems sensible, I couldn't see anything in the code that selected more than one timer but this is the first time anyone has noticed the exception. I'll try to test this tomorrow and then hopefully merge it if it works ok.


 * Seems to be working as expected, so I've merged in your fix along with the vietnamese translations posted above some time ago :)

Time/Date Display Format
Would it be possible to display the timer in a customized format? i.e. 10 days, 23:59:59 compared to the default 10 days, 23 hours, 59 minutes, 59 seconds.

That's just one example. There's tons of formatting for times & dates though... --Lloyd Dunamis (talk) 06:05, June 17, 2014 (UTC)


 * It's something that's been oft requested above. It looks like Pecoes was planning on doing something like that, but he disappeared some time ago. I'm only doing bugfixes and i18n updates for the time being, but if someone wants to have a go at implementing it they're free to :)

Not working/nothing displayed
I can't get this to work over on the homepage of w:c:findingcarter. I implemented the JS where needs be, and I've tried and tried with the timezone and everything else&hellip; I can't even get it to work without being edited. &mdash;Liz 03:52, April 9, 2015 (UTC)


 * Remove the "var " from in front of "countdownTimer.translations" on line 8. You cannot (and don't need to) declare an object property using the "var" keyword. — Foodbandlt (talk) 05:03, April 9, 2015 (UTC)


 * Actually, that entire statement doesn't need to be there unless you want to override the words that are displayed. At the moment you have it set to use the default. So the only thing you need in your Common.js is the importArticles statement. — Foodbandlt (talk) 05:09, April 9, 2015 (UTC)


 * I removed it; I forgot I had it there. >.> Thanks. &mdash;Liz 13:13, April 9, 2015 (UTC)

Multiple Countdown clocks might display the end message if one of them ended earlier.
My Usage Code in a template:

Jianmingyong (talk) 14:04, June 15, 2015 (UTC)

Broken
When I try to use this script, I get the following error: Uncaught TypeError: Cannot read property 'split' of undefined

<font COLOR="#04B404">Rider ranger47  02:35, August 2, 2015 (UTC)


 * It is working on our wiki, just tested. Can you show where it happens? The countdown code itself doesn't contain any "split", so it can be another script causing the problem. - Tjcool007 (Talk) 09:12, August 2, 2015 (UTC)


 * It turns out it was a different script. Sorry for the confusion. <font COLOR="#04B404">Rider ranger47  17:57, August 2, 2015 (UTC)

New translations
Hello! Here are the translations for Arabic, Greek and Romanian. I would have added them myself, but I am getting this error: <span style="font-weight:normal;color:rgb(169,16,0);font-size:12px;line-height:normal;">You can not perform this action right now. Please try again in a few minutes, or  contact Wikia<span style="font-weight:normal;color:rgb(169,16,0);font-size:12px;line-height:normal;"> if you are having difficulties.

Here they are: --Star  Warden--  18:02, October 31, 2015 (UTC)

It doesn't show anything
I need help to install the countdown on my wiki, i left the next code on the common.js page

and then used to use the countdown on a template

Only January 01 2016 00:00:00 until the new year...

but it doesn't show anything, can anyone please tell me what is missing or help me to put it correctly on my wiki? --EB97-217 (talk) 11:04, November 26, 2015 (UTC)

~Curiouscrab (talk) 14:43, November 26, 2015 (UTC)
 * Did you have " Only January 01 2016 00:00:00 until the new year... "?
 * Yes, i did and still nothing :(


 * In w:c:es.how-to-get-away-with-murder:mediawiki:common.js, remove the first line ("MediaWiki:Common.js"), so that the import actually works. slyst (talk) 05:49, November 27, 2015 (UTC)
 * Thanks, i removed and still nothing. Can you help me, please? I have these two templates w:c:es.how-to-get-away-with-murder.wikia.com/wiki/Plantilla:Contador, w:c:es.how-to-get-away-with-murder.wikia.com/wiki/Plantilla:NEcountdown made for the countdown but i don't know what's the problem.

~Curiouscrab (talk) 20:55, November 29, 2015 (UTC)
 * It seems to be a loading issue. If you copy the code from Countdown/code.js and paste it in the console and run it, it works just fine. I searched the imports and it isn't be imported anywhere. I checked the sources folder with the developer tools, and it's definitely not there. Try this:
 * Thank you so much! :D EB97-217 (talk) 05:54, November 30, 2015 (UTC)


 * It works fine now, but nothing is loaded on your part because you've neither submitted your edit for review nor you're in test mode. You would need to submit the latest revision to make the js public. Meanwhile, you can enter the test mode to see the countdown working; the button to enter test mode is also on the same page. - slyst (talk) 02:27, November 30, 2015 (UTC)
 * Thank you so much, i submitted my edit for review now and now that i saw the test mode i could make some editing into my template, now i have to wait. Do you know how much takes to be accepted or denied, and in case of being denied what can i do? EB97-217 (talk) 05:54, November 30, 2015 (UTC)
 * Imports from the dev wiki are considered safe, so you don't have to worry about the revision getting denied. - slyst (talk) 07:46, November 30, 2015 (UTC)