Welcome Guest ( Log In | Register )

12 Pages V   1 2 3 > »   
Reply to this topicStart new topic
> Boxscore code new and improved, written completely in javascript
habman
post Aug 26 2007, 09:12 AM
Post #1


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


I have reworked the linescore code entirely in javascript.

What are the benefits of this:
- No iframes
- Less bandwidth usage for my site
- Quicker loading and uses less of MFL's resources
- Easier to implement for the end user

You can see it in action here: http://www8.myfantasyleague.com/2008/home/15372


The first few lines of the code have variables that you can change but are not required to.

A little further down is a CSS section where you can add some customization if you want.


Just copy and paste the code into a home page module



Here is the code for those interested:

Last modified: August 28, 2008

CODE
<script language="JavaScript" type="text/javascript">
<!--
// FYI: Last updated August 28, 2008

//Start boxscore manually
   var boxClickToStart = false;

//Number of Rows desired to display boxscores
   var boxRows = 1;

//If you wish to use icons from previous iframe box
   var useOldBoxIconMethod = false;

//Icon URL including base name and extension
   var boxIconURL = '';
   var boxIconExt = 'gif';

//Use league icons as default images  
   var boxIconLeagueDefault = false;

//Use league logos as default images  
   var boxLogoLeagueDefault = false;

//Day of week to switch from Last Weeks Results to Next Weeks Games
   var boxSwitchDay = 3; // 3 is Wednesday; 4 is Thursday

//Set the number of decimal places
   var boxDecimals = 0;

//Hide ties when displaying (W-L-T)
   var hideTiesInRecord = false;

//Hide spread in upcoming games
   var hideSpread = false;

//Hide Box Tip
   var hideBoxTip = false;

//Display boxscores on home page only (useful if boxscore is in header)
   var boxHomeOnly = true;

//Franchise Name or Nickname display
  var hideName = false;
  var useNickNames = false;

//Set up your Nick names here if you choose to use them
   var franchiseNickNames = new Object();  
   franchiseNickNames['0001'] = 'NICK 1';  
   franchiseNickNames['0002'] = 'NICK 2';  
   franchiseNickNames['0003'] = 'NICK 3';  
   franchiseNickNames['0004'] = 'NICK 4 ';
//         .
//         .
//        etc.


//-->
</script>


<style type='text/css'>

.boxtablerow {
   background-color: #E8E1D1;
   color: black;
}

.boxoutertable {
  border-collapse: collapse;
  width: 100%;
  padding: 0px;
  margin: 0px;
  align: center;
  background-color: #E8E1D1;
}

.boxoutertd {
  border: 1px solid black;
}

.boxinnertable {
  border-collapse: collapse;
  width: 100%;
  padding: 0px;
  margin: 0px;
}

a.boxclock:link,  a.boxclock:visited,  a.boxclock:active {
  text-decoration: none;
  color: black;
  font-style: italic;
}

a.boxclock:hover {
  text-decoration: none;
  color: red;
}

.boxteam {
  margin: 0px;
  padding: 0px;
}

.boxscore {
  font-size: 15px;
  font-weight: bold;
  margin: 0px;
  padding: 0px;
}

.boxclock {
  margin: 0px;
  padding: 0px;
}

.boxicon {
  height: 30px; /* Use #px for fixed width i.e. 100px */
  width: 30px;  
}

.boxspread {
  font-size: 14px;
  color: red;
}

.tipbox {
  border: 2px solid black;
  color: black;
  background-color: lightyellow;
  padding: 4px;
}
</style>

<script language="JavaScript" type="text/javascript" src="http://www.habman.com/mfl/apps/js/habman_common.js"></script>
<script language="JavaScript" type="text/javascript" src="http://www.habman.com/mfl/apps/js/boxscore.js"></script>


Here is a brief tutorial on how to implement the images.

There are three ways to do this:

Method #1

If you have icons already setup for your league then just set boxIconLeagueDefault to true

OR

If you have logos already setup for your league the just set boxLogoLeagueDefault to true

======================================

Method #2

If you have icons already made on a personal site from the old iframe ticker then set useOldIconMethod to true and update the iconURL and iconExt as you did for the iframe ticker.

======================================

Method #3

If you wish to create icons for this ticker from scratch then here is how you would do that.

First create your icons but note that they must be of the same file type. ie gif or bmp or jpg

Next choose a base name for your icons ie. icon or image or franchise

Now assuming you chose the base name "icon" name your icons in the following manner: icon0001, icon0002 etc. for franchise #1, franchise #2 etc.

Upload your icons to a personal site for example mine are located at www.habman.com/images/

Now in the script you would set iconURL = 'http://www.habman.com/images/icon';

Lastly in the script you would set the icon extension iconExt = 'gif'; if they are in the gif format.

That is all.


If you have any questions or issues just ask.




Update November 10th:
Added ability to automatically set the days of the week for the Click to Start option.

Replace:
CODE
var boxClickToStart = false;

with
CODE
var boxClickToStart = new Array(false,false,true,true,true,true,true);

In the above example the boxscore will display normally on Sunday & Monday and use the "Click to Start" for the other days.


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
Lasernuke_Commis...
post Aug 26 2007, 10:41 AM
Post #2


Veteran
***

Group: Members
Posts: 220
Joined: 22-February 04
From: North St. Paul, MN
Member No.: 17

2009 MFL: 18033
2010 MFL: 24400


I copied the code, all I get is a
LOADING.....PLEASE WAIT.

Is this the code that replaces the linescore I currently have in my header?

http://football4.myfantasyleague.com/2007/home/39478
under the "extra" tab


--------------------
You are in contravention of the New Paradigm.
Return to your own sector...........or be destroyed.
Go to the top of the page
 
+Quote Post
braven112
post Aug 26 2007, 11:06 AM
Post #3


Veteran
***

Group: Members
Posts: 1102
Joined: 18-April 04
From: mfladdons.com
Member No.: 326



QUOTE (Lasernuke_Commish @ Aug 26 2007, 09:41 AM) *
I copied the code, all I get is a
LOADING.....PLEASE WAIT.


me too!!


--------------------
MFLaddons.com, your home for MFL templates and graphics. Check out our Featured Templates for only $39.99 through the month of June.
Go to the top of the page
 
+Quote Post
theeohiostate
post Aug 26 2007, 11:14 AM
Post #4


Veteran
***

Group: Members
Posts: 1024
Joined: 20-November 06
Member No.: 5017

2009 MFL: 38317
2010 MFL: 47718 , 42147


Got it to work fine with team logos here

http://football14.myfantasyleague.com/2007/home/83104 Click on Boxscore Tab


But i tried to install in a 60 team deluxe league (No logos) and i just get a LOADING . . . . PLEASE WAIT display.


--------------------
Visit Nitro Grafixx...

http://nitrografixx.com/
Go to the top of the page
 
+Quote Post
habman
post Aug 26 2007, 11:29 AM
Post #5


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


QUOTE (Lasernuke_Commish @ Aug 26 2007, 12:41 PM) *
I copied the code, all I get is a
LOADING.....PLEASE WAIT.

Is this the code that replaces the linescore I currently have in my header?

http://football4.myfantasyleague.com/2007/home/39478
under the "extra" tab



I see where the code fails on your site. I bypassed the part of the script that fails and I am getting something up but the font colors are blending into the background so that it make is unreadable.

You may have to do CTRL-F5 to clear your cache to see this change.

BTW Braven and Ohiostate do a CTRL-F5 on your sites and you may notice the message disappear as well.


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
Lasernuke_Commis...
post Aug 26 2007, 11:30 AM
Post #6


Veteran
***

Group: Members
Posts: 220
Joined: 22-February 04
From: North St. Paul, MN
Member No.: 17

2009 MFL: 18033
2010 MFL: 24400


It's showing up now, sort of...
after clearing the cache it loads right away but
White text on white background,
I need to find where the text color option is at.


(edit: posted at the sametime as habman)
Thanks habman


--------------------
You are in contravention of the New Paradigm.
Return to your own sector...........or be destroyed.
Go to the top of the page
 
