Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need "image" web counter

    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:

    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.
    Last edited by Nenad91; 07-03-2007 at 03:05 PM.

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Nenad91 View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •