Pages

Friday, May 20, 2011

Online EyeQ Test


Having online games on your site add to your visitors pleasure and tempt them to come back time and again. This simple to configure online javascript game will surely increase your traffic.
Is your EyeQ is as high as Einstein's IQ. Play EyeQ online or download it for free. Copy-paste installation. IE 5 or higher.
Step 1: Paste the following code below the <body> tag of your webpage
<script>
// set horizontal distance to the left margin of browser window (pixels)
 var gameleft=0;
// set vertical distance to the left margin of browser window (pixels)
 var gametop=10; </script> <script
src="eyeqdown.js"></script>
Step 2: Go to the top of the script code and configure the position of EyeQ.
Step 3: Download the zip file 'eyeq.zip'. Extract it and place all the files into the same folder as your webpage. Or copy past the code from below
var floatingspeed=2
var trynumbernew=0
var trynumberold=0
var skinwidth=228
var skinheight=150
var tempo=20
var guessmodus=false
var timer
var timetimer
var timerwrong
var timmercorrect
var timerstart
var timecolor="000000"
var gamemaxseconds=30
var stopit=false
var starttime
var nowtime=0
var penalty=0
var penaltyseconds=1
var dotsmax=16
var dotsrandom=5
var correctdots=dotsrandom+1
var correctanswers=0
var stepx=new Array()
var stepy=new Array()
for (i=0;i<=dotsmax;i++) {
            stepx[i]=randomspeed(floatingspeed)
            stepy[i]=randomspeed(floatingspeed)
}
var marginleft=37
var marginright=109
var margintop=50
var marginbottom=105

var spancontent=new Array()
var imgpreload=new Image
imgpreload.src="dot.gif"

for (i=0;i<=dotsmax;i++) {
            spancontent[i]="<img src='dot.gif'>"
}

function positiongame() {
            if (document.all) {
                        document.all.roof.style.posLeft=gameleft
                        document.all.roof.style.posTop=gametop
                        document.all.quickeyeskin.style.visibility="visible"
            }
}

function guess(thisno) {
            if (nowtime<gamemaxseconds && guessmodus) {
                        guessmodus=false
                        if (thisno==correctdots) {          
                                    correctanswers++
                                    var resultbarwidth=correctanswers*4
                                    resultbar.innerHTML="<table border=0 cellpadding=0 cellspacing=0><tr valign=top><td align=left><img src=\"transparent.gif\" width="+resultbarwidth+" height=5></td></tr></table>"
                                    resultboard.innerHTML="<table width=80 height=62 border=0 cellpadding=2 cellspacing=0 bgcolor=green><tr valign=middle><td align=center><font face=Arial size=1 color=white>CORRECT</font></td></tr></table>"
                                    document.all.resultboard.style.visibility="visible"
                                    trynumberold=trynumbernew
                                    clearTimeout(timerwrong)
                                    timercorrect=setTimeout("nextguess()",500)
                        }
                        else {
                                    penaltyseconds++
                                    resultboard.innerHTML="<table width=80 height=62 border=0 cellpadding=2 cellspacing=0 bgcolor=red><tr valign=middle><td align=center><font face=Arial size=1 color=white>WRONG.<br>Correct: "+correctdots+"<br>Penalty: "+penaltyseconds+" sec.</font></td></tr></table>"
                                    document.all.resultboard.style.visibility="visible"
                                    penalty=(penaltyseconds*1000)
                                    trynumberold=trynumbernew
                                    timerwrong=setTimeout("nextguess()",penalty)
                        }
            }
}

function startgame() {
            trynumbernew++
            stopit=false
            guessmodus=true
            timecolor="000000"
            hideresultboard()
    startnewtime()
            setdots()
}

function stopgame() {
            clearTimeout(timerstart)
            stopit=true
            penalty=1
            resultbar.innerHTML=""
            resultboard.innerHTML="<table width=80 height=62 border=0 cellpadding=5 cellspacing=0><tr valign=middle><td align=center bgcolor=black><font face=Arial size=1 color=white>New game</font></td></tr></table>"
            document.all.resultboard.style.visibility="visible"
            timesign.innerHTML="<font size=1 face=Arial color=black>30.00</font>"
            document.all.timesign.style.visibility="visible"
            guessmodus=false
            nowtime=0
            penaltyseconds=1
            correctanswers=0
            timerstart=setTimeout("startgame()",800)
}

function nextguess() {
            if (nowtime<gamemaxseconds && trynumbernew==trynumberold) {
                        guessmodus=true
                        hideresultboard()
                        setdots()
            }
}

function hideresultboard() {
            document.all.resultboard.style.visibility="hidden"
}

function startnewtime() {
            starttime= new Date()
            starttime=starttime.getTime()
    checktime()
}

function setdots() {
            dotsrandom=randommaker(dotsmax)
            correctdots=dotsrandom+1
                        for (i=0;i<=dotsmax;i++) {            
                                    var thisspan = eval("document.all.d"+(i)+".style")
                                    thisspan.visibility="hidden"
                        }
                        for (i=0;i<=dotsrandom;i++) {            
                                    var thisspan = eval("document.all.d"+i)
                                    thisspan.innerHTML=spancontent[i]
                                    var thisspan = eval("document.all.d"+(i)+".style")
                                    var randomposleft=marginright-marginleft
                                    var randompostop=marginbottom-margintop
                                    thisspan.posLeft=randommaker(randomposleft)+marginleft
                                    thisspan.posTop=randommaker(randompostop)+margintop
                                    thisspan.visibility="visible"
                        }
                        checkmovement()
}

function randomspeed(range) {             
            rand=Math.floor(range*Math.random())
            if (rand==0) {rand=Math.ceil(range/2)}
    return rand
}

function randommaker(range) {              
            var randomposition=Math.floor(range*Math.random())
    return randomposition
}

function checkmovement() {
            if (document.all && guessmodus && nowtime<gamemaxseconds  && stopit==false) {
                        checkposition()
                        movepictures()
            timer=setTimeout("checkmovement()",tempo)
            }
            else {
                        clearTimeout(timer)
                        for (i=0;i<=dotsmax;i++) {            
                                    var thisspan = eval("document.all.d"+(i)+".style")
                                    thisspan.visibility="hidden"
                                    thisspan.posLeft=marginleft
                                    thisspan.posTop=margintop
                        }
            }
}

function movepictures() {
            for (i=0;i<=dotsrandom;i++) { 
            var thisspan=eval("document.all.d"+(i)+".style")
            thisspan.posLeft+=stepx[i]
                        thisspan.posTop+=stepy[i]
    }
}

function checkposition() {
            for (i=0;i<=dotsrandom;i++) {            
                        var thisspan=eval("document.all.d"+i+".style")               
                        if (thisspan.posLeft>marginright) {
                                    thisspan.posLeft-=Math.abs(stepx[i]+1)
                                    stepx[i]=randomspeed(floatingspeed)*-1           
                        }
                        if (thisspan.posLeft<marginleft) {
                                    thisspan.posLeft+=Math.abs(stepx[i])
                                    stepx[i]=randomspeed(floatingspeed)                           
                        }          
                        if (thisspan.posTop>marginbottom) {
                                    thisspan.posTop-=Math.abs(stepy[i])
                                    stepy[i]=randomspeed(floatingspeed)*-1
                        }
                        if (thisspan.posTop<margintop) {
                                    thisspan.posTop+=Math.abs(stepy[i])
                                    stepy[i]=randomspeed(floatingspeed)
                        }
            }
}

function checktime() {
    if (nowtime<gamemaxseconds && stopit==false) {
                nowtime=new Date()
                nowtime=nowtime.getTime()
        nowtime=(nowtime-starttime)/1000
                        var countdown=gamemaxseconds-nowtime
                        countdown=Math.floor(countdown*100)/100
                        if (countdown<0) {countdown=0}
        timesign.innerHTML="<font size=1 face=Arial color="+timecolor+">"+countdown+"</font>"
        timetimer=setTimeout("checktime()",100)
    }
            else if (stopit==true) {
                        clearTimeout(timetimer)
                        for (i=0;i<=dotsmax;i++) {            
                                    var thisspan = eval("document.all.d"+(i)+".style")
                                    thisspan.visibility="hidden"
                        }
            }
    else {
        clearTimeout(timetimer)
                        endgame()
    }
}

function endgame() {
            timecolor="000000"
            if (correctanswers<=5) {
                        resultboard.innerHTML="<table width=80 height=132 border=0 cellpadding=5 cellspacing=0><tr valign=middle><td align=center bgcolor=red><font face=Arial size=1 color=white>Game over.<br>Correct: "+correctanswers+"<br><br>Not good enough for our hall of fame<br><br>Try again.</font></td></tr></table>"
                        document.all.resultboard.style.visibility="visible"
                        timesign.innerHTML=""
            }
            else {
                        resultboard.innerHTML="<table width=80 height=132 border=0 cellpadding=5 cellspacing=0><tr valign=middle><td align=center bgcolor=red><font face=Arial size=1 color=white>Game over.<br>Correct answers: "+correctanswers+"</font></td></tr></table>"
                        document.all.resultboard.style.visibility="visible"
                        timesign.innerHTML=""
                        pophalloffame()
            }
}

function pophalloffame() {
                        var popup=window.open("", "hall", "status=no,location=no,toolbar=no,menubar=no,resizable=no,scrollbars=no,width=235,height=180,top=100,left=210")
                        popup.document.writeln("<HTML><HEAD><TITLE>HALL OF FAME</TITLE></HEAD><BODY>")
                        popup.document.writeln("<table border=0 cellpadding=2 cellspacing=0 width=210>")
           
                        popup.document.writeln("<tr><td bgcolor=000000>")
            popup.document.writeln("<font face=Verdana size=1 color=white><strong>Cool Prizes for EyeQ Cracks</strong></font>")
            popup.document.writeln("</td></tr>")
                       
                        popup.document.writeln("<tr><td><br></td></tr>")
           
                        popup.document.writeln("<tr><td><font face=Verdana size=1 color=black>Add your top results to our realtime Hall of Fame.<br><br><a href=\"http://www.24fun.com/cgi-bin/eyeq.pl\" target=\"_blank\"><strong><font face=Verdana size=1 color=black>Click here.</font></strong></a>")
                        popup.document.writeln("</td></tr></table>")
                        popup.document.writeln("</BODY></HTML>")
                        popup.document.close()
}

function ov(thisleft,thistop) {
            document.all.l.style.posLeft=thisleft
            document.all.l.style.posTop=thistop
            document.all.r.style.posLeft=thisleft+17
            document.all.r.style.posTop=thistop
            document.all.t.style.posLeft=thisleft
            document.all.t.style.posTop=thistop
            document.all.b.style.posLeft=thisleft
            document.all.b.style.posTop=thistop+12
}

function ou() {
            document.all.l.style.posLeft=0
            document.all.l.style.posTop=0
            document.all.r.style.posLeft=0
            document.all.r.style.posTop=0
            document.all.t.style.posLeft=0
            document.all.t.style.posTop=0
            document.all.b.style.posLeft=0
            document.all.b.style.posTop=0
}



if (document.all) {
            document.write("<div id=\"roof\" style=\"position:absolute;left:"+gameleft+"px;top:"+gametop+"px\">")
            document.write("<div id=\"quickeyeskin\" style=\"position:absolute;visibility:hidden;left:0px;top:0px\">")
            document.write("<IMG SRC=\"skin.gif\" USEMAP=\"#skin\" BORDER=0>")
            document.write("<MAP NAME=\"skin\">")
            document.write("<AREA SHAPE=RECT COORDS=\"34,115,51,127\" HREF=\"javascript:guess('1')\" onMouseOver=\"ov(34,115)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"55,115,72,127\" HREF=\"javascript:guess('2')\" onMouseOver=\"ov(55,115)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"76,115,93,127\" HREF=\"javascript:guess('3')\" onMouseOver=\"ov(76,115)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"97,115,114,127\" HREF=\"javascript:guess('4')\" onMouseOver=\"ov(97,115)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"34,132,51,144\" HREF=\"javascript:guess('5')\" onMouseOver=\"ov(34,132)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"55,132,72,144\" HREF=\"javascript:guess('6')\" onMouseOver=\"ov(55,132)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"76,132,92,143\" HREF=\"javascript:guess('7')\" onMouseOver=\"ov(76,132)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"97,132,113,143\" HREF=\"javascript:guess('8')\" onMouseOver=\"ov(97,132)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"34,149,51,161\" HREF=\"javascript:guess('9')\" onMouseOver=\"ov(34,149)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"55,149,72,160\" HREF=\"javascript:guess('10')\" onMouseOver=\"ov(55,149)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"77,149,92,161\" HREF=\"javascript:guess('11')\" onMouseOver=\"ov(76,149)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"97,149,114,161\" HREF=\"javascript:guess('12')\" onMouseOver=\"ov(97,149)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"34,166,51,178\" HREF=\"javascript:guess('13')\" onMouseOver=\"ov(34,166)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"55,166,72,178\" HREF=\"javascript:guess('14')\" onMouseOver=\"ov(55,166)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"77,166,93,178\" HREF=\"javascript:guess('15')\" onMouseOver=\"ov(76,166)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"98,166,113,178\" HREF=\"javascript:guess('16')\" onMouseOver=\"ov(97,166)\" onMouseOut=\"ou()\">")
            document.write("<AREA SHAPE=RECT COORDS=\"76,184,113,194\" HREF=\"javascript:stopgame()\">")
            document.write("</MAP>")
            document.write("</div>")

            for (i=0;i<=dotsmax;i++) {
                        document.write("<div id=\"d"+i+"\" style=\"position:absolute;left:0px;top:0px\"><img src=\"dot.gif\"></div>")
            }
           
            document.write("<div id=\"resultboard\" style=\"position:absolute;left:35px;top:48px\"><table width=80 height=60 border=0 cellpadding=5 cellspacing=0><tr valign=middle><td align=center><font face=Arial size=1 color=000000>Click start and guess the number of dots.<br>time: 30 sec.</font></td></tr></table></div>")

            document.write("<div id=\"resultbar\" style=\"position:absolute;left:35px;top:41px\"></div>")
           
            document.write("<div id=\"resultbarskin\" style=\"position:absolute;left:35px;top:33px\"><img src=\"resultbarskin.gif\"></div>")

            document.write("<div id=\"timesign\" style=\"position:absolute;visibility:visible;left:39px;top:185px;\"></div>")

            document.write("<div id=\"l\" style=\"position:absolute;left:0px;top:0px;\"><table cellpadding=0 cellspacing=0 border=0><tr><img src=\"white.gif\" height=13 width=1><td></td></tr></table></div>")
            document.write("<div id=\"r\" style=\"position:absolute;left:0px;top:0px;\"><table cellpadding=0 cellspacing=0 border=0><tr><img src=\"white.gif\" height=13 width=1><td></td></tr></table></div>")
            document.write("<div id=\"t\" style=\"position:absolute;left:0px;top:0px;\"><table cellpadding=0 cellspacing=0 border=0><tr><img src=\"white.gif\" height=1 width=18><td></td></tr></table></div>")
            document.write("<div id=\"b\" style=\"position:absolute;left:0px;top:0px;\"><table cellpadding=0 cellspacing=0 border=0><tr><img src=\"white.gif\" height=1 width=18><td></td></tr></table></div>")

            document.write("</div>")
           
            document.close()
            onload=positiongame
}

No comments:

Post a Comment