Jump to content


Photo

Lineup Alert Module


51 replies to this topic

#1 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 08 June 2015 - 01:55 PM

On many of my large leagues I commish , i find it time consuming going through each weeks starting lineups options_06 page to verify each owner has a full lineup submitted. MFL offers no alerts or modules to display this simple data. I combed through the API and modules and couldn't find anything. So i just pulled the info from the options_06 HTML and appended it to create a new module called "Lineup Alert" or you can name it whatever you'd like.

 

Demo Site here - "Lineup Alert" module located on homepage right side - http://www30.myfanta...15/home/15787#0

 

This script will not work on leagues that hide their starting lineups , well i should say , it won't work until the starters are displayed in that case. Any team found with an invalid amount of starters will be displayed in the module , along with a quick link to submit a lineup. When all teams have valid lineups , the module will display text "All Teams Have Valid Lineups?

 

<!----- LINEUP ALERT HTML ------>
<div class="mobile-wrap">
<table class="homepagemodule report" id="InvalidLineup" align="center" cellspacing="1">
    <caption><span>LINEUP ALERT</span></caption>
    <tbody>
        <tr class="invalid-teams" style="display:none"><th colspan="2">The Following Teams Have Invalid Lineups</th></tr>
        <tr class="valid-teams" style="display:none"><th colspan="2">All Teams Have Valid Lineups</th></tr>
        <tr class="reportfooter" style="display:none">
            <td colspan="2" align="center">
                <a href='//%HOST%/%YEAR%/options?LEAGUE_ID=%LEAGUEID%&O=02&%FRANCHISEID%' style='text-decoration:none'>
                    <input type='button' value='Submit Valid Lineup' />
                </a>
            </td>
        </tr>
    </tbody>
</table>
</div>
 

<!----- LINEUP ALERT SCRIPT ------>
<script type="text/javascript"> 
var donotcountBye = true; // SETTING TO FALSE WILL NOT ALERT IF A OWNER IS STARTING A BYE WEEK PLAYER
var donotcountI = true; // SETTING TO FALSE WILL NOT ALERT IF A OWNER IS STARTING A INJURED PLAYER
var donotcountS = true; // SETTING TO FALSE WILL NOT ALERT IF A OWNER IS STARTING A SUSPENDED PLAYER
var donotcountO = true; // SETTING TO FALSE WILL NOT ALERT IF A OWNER IS STARTING A PLAYER DEEMED OUT
var getPlayerStatus = function() {
  var Status = "td.player";
  if (donotcountI) {
    Status = Status + ":not(':has(.warning:contains(I))')";
  }
  if (donotcountS) {
    Status = Status + ":not(':has(.warning:contains(S))')";
  }
  if (donotcountO) {
    Status = Status + ":not(':has(.warning:contains(O))')";
  }
  if (donotcountBye) {
    Status = Status + "+td:not(:contains(Bye))";
  }
  return Status;
}
var RequiredStarters = 0;
var clazz = {};
$.ajax({
  type: "GET",
  url: location.protocol + '//' + window.location.hostname + '/%YEAR%/export?TYPE=league&L=%LEAGUEID%&W=&JSON=1'
}).done(function(data) {
  RequiredStarters = data.league.starters.count;
  $.get('http://%HOST%/%YEAR%...%LEAGUEID%&O=06', function(data) {
    $(data).find('td.two_column_layout .report').each(function(index, element) {
      if ($(this).find(getPlayerStatus()).length !== +RequiredStarters && $(this).attr("id") !== "InvalidLineup") {
        var target = $("#InvalidLineup").find("tr.valid-teams");
        $(this).find("span a").each(function() {
          var className = this.className;
          if (clazz[className]) {
            return
          }
          clazz[className] = true;
          //target.append("<tr class='oddtablerow'><td colspan='2' style='text-align:center'>" + $(this)[0].outerHTML + "</td></tr>");
 
$("<tr class='oddtablerow'><td colspan='2' style='text-align:center'>" + $(this)[0].outerHTML + "</td></tr>").insertAfter(target);
 
          $('#Invalid_lineup .reportfooter').show();
        });
      }
    });
    var $lineuprow = $("#InvalidLineup tr");
    if ($lineuprow.length <= 3) {
      $('.valid-teams').show();
      $('#InvalidLineup .reportfooter').hide();
    }
    else {
      $('.invalid-teams').show();
      $('#InvalidLineup .reportfooter').show();
    }
  });
});
</script>

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

#2 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 08 June 2015 - 02:31 PM

found a bug , fixed the bug , all good for use now


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

#3 GhostXray

GhostXray

    Veteran

  • Members
  • PipPipPip
  • 244 posts
  • Gender:Male
  • Location:Portland, OR

Posted 08 June 2015 - 03:28 PM

Very nice man. Thanks for sharing.



#4 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 08 June 2015 - 05:08 PM

Example with icons in module - http://www30.myfanta...2015/home/15787

 

Example with text names in module - http://www4.myfantas...2015/home/39777


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

#5 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 321 posts
  • Gender:Male
  • Location:Denver

Posted 08 June 2015 - 10:00 PM

That's cool stuff. Nice work.
Gridiron Tavern, the best IDP league available.

#6 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 09 June 2015 - 02:00 PM

will be updating this , to pull the total required starters from the league json , so no editing of the script will be needed

 

Updated:  so no var needs set , API providing the required # of starters for each league

 

 

..........now if i can just place an "Email" button for commish view only , and have it generate an email to owners that didn't submit a lineup ......... THAT WOULD BE SWEET !  Maybe another day.....but its doable after looking into it


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

#7 quickolas1

quickolas1

    Veteran

  • Members
  • PipPipPip
  • 926 posts
  • Gender:Male

Posted 09 June 2015 - 05:48 PM