+Quote Post
habman
post Aug 26 2007, 12:00 PM
Post #7


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


I updated the code a bit.

Please re-copy, paste and do a CTRL-F5




PS
Lasernuke find "boxtablerow" in the css portion of the code to set your colours for the table


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
theeohiostate
post Aug 26 2007, 12:18 PM
Post #8


Veteran
***

Group: Members
Posts: 1024
Joined: 20-November 06
Member No.: 5017

2009 MFL: 38317
2010 MFL: 47718 , 42147


Perfect. Working fine on Deluxe league

http://football35.myfantasyleague.com/2007/home/70226


Edited to ask:

Can this be adjusted to "not" display team names and just display icons only?


--------------------
Visit Nitro Grafixx...

http://nitrografixx.com/
Go to the top of the page
 
+Quote Post
habman
post Aug 26 2007, 01:49 PM
Post #9


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


QUOTE (theeohiostate @ Aug 26 2007, 02:18 PM) *
Perfect. Working fine on Deluxe league

http://football35.myfantasyleague.com/2007/home/70226


Edited to ask:

Can this be adjusted to "not" display team names and just display icons only?



Yes.

First you need to set up your icons.

Then to hide the franchise names look for var hideNames=false; and change it to var hideNames=true;


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
Lasernuke_Commis...
post Aug 26 2007, 06:04 PM
Post #10


Veteran
***

Group: Members
Posts: 220
Joined: 22-February 04
From: North St. Paul, MN
Member No.: 17

2009 MFL: 18033
2010 MFL: 24400


Working great now Habman.
thanks for making these great tools available to the community.
Your the best!


--------------------
You are in contravention of the New Paradigm.
Return to your own sector...........or be destroyed.
Go to the top of the page
 
+Quote Post
stikman
post Aug 26 2007, 10:12 PM
Post #11


Veteran
***

Group: Members
Posts: 74
Joined: 27-May 06
From: 37601
Member No.: 4369



Do the scores auto-refresh? If so, how often? Can the timer be changed?
thanks!!!!
Go to the top of the page
 
+Quote Post
habman
post Aug 27 2007, 12:13 AM
Post #12


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


QUOTE (stikman @ Aug 27 2007, 12:12 AM) *
Do the scores auto-refresh? If so, how often? Can the timer be changed?
thanks!!!!

yes the scoreboard refreshes every 90 seconds.

There is no point in auto refreshing any more often since MFL only updates their stats every 90 seconds. Refreshing more often will only cause unnecessary requests to MFL servers.


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
habman
post Aug 27 2007, 08:59 PM
Post #13


Veteran
***

Group: Members
Posts: 1948
Joined: 29-August 05
From: Leamington ON, Canada
Member No.: 3058

2009 MFL: 31589 , 24836


The code has been modified I think for the last time.

I have added the point spread and a few more CSS controls as well as fixed any bugs with the tip message that displays the status of players for live games.

Let me know of any issues.


--------------------
My MFL scripts . . . . . . . . http://www.habman.com/mfl/
Go to the top of the page
 
+Quote Post
yeti2112dd
post Aug 27 2007, 09:07 PM
Post #14


Member
**

Group: Members
Posts: 25
Joined: 9-September 04
From: Cleveland, OH
Member No.: 1557



I'm getting the boxscore, but underneath it keeps saying "Loading....Please Wait". Is there a setting that I don't have correct? It's under the 'Game' tab.

http://football13.myfantasyleague.com/2007/home/46072

I hit ctrl-F5 and still see the same thing.
Go to the top of the page
 
+Quote Post
Lasernuke_Commis...
post Aug 27 2007, 09:24 PM
Post #15


Veteran
***

Group: Members
Posts: 220
Joined: 22-February 04
From: North St. Paul, MN
Member No.: 17

2009 MFL: 18033
2010 MFL: 24400


Is it possible you have both sets of code there?

the working code, followed by the non-working code?


--------------------
You are in contravention of the New Paradigm.
Return to your own sector...........or be destroyed.
Go to the top of the page
 
+Quote Post

12 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 3rd September 2010 - 11:36 PM