Jump to content


Photo

Position Count For Total Points League

LuckyDog Sports PROgnosticators ProScore US of A Invitational Chopped

8 replies to this topic

#1 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,627 posts
  • Gender:Male
  • Location:Colorado

  • 2020 MFL: 29346

Posted 13 December 2019 - 04:55 AM

Hey Hab,

 

Back in 2017 you offered-up a Position Count Script to use for Contest Leagues in this post -->  http://forums.myfant...=35435&p=189829

 

I have a post-season League PROgnosticators 3.0 in the works where its a set `em and leave it, total points and best ball league where an owner picks his fixed roster via Option 256 (Add/Drops) and it would be helpful if the code for the contest script could be tweaked/adapted to accommodate this setup.

 

League Link:  PROgnosticators 3.0

 

If it can't be done, you don't have the time or the inclination for such a project - I'll completely understand.  Its something I believe would be helpful to the owners when choosing their roster.

 

 

-- Mitch


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#2 habman

habman

    Veteran

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

  • 2020 MFL: 55681
  • , 18835

Posted 30 December 2019 - 08:20 AM

Try the following and set it as a footer message:

 

<style>
.positionCount {
	border: 1px solid black;
	border-collapse:collapse;
	min-width:120px;
}
.positionCount th {
	text-align:center;
	padding:2px;
	font-weight:bold;
}
.positionCount td {
	text-align:center;
	padding:2px;
	width:50%;
}
.positionFailMax {
	background-color:pink;
}
.positionFailMin {
	background-color:yellow;
}
div.positionFailMax, div.positionFailMin{
	text-align:center;
}
</style>
<script>
if(document.getElementById("body_options_256")) {
	//FILL IN YOUR VALID POSITIONS
	var validPositions = ["QB","RB","WR","TE","PK","Def"];
	
	//OPTIONAL SET POSITION MAXIMUM TOTALS (if maximum exceeded item row has positionFailMax class attached)
	var useMaximumTotals = true;
	var includeMaxColumn = false;
	var maximumPositionTotals = ({"Total":12,"QB":2,"RB":4,"WR":4,"TE":3,"PK":2,"Def":1});
	
	//OPTIONAL SET POSITION MINIMUM TOTALS (if minimum not met item row has positionFailMin class attached)
	var useMinimumTotals = true;
	var includeMinColumn = false;
	var minimumPositionTotals = ({"Total":12,"QB":1,"RB":2,"WR":2,"TE":1,"PK":1,"Def":1});

	//NO NEED TO EDIT BELOW THIS LINE
	function updatePositionCount(){
		var playerCount = new Array();
		playerCount["Total"] = 0;
		for (var i=0;i<validPositions.length;i++) playerCount[validPositions[i]] = 0; 
		var destinationBox = document.getElementById("destination_list");
		for (var i=0;i<destinationBox.length;i++){
			playerCount["Total"]++;
			playerCount[playerDatabaseKey["pid_"+destinationBox.options[i].value].pos]++;
		}
		//CREATE TABLE AND APPEND
		var tableHTML = "";
		tableHTML += "<table class='positionCount'>";
		tableHTML += "<tr><th>Pos</th><th>Sum</th>";
		if(includeMinColumn) tableHTML += "<th>Min</th>";
		if(includeMaxColumn) tableHTML += "<th>Max</th>";
		tableHTML += "</tr>";
		var maxExceeded = false;
		var minExceeded = false;
		for (var key in playerCount) {
			if(playerCount[key].hasOwnProperty) {
				var tempClass="";
				if(useMaximumTotals&&playerCount[key]>maximumPositionTotals[key]) { var tempClass=" class='positionFailMax'"; maxExceeded=true; }
				if(useMinimumTotals&&playerCount[key]<minimumPositionTotals[key]) { var tempClass=" class='positionFailMin'"; minExceeded=true; }
				tableHTML += "<tr"+tempClass+"><td>"+key+"</td><td>"+playerCount[key]+"</td>";
				if(includeMinColumn) tableHTML += "<td>"+minimumPositionTotals[key]+"</td>";
				if(includeMaxColumn) tableHTML += "<td>"+maximumPositionTotals[key]+"</td>";
				tableHTML += "</tr>";
			}
		}
		tableHTML+="</table>";
		if(maxExceeded) tableHTML+="<div class='positionFailMax'>Maximum Exceeded</div>";
		if(minExceeded) tableHTML+="<div class='positionFailMin'>Minimum Not Met</div>";
		jQuery(".newColumn").remove();
		jQuery("#destination_list").closest('tr').append("<td class='newColumn' valign='top'>"+tableHTML+"</td>");
	}
	//UPDATE addToList() AND removeListItem() FUNCTIONS TO INCLUDE OUR FUNCTION CALL
	addToList = (function() {
		var cached_function = addToList;
		return function() {
			cached_function.apply(this, arguments);
			updatePositionCount();
		};
	}());
	removeListItem = (function() {
		var cached_function = removeListItem;
		return function() {
			cached_function.apply(this, arguments);
			updatePositionCount();
		};
	}());

	//NEED TO CREATE PLAYER ID KEY FOR PLAYER DATABASE
	var playerDatabaseKey = new Array();
	for (var i=0;i<playerDatabaseObj.picker.length;i++) {
		playerDatabaseKey["pid_"+playerDatabaseObj.picker[i].id] = playerDatabaseObj.picker[i];
	}
	updatePositionCount();
}
</script>

 

 

 

If you don't have jQuery library you will need to include it.

 

FWIW in my tests I noticed that the load rosters allows an owner to submit the same player more than once (first attempt fails but second attempt allows it).  If that is an issue for you I can probably include a warning saying something like duplicate players are not allowed.


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

#3 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,627 posts
  • Gender:Male
  • Location:Colorado

  • 2020 MFL: 29346

Posted 30 December 2019 - 07:42 PM

Looking good.  A "Warning" would be nice, but not critical.


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#4 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,627 posts
  • Gender:Male
  • Location:Colorado

  • 2020 MFL: 29346

Posted 29 August 2020 - 05:40 AM

Hey Hab -

 

Does the script need to be updated or tweaked for 2020?  Its not working for the US of A at

 

https://www51.myfant...20/home/79291#0

 

 

Thanks - Mitch


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#5 theeohiostate

theeohiostate

    Veteran

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

Posted 29 August 2020 - 08:26 AM

see one error on your site not relating to what you asked but needs fixed

 

<script>

//THIS NEEDS TO BE PLACED IN HEADER AND IS USED TO GO BACK IN HISTORY FOR MFL'S LIVE SCORING

if (document.getElementById("body_ajax_ls")) {
    var ls_liveScoringWeekCheck = parseInt(location.href.substr(location.href.indexOf("W2=") + 3, 2));
    if (ls_liveScoringWeekCheck > 0 && ls_liveScoringWeekCheck < liveScoringWeek) {
        liveScoringWeek = parseInt(location.href.substr(location.href.indexOf("W2=") + 3, 2));
    }https://www50.myfantasyleague.com/2020/csetup?L=21666&C=HMPGMSG&SEQNO=3
}

</script>

 should be

 

<script>
//THIS NEEDS TO BE PLACED IN HEADER AND IS USED TO GO BACK IN HISTORY FOR MFL'S LIVE SCORING
if (document.getElementById("body_ajax_ls")) {
    var ls_liveScoringWeekCheck = parseInt(location.href.substr(location.href.indexOf("W2=") + 3, 2));
    if (ls_liveScoringWeekCheck > 0 && ls_liveScoringWeekCheck < liveScoringWeek) {
        liveScoringWeek = parseInt(location.href.substr(location.href.indexOf("W2=") + 3, 2));
    }
}
</script>

FREE Player Cuts Collection
https://www.nitrogra...om/player-cuts/


#6 habman

habman

    Veteran

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

  • 2020 MFL: 55681
  • , 18835

Posted 29 August 2020 - 10:12 AM

Please fix the error that TOS pointed out.  If that doesn't fix the other issue then you will need to give me commish access so I can debug


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

#7 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,627 posts
  • Gender:Male
  • Location:Colorado

  • 2020 MFL: 29346

Posted 29 August 2020 - 07:15 PM

Hab -

 

Didn't fix it.  

 

You need to link your franchise and I'll give you commissioner access.


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "


#8 habman

habman

    Veteran

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

  • 2020 MFL: 55681
  • , 18835

Posted 30 August 2020 - 06:53 AM

Hab -

 

Didn't fix it.  

 

You need to link your franchise and I'll give you commissioner access.

 

 

This league? https://www51.myfant...20/home/79291#0

 

If so which franchise?


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

#9 UCanCallMeMitch

UCanCallMeMitch

    Veteran

  • Members
  • PipPipPip
  • 3,627 posts
  • Gender:Male
  • Location:Colorado

  • 2020 MFL: 29346

Posted 30 August 2020 - 07:17 AM

I having trouble with my server trying to send you an email, but yes on the league, and FFDogz for the franchise.


ldsportslogoindex_32x32.png  LuckyDog Sports 
" Fantasy Fun For Football Fanatics "




Reply to this topic



  



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users