TinyPortal
Development => Support => Topic started by: Xarcell on December 12, 2007, 09:27:08 PM
I been trying to get my xmas theme approved at SMF, but it's been a bit of a hassle.
I need to alter my javascript for the countdown so that it uses language strings. This is beyond my coding skills. Any help?
I have this in my ThemeStrings.english.php:
$txt['xmas_only'] = 'There are only ';
$txt['xmas_left'] = 'days ';
$txt['xmas_hours'] = 'hours and ';
$txt['xmas_min'] = 'minutes left Until December 25th 2007 (Christmas)';This is the part I cannot get to work, changing the code to use language strings:
<script type="text/javascript">
today = new Date();
BigDay = new Date("December 25, 2007")
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
document.write("There are only " + daysLeft + " days " + hrsLeft +" hours and " + minsLeft + " minutes left Until December 25th 2007 (Christmas)");
</script>They also said
QuoteChange the the year for christmas javascript countdown as variable instead of a harcoded year because after
December 25, 2007 the function will not work correctly and will look odd if people still have the theme up. Maybe replace the year with the next year's date after december 25 of this year.
Obviously the user will need to change it manually each year. Like I said, it's beyond my skills to provide what they ask.
Ahh Did you used Singe quote or double quote for echo?
Have you tried defining the txt strings as a var and calling that in the javascript
var smf_c_day = "', $txt['xmas_left'], '";
Than call that var in the write
" + daysLeft + " smf_c_day " + hrsLeft
As you can see I have no clue either, but hopefully you'll work something out. That is why I used a third party php countdown file in for my Christmas countdown display. Though I wasn't every pulled up for language strings.