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

Recent

Welcome to TinyPortal. Please login or sign up.

February 13, 2025, 06:59:29 AM

Login with username, password and session length
Members
  • Total Members: 3,946
  • Latest: Sparo
Stats
  • Total Posts: 195,471
  • Total Topics: 21,258
  • Online today: 115
  • Online ever: 6,457 (November 30, 2024, 02:40:09 PM)
Users Online
  • Users: 1
  • Guests: 73
  • Total: 74
  • @rjen

countdown

Started by eltonave, February 22, 2007, 10:29:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bloc

Countdowns can be interesting..as a expansion on the calendar I assume?

brianjw

This is also a feature on vBulletin. You modify it in your profile and what to say on the day of your event and what to say after when its over. Then it displayed right under your signature, but I would personally like it in the user collumn where the avatar is and the hero member stuff is ;)

Brianjw

PS: Like the idea, this would more likely be a sepret mod unless Bloc says so. In that case you should put that down at smf :D

eltonave

Srry I havnt replied, been busy

Well I cant really think where to put this on a page but maybe just a block  on either L,R,C.  Like I said before, On the AI theme theres a count down for the holidays. On Valetines day hearts and stuff fall and header  turns into  a HAPPY VALENTINES DAY , so in this case something where once the event takes place like a birthday it will say Happy Birthday To so and so ,,,, Happy Aniversarry to xxxxx and xxxxx and so on.

EI: 2Days and 21 Hrs Until Blocs Birthday

And after 2 days and 21 hrs it will say Happy Birthday Bloc

bloc

ah, sort of reminder type of block then? It has a time-span, a content during countdown and another content after countdown? The actual message could be from the calendar or simply a custom made one.

Hm, sounds intriguing this one.

eltonave

I searched the Snippets and found one but it doesnt seem to work for me .It has room for improvements, if anyone can get it to work or improve it let me know .

It can be found here.     

http://www.tinyportal.net/index.php?topic=11442.0

brianjw

Oh! I use that on my website. I used that and it works perfectly. :)
I will give you my source...
Download these files
Follow some of the instructions in the topic above.
Code (my source-put in scriptblock) Select

<head>
<script type="text/javascript">

/***********************************************
* Dynamic Countdown script- Ã,© Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function cdtime(container, targetdate){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.currentTime=new Date()
this.targetdate=new Date(targetdate)
this.timesup=false
this.updateTime()
}

cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}

cdtime.prototype.showresults=function(){
var thisobj=this


var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdtime.displaycountdown()
//Use arguments[0] to access "Days" left
//Use arguments[1] to access "Hours" left
//Use arguments[2] to access "Minutes" left
//Use arguments[3] to access "Seconds" left

//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc

function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds left until <b>DeeAnns Birthday!</b>"
}
else{ //else if target date/time met
var displaystring="<b>DeeAnn's</b> bday is here!"
}
return displaystring
}

function formatresults2(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds left until <b>Independence Day</b>"
}
else{ //else if target date/time met
var displaystring="<b>Independence Day</b> is here!"
}
return displaystring
}

function formatresults3(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds left until <b>Tuxie's Birthday</b>"
}
else{ //else if target date/time met
var displaystring="<b>Tuxie's Birthday</b> is here!"
}
return displaystring
}

function formatresults4(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds left until <b>Christmas</b>"
}
else{ //else if target date/time met
var displaystring="<b>Christmas</b> is here!"
}
return displaystring
}
</script>
</head>


<table border="0" width="100%" id="table1" cellpadding="0" style="border-collapse: collapse">
<tr>
<td width="360">
<img border="0" src="imdatesmain1.jpg" width="360" height="165"></td>
<td background="impdates_strip.gif"><font size="1" color="#FFFFFF" face="Verdana">
<div id="countdowncontainer"></div>
<hr />
<div id="countdowncontainer1"></div>
<hr />
<div id="countdowncontainer3"></div>
<hr />
<div id="countdowncontainer4"></div>
</font></td>
</tr>
</table>


<script type="text/javascript">
var futuredate=new cdtime("countdowncontainer", "January 25, 2007 0:00:00")
futuredate.displaycountdown("days", formatresults)
var futuredate=new cdtime("countdowncontainer1", "July 4, 2007 0:00:00")
futuredate.displaycountdown("days", formatresults2)
var futuredate=new cdtime("countdowncontainer3", "July 18, 2007 0:00:00")
futuredate.displaycountdown("days", formatresults3)
var futuredate=new cdtime("countdowncontainer4", "December 25, 2007 0:00:00")
futuredate.displaycountdown("days", formatresults4)

var currentyear=new Date().getFullYear()
//dynamically get this date' year value. If date already passed, then year=current year+1
var thischristmasyear=(new Date().getMonth()>=11 && new Date().getDate()>25)? currentyear+1 : currentyear
var christmas=new cdtime("countdowncontainer2", "December 25, "+thischristmasyear+" 0:0:00")
christmas.displaycountdown("days", formatresultsx)

</script>

Replace the background images with one of the images in the downloads if you want. Replace the event names and date and times for them :) Even add more :D

REMEMBER SCRIPTBLOCK!
Brianjw