If you keep tweaking it, you'll go blind.

 

Looks like there may be an issue for leagues that use backup player(s)... still says lineup needs to be submitted.



#8 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 09 June 2015 - 05:50 PM

If you keep tweaking it, you'll go blind.
 
Looks like there may be an issue for leagues that use backup player(s)... still says lineup needs to be submitted.


 

Updated to work with leagues with backup players

 

 

- found another issue , when your league has double headers , 2 instances of the team name or icon will display , working on a fix for that now -


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

#9 bonscott

bonscott

    Veteran

  • Members
  • PipPipPip
  • 7,770 posts
  • Gender:Male

Posted 10 June 2015 - 06:33 AM

Quick question:  Most leagues I'm in the previous weeks lineup is copied in at the start of the week.  So I assume for leagues that do that this module wouldn't be of much use since a full lineup is always in, even if the owner themselves just let last weeks lineup ride as it's checking the number of players that are in the lineup,  Correct?

 

It's an awesome script by the way, great work.



 


#10 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 321 posts
  • Gender:Male
  • Location:Denver

Posted 10 June 2015 - 08:22 AM

Quick question:  Most leagues I'm in the previous weeks lineup is copied in at the start of the week.  So I assume for leagues that do that this module wouldn't be of much use since a full lineup is always in, even if the owner themselves just let last weeks lineup ride as it's checking the number of players that are in the lineup,  Correct?
 
It's an awesome script by the way, great work.


I bet it would work well if the script checked for byes as well.
Gridiron Tavern, the best IDP league available.

#11 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 10 June 2015 - 10:09 AM

Quick question:  Most leagues I'm in the previous weeks lineup is copied in at the start of the week.  So I assume for leagues that do that this module wouldn't be of much use since a full lineup is always in, even if the owner themselves just let last weeks lineup ride as it's checking the number of players that are in the lineup,  Correct?
 
It's an awesome script by the way, great work.


I bet it would work well if the script checked for byes as well.

 

 

I'd like to add a check for players on bye , players with an "Out" or "Injured Status" , but MFL has nothing in their API relating to starting lineups , other then the total # of starters per league. The only way i have this working now is checking for the correct # of td.player cells on the options_06 page and matching that to the API required starters .  If MFL would give players on bye or injured players a secondary unique td.player class name, then i could subtract those from the count , thereby kicking in the script to show those franchise have invalid lineups. But also , many leagues allow bye week players to be started , so would need a var to turn on or off that feature

 

I guess i could try to find players on bye , using text match "Bye" for the td cell following the td.player , and then for IR , i could find the span.warning and text match "IR"  , then have those td.player cells not be counted . We'll see.....still working on getting the script to remove duplicate franchise names/icons for leagues that play double headers.

 

UPDATED: updated to work with leagues using double/triple headers to only pull the franchise name / icon 1 time


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

#12 Thunder56

Thunder56

    Veteran

  • Members
  • PipPipPip
  • 435 posts
  • Gender:Male
  • Interests:Denver Broncos

Posted 10 June 2015 - 11:08 AM

Nice work!, Thanks TOS!


BEERGUTS & GLORY FFL: My Drinking Team Has A Football Problem!

#13 bonscott

bonscott

    Veteran

  • Members
  • PipPipPip
  • 7,770 posts
  • Gender:Male

Posted 10 June 2015 - 11:25 AM

Don't worry about getting too complicated.  Once you start peeling back that onion it can get pretty messy.  I was just considering using this and then thought about the fact that all teams have rosters all the time in copy over leagues (which I think most do).

 

As for Bye, you are correct in that some leagues, usually dynasty leagues, do allow players on bye to be started (or OUT for that matter) because you may not have a choice.



 


#14 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 321 posts
  • Gender:Male
  • Location:Denver

Posted 10 June 2015 - 01:31 PM


Quick question:  Most leagues I'm in the previous weeks lineup is copied in at the start of the week.  So I assume for leagues that do that this module wouldn't be of much use since a full lineup is always in, even if the owner themselves just let last weeks lineup ride as it's checking the number of players that are in the lineup,  Correct?
 
It's an awesome script by the way, great work.

I bet it would work well if the script checked for byes as well.
 
 
I'd like to add a check for players on bye , players with an "Out" or "Injured Status" , but MFL has nothing in their API relating to starting lineups , other then the total # of starters per league. The only way i have this working now is checking for the correct # of td.player cells on the options_06 page and matching that to the API required starters .  If MFL would give players on bye or injured players a secondary unique td.player class name, then i could subtract those from the count , thereby kicking in the script to show those franchise have invalid lineups. But also , many leagues allow bye week players to be started , so would need a var to turn on or off that feature
 
I guess i could try to find players on bye , using text match "Bye" for the td cell following the td.player , and then for IR , i could find the span.warning and text match "IR"  , then have those td.player cells not be counted . We'll see.....still working on getting the script to remove duplicate franchise names/icons for leagues that play double headers.
 
UPDATED: updated to work with leagues using double/triple headers to only pull the franchise name / icon 1 time

You could find the text like you are saying. Just like I did here
http://forums.myfant...showtopic=33390
Gridiron Tavern, the best IDP league available.

#15 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 3,358 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 10 June 2015 - 03:06 PM

You could find the text like you are saying. Just like I did here
http://forums.myfant...showtopic=33390

 

 

that is what i was thinking  ,   "O" is out and "I" is injured correct ?  the only thing left would be bye week players which reside in a different td cell with no class attached. What about players on injured reserve , I don't use the IR , but if a league uses the IR , will MFL allow those into the lineups ? I wouldn't think that is possible , so , to get this working well ,  I'd just need a var for users to allow / disallow  Out , Injured and Bye players , correct ?


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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users