Jump to content


Photo

Boxscore code new and improved


266 replies to this topic

#1 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 26 August 2007 - 09:12 AM

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.myfantas...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: September 9, 2011

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

//Start boxscore manually 
   var boxClickToStart = false;

//For sites that are Fixed Width set the width here
   var boxFixedWidthSite = 0;

//For sites where the calculated vertical positioning is not working
//you can set your own fixed positioning
//Simply uncomment the following var (remove the leading slashes) and set the number to fit your site

//  var boxVerticalOverride = 200;  


//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.


UPDATES

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

Replace:
var boxClickToStart = false;
with
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.



Update September 9, 2011:

Many sites are now using "Fixed Width" which messes up the popups positioning. I have added a var "boxFixedWidthSite" which will compensate for fixed width sites.

Simply set the var to the width of your fixed width site ie
var boxFixedWidthSite = 980;

Just leave it set to zero or omit it altogether if your site is not fixed width.


Update September 10, 2011:

The vertical positioning of the popup gets calculated wrong on some sites so I have added the ability to manually set the vertical positioning.

It may take some trial and error on your part to get the positioning set correctly.

Example: To set the positioning at 200 pixels from the top here is the code
var boxVerticalOverride = 200;

My MFL scripts . . . . . . . . http://www.habman.com/mfl/

#2 Lasernuke_Commish

Lasernuke_Commish

    Veteran

  • Members
  • PipPipPip
  • 220 posts
  • Location:North St. Paul, MN

Posted 26 August 2007 - 10:41 AM

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.myf...2007/home/39478
under the "extra" tab
You are in contravention of the New Paradigm.
Return to your own sector...........or be destroyed.

#3 braven112

braven112

    Veteran

  • Members
  • PipPipPip
  • 1,121 posts
  • Location:mfladdons.com
  • Interests:Seatle Seahawks

Posted 26 August 2007 - 11:06 AM

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


me too!!
MFLaddons.com, your home for MFL templates and graphics.

Visit http://www.facebook.com/MFLaddons

Like us and get a coupon code for 10% off any template at MFLaddons.com

#4 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 2,402 posts
  • Gender:Male
  • Location:NitroGrafixx.com

Posted 26 August 2007 - 11:14 AM

Got it to work fine with team logos here

http://football14.my...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.

Make Your Visual Concepts Explode...
http://nitrografixx.com/

FREE Player Cuts Collection
http://www.nitrograf...nfl-playercuts/


#5 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 26 August 2007 - 11:29 AM

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.myf...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/

#6 Lasernuke_Commish

Lasernuke_Commish

    Veteran

  • Members
  • PipPipPip
  • 220 posts
  • Location:North St. Paul, MN

Posted 26 August 2007 - 11:30 AM

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.

#7 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 26 August 2007 - 12:00 PM

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/

#8 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 2,402 posts
  • Gender:Male
  • Location:NitroGrafixx.com

Posted 26 August 2007 - 12:18 PM

Perfect. Working fine on Deluxe league

http://football35.my...2007/home/70226


Edited to ask:

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

Make Your Visual Concepts Explode...
http://nitrografixx.com/

FREE Player Cuts Collection
http://www.nitrograf...nfl-playercuts/


#9 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 26 August 2007 - 01:49 PM

Perfect. Working fine on Deluxe league

http://football35.my...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/

#10 Lasernuke_Commish

Lasernuke_Commish

    Veteran

  • Members
  • PipPipPip
  • 220 posts
  • Location:North St. Paul, MN

Posted 26 August 2007 - 06:04 PM

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.

#11 stikman

stikman

    Veteran

  • Members
  • PipPipPip
  • 74 posts
  • Gender:Male
  • Location:37601

Posted 26 August 2007 - 10:12 PM

Do the scores auto-refresh? If so, how often? Can the timer be changed?
thanks!!!!

#12 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 27 August 2007 - 12:13 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/

#13 habman

habman

    Veteran

  • Members
  • PipPipPip
  • 2,292 posts
  • Gender:Male
  • Location:Leamington ON, Canada

Posted 27 August 2007 - 08:59 PM

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/

#14 yeti2112dd

yeti2112dd

    Member

  • Members
  • PipPip
  • 25 posts
  • Gender:Male
  • Location:Cleveland, OH

Posted 27 August 2007 - 09:07 PM

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.my...2007/home/46072

I hit ctrl-F5 and still see the same thing.

#15 Lasernuke_Commish

Lasernuke_Commish

    Veteran

  • Members
  • PipPipPip
  • 220 posts
  • Location:North St. Paul, MN

Posted 27 August 2007 - 09:24 PM

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.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users