TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,991
  • Total Topics: 21,323
  • Online today: 290
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 282
  • Total: 283
  • Skhilled

X-mas Countdown Script - Need Language Strings

Started by Xarcell, December 12, 2007, 09:27:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xarcell

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.

Dragooon

Ahh Did you used Singe quote or double quote for echo?

Rumbaar

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.

This website is proudly hosted on Crocweb Cloud Website Hosting.