hi,
The idea was given by crip - however the script he showed me had random images. I was unable to pull that off but using a free "snow applet" script from the net and the countdown script from Dynamic Drive this is what came about.
Demo can be found here just look on the left (http://goofy-goobers.com/forum/index.php)
Step 1:
Download the file attached at the bottom of this post unzip and upload the 3 files inside to your forum root (forum root is where you find the folders Themes, Sources, etc etc)
Step 2:
To install this create a PHP block and add this line in it:
include "123.php";
Customization
- You can change the image in the PHP file in the line
<param name="grph" value="christmas25.jpg">
- you can set the height and width of the image in this line, the applet will resize accordingly so this can be used for center as well as side blocks if needed, just adjust the size.
<applet code="alcsnow.class" align="baseline" width="130" height="147" style="border: 6px ridge #008080">
Also I have included a 2nd zip file called more_images.zip containing some other images inside which you could use - just dont forget to fix the width and height according to image dimensions if u use any other images
enjoy:up:
nice one Aku, I tried it in its own folder but it says cant find alcsnow.class, I have this in the block include "count/123.php"; count being the folder
Your fantastic Aku..
it looks great, I knew you could do it....Thanks :D
Ant it purty. ;)
You are welcome and Thanks :D I also added a larger center block for people who want it as a center block
Its on the demo page and the zip is linked there as well :up:
it works, but for some reason i can click any of the links in the forum when i have activated this. It just ask me to download the index.php file when i try to browse the site.
Deleted the block again from the DB and every thing works fine again ???
thats strange - its working perfectly for me on the default theme
but i haven't tried it with custom themes
Eithrways it shouldn't do that at all - very strange
am i doing something wrong with the code cause i have a parse error instead of the countdown. :(
can u post the error code here
and also a link to ur site? :up:
well since u didnt return..ill leave this for u
If ur getting a parse error then try this method - its basically putting the entire code from the PHP file as a script in a block
After u upload the images as explained in the 1st post
Create a script block and put the code in there
<head>
<style style="text/css">
.lcdstyle{ /*Example CSS to create LCD countdown look*/
background-color:black;
color:yellow;
font: bold 18px MS Sans Serif;
padding: 3px;
}
.lcdstyle sup{ /*Example CSS to create LCD countdown look*/
font-size: 80%
}
</style>
<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 <br>"+arguments[2]+" minutes "+arguments[3]+" seconds<br> left until Christmas"
}
else{ //else if target date/time met
var displaystring="Future date is here!"
}
return displaystring
}
function formatresults2(){
if (this.timesup==false){ //if target date/time not yet met
var displaystring="<span class='lcdstyle'>"+arguments[0]+" <sup>days</sup> "+arguments[1]+" <sup>hours</sup> "+arguments[2]+" <sup>minutes</sup> "+arguments[3]+" <sup>seconds</sup></span> left until this Christmas"
}
else{ //else if target date/time met
var displaystring="" //Dont display any text
alert("Christmas is here!") //Instead, perform a custom alert
}
return displaystring
}
</script>
</head>
<div align="center">
<table border="0" id="table1" cellpadding="0" style="border-collapse: collapse">
<tr><td bgcolor="#99CCFF"><center><font size="1" face="Verdana">Christmas Countdown</font></center></td></tr>
<tr><td bgcolor="#99CCFF">
<applet code="alcsnow.class" align="baseline" width="130" height="147" style="border: 6px ridge #008080">
<param name="grph" value="christmas25.jpg">
<param name="snows" value="700">
<param name="threadsleep" value="50"></applet></center>
</td></tr>
<tr><td bgcolor="#99CCFF"><center><font size="1" face="Verdana">
<div id="countdowncontainer"></div>
</font></center>
<script type="text/javascript">
var futuredate=new cdtime("countdowncontainer", "December 25, 2006 00:00:00")
futuredate.displaycountdown("days", formatresults)
</script>
</font>
</td></tr>
</table></div>
sorry I didnt return but im in England so I went to bed. :) I will give it a go when I get back in from work tonight, thanx :)
Couldnt wait have just put it up and it works like a dream, was looking at the code and looks like if you just change the date your counting down to and the image and resize to fit the image you can have it as a countdown to any date. Great will readjust to fit in with all the holidays for college so students now how long to holiday breaks. :)
very nice code ;)
Quote from: G6 on December 13, 2006, 05:45:46 AM
it works, but for some reason i can click any of the links in the forum when i have activated this. It just ask me to download the index.php file when i try to browse the site.
Deleted the block again from the DB and every thing works fine again ???
That's JavaApplets..they act that way.. & Alt+F4 won't colse the window either, you gotta click the close button..
Thanks a lot. I love it. :D
http://rickyforever.com/
Crip whats that? dont tell me this script is buggy?!! :o
Or was that due to something else?
Quote from: crip on December 16, 2006, 05:35:13 PM
http://rickyforever.com/
Thanks Crip, I haven't seen it yet, didn't check it yesterday. A few days ago the forum (that was only my test forum though) but I had to reinstall everything. :( And now the website itself. :tickedoff: What can I do to prevent it? Should I report it to my host? ???
Quote from: Aku on December 17, 2006, 01:16:40 AM
Crip whats that? dont tell me this script is buggy?!! :o
Or was that due to something else?
Not your script Aku, I was going to checkout RML's site and thats what I saw..it's been Hacked?? or it looks like it has..
Quote from: RML on December 17, 2006, 08:50:23 AM
Quote from: crip on December 16, 2006, 05:35:13 PM
http://rickyforever.com/
Thanks Crip, I haven't seen it yet, didn't check it yesterday. A few days ago the forum (that was only my test forum though) but I had to reinstall everything. :( And now the website itself. :tickedoff: What can I do to prevent it? Should I report it to my host? ???
RML I do not know what you should or shouldn't do or report, but just for good luck do not use your Shoutbox at all, deactivate it until we do some investigating..see what I'm saying?
Yes, I see. Thanks Crip, I'll do that with the shoutbox.
By the way for the Big Xmas block, just download the file linked to under the block on the demo page
upload the files to your forum root
then put this in a PHP block:
include "12x.php";
thats it :D
aku
works great, thanks a lot!!
Sweet.... 8)
thanks
Aku... thanks a lot for this block but Xmas is finished already. Do you have something for New year? :)
well this block can be configured for new year very easily
do this:
open up the PHP file in the package
Then find:
<tr><td bgcolor="#99CCFF"><center><font size="1" face="Verdana">Christmas Countdown</font></center></td></tr>
change the christmas to new year
find:
<param name="grph" value="christmas25.jpg">
change over for a new year image of ur choice
find:
var futuredate=new cdtime("countdowncontainer", "December 25, 2006 00:00:00")
change the date to December 21, 2006 23:59:59
so that should be 1 sec b4 new year or u can set it 1 min after if u want
and thenfinally find:
function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours <br>"+arguments[2]+" minutes "+arguments[3]+" seconds<br> left until Christmas"
}
and change the left until Christmas to left until new year
and thats all really
countdown not showing only "Future date is here!" any ideas?
Quote from: gmlong on October 28, 2007, 09:01:16 PM
countdown not showing only "Future date is here!" any ideas?
Have you changed the following code to be this year?
var futuredate=new cdtime("countdowncontainer", "December 25, 2006 00:00:00")
hi
dont mean to sound thick but im new to tp but were do i upload the files to?
themes and layouts? or packages?
ive never done anything like this before and ive already broke my baord with "tinkering"
incase your wondering a friend set up my tp for me so i havent a clue.
Quote from: Gobo on December 17, 2006, 02:41:27 PM
By the way for the Big Xmas block, just download the file linked to under the block on the demo page
upload the files to your forum root
then put this in a PHP block:
include "12x.php";
thats it :D
aku
Forum Root.. the public_html folder.
Thanks, this works nice. :coolsmiley:
Quote from: Gobo on December 26, 2006, 06:45:39 PM
well this block can be configured for new year very easily
do this:
open up the PHP file in the package
Then find:
<tr><td bgcolor="#99CCFF"><center><font size="1" face="Verdana">Christmas Countdown</font></center></td></tr>
change the christmas to new year
find:
<param name="grph" value="christmas25.jpg">
change over for a new year image of ur choice
find:
var futuredate=new cdtime("countdowncontainer", "December 25, 2006 00:00:00")
change the date to December 21, 2006 23:59:59
so that should be 1 sec b4 new year or u can set it 1 min after if u want
and thenfinally find:
function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours <br>"+arguments[2]+" minutes "+arguments[3]+" seconds<br> left until Christmas"
}
and change the left until Christmas to left until new year
and thats all really
i did this and all works well apart from the fact the snow is still falling.
is there a way to turn this off ?
regards
Dave