...

View Full Version : Need "image" web counter



Nenad91
07-03-2007, 01:58 PM
Hi, I have some problems. I need new web counter for my site. I've put one script to my site (for clock). It displays images instead of strings. So, if it is 12:25pm, it seems like that:http://www.freewebs.com/elektronika91/c1.gifhttp://www.freewebs.com/elektronika91/c2.gifhttp://www.freewebs.com/elektronika91/colon.gifhttp://www.freewebs.com/elektronika91/c2.gifhttp://www.freewebs.com/elektronika91/c5.gifhttp://www.freewebs.com/elektronika91/cpm.gif

This is that script (for clock):
var imageclock=new Object()
//Enter path to clock digit images here, in order of 0-9, then "am/pm", then colon image:
imageclock.digits=["c0.gif", "c1.gif", "c2.gif", "c3.gif", "c4.gif", "c5.gif", "c6.gif", "c7.gif", "c8.gif", "c9.gif", "cam.gif", "cpm.gif", "colon.gif"] imageclock.instances=0
var preloadimages=[]
for (var i=0; i<imageclock.digits.length; i++){ //preload images
preloadimages[i]=new Image()
preloadimages[i].src=imageclock.digits[i]
}

imageclock.imageHTML=function(timestring){ //return timestring (ie: 1:56:38) into string of images instead
var sections=timestring.split(":")
if (sections[0]=="0") //If hour field is 0 (aka 12 AM)
sections[0]="12"
else if (sections[0]>=13)
sections[0]=sections[0]-12+""
for (var i=0; i<sections.length; i++){
if (sections[i].length==1)
sections[i]='<img src="'+imageclock.digits[0]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i])]+'" />'
else
sections[i]='<img src="'+imageclock.digits[parseInt(sections[i].charAt(0))]+'" />'+'<img src="'+imageclock.digits[parseInt(sections[i].charAt(1))]+'" />'
}
return sections[0]+'<img src="'+imageclock.digits[12]+'" />'+sections[1]+'<img src="'+imageclock.digits[12]+'" />'+sections[2]
}

imageclock.display=function(){
var clockinstance=this
this.spanid="clockspan"+(imageclock.instances++)
document.write('<span id="'+this.spanid+'"></span>')
this.update()
setInterval(function(){clockinstance.update()}, 1000)
}

imageclock.display.prototype.update=function(){
var dateobj=new Date()
var currenttime=dateobj.getHours()+":"+dateobj.getMinutes()+":"+dateobj.getSeconds() //create time string
var currenttimeHTML=imageclock.imageHTML(currenttime)+'<img src="'+((dateobj.getHours()>=12)? imageclock.digits[11] : imageclock.digits[10])+'" />'
document.getElementById(this.spanid).innerHTML=currenttimeHTML
}

Can someone write how to use this for making "image" web counter. So, how to use var. image in web counter.

koyama
07-03-2007, 11:04 PM
Can someone write how to use this for making "image" web counter. So, how to use var. image in web counter.
It's probably not as simple as just exchanging the numbers.

Your clock is implemented with JavaScript while your counter probably relies on server-side scripting. You will probably need to edit the counter-script in order to get what you want.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum