I've got this javascript scroller and it really looks crappy in FF.
What needs to be done to get it working correctly in FF as well as IE?
Will award 200 $Fri to working solution.
scoresscroller.js:
CSS:
Sample Data:
What needs to be done to get it working correctly in FF as well as IE?
Will award 200 $Fri to working solution.
scoresscroller.js:
| Code: |
|
// Initialise settings // First set the left and top positions of each detail so that it is outside the // displayable area. Then set the first area and score details so they can be seen. // After a delay start the first score moving. function init() { eval("areas.style.clip = 'rect(0," + detailswidth + "," + divisionheight + ",0)'") eval("scores.style.top = " + divisionheight) eval("scores.style.clip = 'rect(0," + detailswidth + "," + scoreheight + ",0)'") for (a=0;a<thedetails.length;a++) { eval("area" + a + ".style.left=" + detailswidth) eval("area" + a + ".style.width=" + detailswidth) eval("area" + a + ".style.height=" + divisionheight) for (s=1;s<thedetails[a].length;s++) { eval("score" + a + "_" + s + ".style.top=scoreheight") eval("score" + a + "_" + s + ".style.width=detailswidth") eval("score" + a + "_" + s + ".style.height=scoreheight") } } areanum = 0 scorenum = 1 eval("area" + areanum + ".style.left = 0") eval("score" + areanum + "_" + scorenum + ".style.top = 0") scoreismoving = false setTimeout("startmovescore()",startmovedelay) } // Starts the movement of the area by checking and setting the necessary variables. function startmovearea() { if ((lastarea)>=thedetails.length) {lastarea = 0} if ((lastarea+1)>=thedetails.length) {newarea = 0} else {newarea = (lastarea+1)} movingarea = setInterval("movearea()",contmovedelay) movingscore = setInterval("movescorenewarea()",contmovedelay) } // Moves the area section from from to left. // Runs over and over until the area appearing reaches the left most point. function movearea() { if (parseInt(eval("area" + newarea + ".style.left"))>(divisionmove-1)) { eval("area" + lastarea + ".style.left=" + (parseInt(eval("area" + lastarea + ".style.left")) -divisionmove)) eval("area" + newarea + ".style.left=" + (parseInt(eval("area" + newarea + ".style.left")) -divisionmove)) } else { eval("area" + lastarea + ".style.left=" + detailswidth) eval("area" + newarea + ".style.left=0") clearInterval(movingarea) } } // Starts the movement of the score by checking and setting the necessary variables. function startmovescore() { if ((scorenum+1)>=thedetails[areanum].length) { newscore = 1 lastarea = areanum areanum+=1 startmovearea() } else { newscore = (scorenum+1) movingscore = setInterval("movescore()",contmovedelay) } } // Moves the score section from bottom to top. // Runs over and over until the score appearing reaches the top most point. function movescore() { if (parseInt(eval("score" + areanum + "_" + newscore + ".style.top"))>(scoremove-1)) { scoreismoving = true eval("score" + areanum + "_" + scorenum + ".style.top=" + (parseInt(eval("score" + areanum + "_" + scorenum + ".style.top")) -scoremove)) eval("score" + areanum + "_" + newscore + ".style.top=" + (parseInt(eval("score" + areanum + "_" + newscore + ".style.top")) -scoremove)) } else { eval("score" + areanum + "_" + scorenum + ".style.top=" + scoreheight) eval("score" + areanum + "_" + newscore + ".style.top=0") clearInterval(movingscore) scorenum += 1 scoreismoving = false setTimeout("startmovescore()",startmovedelay) } } // Moves the score section from top to bottom as above but accomodates a new area change as well. // This requires moving the first score from the new area and the last score from the last area. function movescorenewarea() { if (areanum>=thedetails.length) {areanum = 0} if (parseInt(eval("score" + areanum + "_" + newscore + ".style.top"))>(scoremove-1)) { scoreismoving = true eval("score" + lastarea + "_" + scorenum + ".style.top=" + (parseInt(eval("score" + lastarea + "_" + scorenum + ".style.top")) -scoremove)) eval("score" + areanum + "_" + newscore + ".style.top=" + (parseInt(eval("score" + areanum + "_" + newscore + ".style.top")) -scoremove)) } else { eval("score" + lastarea + "_" + scorenum + ".style.top=" + scoreheight) eval("score" + areanum + "_" + newscore + ".style.top=0") clearInterval(movingscore) scorenum = 1 scoreismoving = false setTimeout("startmovescore()",startmovedelay) } } // Build the holder for the areas and scores function buildscoreboard() { document.write('<div id="detailsholder">'); buildareas(); buildscores(); document.write('</div><img src="images/main_menu_filler.gif" width="' + detailswidth + '" height="' + (divisionheight+scoreheight) + '">') } // Build all the area sections function buildareas() { document.write('<div id="areas">') for (t=0;t<thedetails.length;t++) { if ( thedetails[t][0].indexOf('Playoffs', 1) == 0 ) { strHTML = ' <div id="area' + t + '" class="anarea"><table border="0" cellpadding="0" cellspacing="0" width="' + (detailswidth-4) + '" height="' + (divisionheight-4) + '"><tr><td class="thearea">' + thedetails[t][0] + ' Division</td></tr></table></div>' } else { strHTML = ' <div id="area' + t + '" class="anarea"><table border="0" cellpadding="0" cellspacing="0" width="' + (detailswidth-4) + '" height="' + (divisionheight-4) + '"><tr><td class="thearea">' + thedetails[t][0] + '</td></tr></table></div>' } document.write(strHTML) } document.write('</div>') } // Build all the score sections. // thedetails array elements: // 0: date // 1: home team // 2: home team score // 3: home team win count // 4: home team loss count // 5: home team ties count // 6: away team // 7: away team score // 8: away team win count // 9: away team loss count // 10:away team ties count function buildscores() { document.write('<div id="scores">') // These are displayed as tables to accommodate lines and text positioning. for (sa=0;sa<thedetails.length;sa++) { for (ss=1;ss<thedetails[sa].length;ss++) { strHTML = ' <div id="score' + sa + '_' + ss + '" class="ascore">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" ' strHTML += ' width="' + (detailswidth-9) + '" height="' + (scoreheight-4) + '">' strHTML += ' <tr>' strHTML += ' <td colspan="3" class="thedate">' + thedetails[sa][ss][0] + '</td>' strHTML += ' <td class="thedate"><img src="spacer.gif" width="1" height="14"></td>'; strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="' + (((detailswidth-9)/3)*2) + '" height="2"></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="5" height="2"></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="' + (((detailswidth-9)/3)*1) + '" height="2"></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="2"></td>' strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scoredetails" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <tr>' if (thedetails[sa][ss][2] =='ppd' || thedetails[sa][ss][2] =='canc') { // game ppd rain or cancelled strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][1] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][2] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">' strHTML += ' (' + thedetails[sa][ss][3] + '-' + thedetails[sa][ss][4] + '-' + thedetails[sa][ss][5] + ')</td>' strHTML += ' <td class="scoreloser"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scoreloser" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <tr>' strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][6] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][7] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">' strHTML += ' (' + thedetails[sa][ss][8] + '-' + thedetails[sa][ss][9] + '-' + thedetails[sa][ss][10] + ')</td>' strHTML += ' <td class="scoredetails"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' </table>' } else { hs = parseInt(thedetails[sa][ss][2]); vs = parseInt(thedetails[sa][ss][7]); if ( hs > vs) { // home team won strHTML += ' <td class="scorewinner" width="75%">' + thedetails[sa][ss][1] + '</td>' strHTML += ' <td align="right" class="scorewinner" width="25%">' + thedetails[sa][ss][2] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordw" align="center">' strHTML += ' (' + thedetails[sa][ss][3] + '-' + thedetails[sa][ss][4] + '-' + thedetails[sa][ss][5] + ')</td>' strHTML += ' <td class="scorewinner"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scorewinner" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <tr>' strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][6] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][7] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">' strHTML += ' (' + thedetails[sa][ss][8] + '-' + thedetails[sa][ss][9] + '-' + thedetails[sa][ss][10] + ')</td>' strHTML += ' <td class="scoredetails"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' </table>' } else { if (hs == vs) { // tie strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][1] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][2] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">(' + thedetails[sa][ss][3] + '-' + thedetails[sa][ss][4] + '-' + thedetails[sa][ss][5] +')</td>' strHTML += ' <td class="scorewinner"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scoreloser" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <tr>' strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][6] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][7] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">(' + thedetails[sa][ss][8] + '-' + thedetails[sa][ss][9] + '-' + thedetails[sa][ss][10] +')</td>' strHTML += ' <td class="scoredetails"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' </table>' } else { // Home team lost strHTML += ' <td class="scoreloser" width="75%">' + thedetails[sa][ss][1] + '</td>' strHTML += ' <td align="right" class="scoreloser" width="25%">' + thedetails[sa][ss][2] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordl" align="center">(' + thedetails[sa][ss][3] + '-' + thedetails[sa][ss][4] + '-' + thedetails[sa][ss][5] +')</td>' strHTML += ' <td class="scorewinenr"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' <tr>' strHTML += ' <td class="scorewinner" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <table border="0" cellpadding="0" cellspacing="0" width="' + (((detailswidth-10)/3)*2) + '">' strHTML += ' <tr>' strHTML += ' <td class="scorewinner" width="75%">' + thedetails[sa][ss][6] + '</td>' strHTML += ' <td align="right" class="scorewinner" width="25%">' + thedetails[sa][ss][7] + ' </td>' strHTML += ' </tr>' strHTML += ' </table></td>' strHTML += ' <td class="scoreborder"><img src="spacer.gif" width="1" height="1"></td>' strHTML += ' <td class="scorerecordw" align="center">(' + thedetails[sa][ss][8] + '-' + thedetails[sa][ss][9] + '-' + thedetails[sa][ss][10] +')</td>' strHTML += ' <td class="scoredetails"><img src="spacer.gif" width="1" height="' + ((scoreheight-6)/3) + '"></td>' strHTML += ' </tr>' strHTML += ' </table>' } } } strHTML += ' </div>' document.write(strHTML) } } document.write('</div>') } |
CSS:
| Code: |
|
/* #areas and #scores are boxes to hold and clip all the details. These boxes are so that content that would be displayed outside their set area is hidden. */ #detailsholder { position:relative; } #areas { position:absolute; top:0; left:0; clip:rect(0,150,30,0); height:30; width:150; } #scores { position:absolute; top:30; left:0; clip:rect(0,150,66,0); } /* .anarea and .ascore are classes for the details boxes. These sit within #areas and #scores and their position of 0,0 are relative to #areas and #scores. */ .anarea { position:absolute; top:0; left:150; height:22; width:150; background-color:#F9DFB2; border:2 solid #cb0017; } .ascore { position:absolute; top:66; left:0; height:66; width:146; background-color:#00318C; border:2 solid #cb0017; } /* .thearea, .thedate, .scoreborder, and .scoredetails are classes to set colors and fonts for the details. */ .thearea { color:#CB0017; font-size:10pt; font-weight:bold; font-family:verdana; } .thedate { color:#ffffff; background-color:#CB0017; font-size:8pt; font-weight:bold; font-family:arial; } .scoreborder { background-color:#CB0017; } .scoreloser { color:#ffffff; background-color:#00318C; font-size:10pt; font-weight:bold; font-family:arial; } .scorewinner { color:#f9dfb2; background-color:#00318C; font-size:10pt; font-weight:bold; font-family:arial; } .scorerecordl { color:#ffffff; background-color:#000000; font-size:10pt; font-weight:bold; font-family:arial; } .scorerecordw { color:#f9dfb2; background-color:#000000; font-size:10pt; font-weight:bold; font-family:arial; } |
Sample Data:
| Code: |
|
{austin.js} austin = new Array("Austin Playoffs", new Array("Wednesday, Aug 16", "Thunder","6","0","1","0", "Devil Rays","15","1","0","0"), new Array("Thursday, Aug 17", "White Sox","2","0","1","0", "Rangers","4","1","0","0"), new Array("Friday, Aug 18", "Devil Rays","2","1","1","0", "Thunder","3","1","1","0"), new Array("Sunday, Aug 20", "Thunder","0","1","2","0", "Devil Rays","9","2","1","0"), new Array("Wednesday, Aug 23", "Rangers","5","0","1","0", "Devil Rays","12","1","0","0"), new Array("Friday, Aug 25", "Rangers","6","0","2","0", "Devil Rays","8","2","0","0") ) {capitol.js} capitol = new Array("Capitol Playoffs", new Array("Saturday, Aug 19", "Braves","7","1","0","0", "Bombers","6","0","1","0"), new Array("Saturday, Aug 19", "Zephyrs","3","0","1","0", "Cardinals","6","1","0","0"), new Array("Wednesday, Aug 23", "Bombers","4","1","1","0", "Braves","2","1","1","0"), new Array("Thursday, Aug 24", "Cardinals","6","1","1","0", "Zephyrs","7","1","1","0"), new Array("Friday, Aug 25", "Braves","1","1","2","0", "Bombers","6","2","1","0"), new Array("Saturday, Aug 26", "Zephyrs","0","1","2","0", "Cardinals","5","2","1","0"), new Array("Sunday, Aug 27", "Bombers","3","0","1","0", "Cardinals","4","1","0","0"), new Array("Tuesday, Aug 29", "Braves","18","2","0","0", "Bombers","11","0","2","0") ) |
