Jump to content


Photo

Replace franchise text with franchiseicon


18 replies to this topic

#1 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 16 September 2021 - 06:50 PM

Is the code on this link the most up to date way that has been found to replace franchise text with franchiseicon?

 

http://forums.myfant...showtopic=33332

 

My code below is partly working, but not great. On options 117, top adds/drops, when logged in as commissioner it isn't showing some that have TS for taxi squad or IR next to them. While logged in as me, it only shows my franchiseicon. It is not working at all on the top performers pages that I added a class to the body. It has some team abbreviations, but not all teams have set abbreviations.  

 

<script>
$(document).ready(function(){
$('#body_top').has('.pagetitle:contains("Top Performers")').addClass('topplayerreport');
});
</script>


<script>
var iconDisplayCheckArr    =    new Array();

//DEFAULT CONFIGURATION WILL DISPLAY ICONS ON BRIEF STANDINGS - RECENT DRAFT PICKS - LIVE SCORING SUMMARY
//DEFAULT CONFIGURATION WILL DISPLAY TEXT ON OPTIONS_15 AND OPTIONS_16 REPORTS

iconDisplayCheckArr['topplayerreport']            = new CustomConfigIcons(true, false, true, true, false,'','');

iconDisplayCheckArr['brief_standings']            = new CustomConfigIcons(false, true, true, true, false,'','');
//iconDisplayCheckArr['livescoring_summary']        = new CustomConfigIcons(false, true, true, true, false,'','');
//iconDisplayCheckArr['recent_draft_picks']        = new CustomConfigIcons(false, true, true, true, false,'','');
//iconDisplayCheckArr['body_options_16']            = new CustomConfigIcons(false, true, false, true, false,'','');
//iconDisplayCheckArr['body_options_15']            = new CustomConfigIcons(false, true, false, true, false,'','');

showDetailsIcon    =    false; //SET TO FALSE TO REMOVE THE CUSTOM IMAGE I HAVE ADDED ON THE LIVE SCORING REPORT TO REPLACE THE TEXT WORD "DETAILS"

function CustomConfigIcons (isClass, isId, showIcon, forAllInstances, isCustom, source, value){
   this.isClass        =    isClass;
   this.isId        =    isId;
   this.showIcon    =    showIcon;
   this.forAllInstances    =    forAllInstances;
   this.isCustom    =    isCustom;
   this.source        =    source;
   this.value        =    value;
}
(function($) {
    var prop,fdb,filter_fn = null;
    var displayContent = '';
      for(prop in franchiseDatabase){    
          fdb = franchiseDatabase[prop];
          if(fdb instanceof Franchise){
// Place target here
        $('#brief_standings, .topplayerreport').each(function(index, element){
            checkAndReplaceNamesWithIcon(element, fdb);
        });
          }
      }
})(jQuery);
function checkAndReplaceNamesWithIcon(element, fdb){        
        if(showDetailsIcon){       
//YOU CAN LINK YOU OWN CUSTOM IMAGE FOR LIVESCORING DETAILS TEXT REPLACEMENT HERE                                                                       
            $('*#livescoring_summary td a:contains("Details")').html('<img src="" title="View Scoring Details"/>');
        }
         if(element!=null){
            var    cConfig        =    iconDisplayCheckArr[element.id.trim()==''?element.classList[0]:element.id];
            var displayContent    =    '';
            var    key        =    '';

            if(cConfig!=null && cConfig instanceof CustomConfigIcons){
                if(cConfig.forAllInstances){
                    key+='*';
                }
                 if(cConfig.class){
                    key = key+'.'+element.classList[0];
                 }
                 if(cConfig.isId){
                    key = key+'#'+element.id;
                 }
                 if(cConfig.showIcon && fdb.icon!=''){
                    displayContent    =   '<img src="' + fdb.icon + '"class="franchiseicon" title="' + fdb.name + '" />';
                 }
                 else{
                    displayContent    =     fdb.name;     
                    $(key).find('img').filter(function(){
                        return $(this).attr('src')==fdb.icon;
                    }).parent().html(displayContent);
                  }                
                 $(key).find('td').filter(function() { return $(this).text() == fdb.name; })
//CHANGE THE URL OF THE DESTINATION YOUR ICONS/TEAM NAMES ARE DIRECTED - CURRENTLY SET TO 01 FOR OPTIONS PAGE 01 TEAM HOME PAGE
                .html( '<a href="' + window.baseURLDynamic + '/' + window.year + '/options?L=' + window.league_id + '&F=' + fdb.id + '&O=01">' + displayContent+'</a>' );                
            }
        }
}
</script>

 



#2 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 16 September 2021 - 07:13 PM

dont think there is a one stop shop for this 

 

the top players reports used to show icons , but now just text , so nothing to target  , unless league by league case using text replace to match up the team names / abbr and then prop an icon


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#3 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 16 September 2021 - 07:20 PM

dont think there is a one stop shop for this 
 
the top players reports used to show icons , but now just text , so nothing to target  , unless league by league case using text replace to match up the team names / abbr and then prop an icon


Ok, thanks for the heads up. I'll just hack something together for my league in that case. I was hoping it would be easy.

#4 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 16 September 2021 - 07:25 PM

you can check out what habman did for his sites

 

appending an icon by every player https://www68.myfant...s?L=29385&O=236

 

but he uses small icons and not big ones like most , so they all look nice and tight


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#5 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 16 September 2021 - 07:28 PM

Here is the script he has , what he is doing is adding a class to each player , then i use css to add the image

  //SETTINGS FOR FRANCHISE ICON PREPEND TO TEAM
  var MFL_prependFranchiseIconTeam = true;
  var MFL_prependFranchiseIconTeamOmitId = new Array("body_options_03", "body_options_08", "body_options_34", "body_options_67", "body_options_79", "body_options_170", "body_trade_offer", "body_trade_response", "transactions", "trade_bait","body_csetup_revtrad","body_options_100");

  //SETTINGS FOR FRANCHISE ICON PREPEND TO PLAYER
  var MFL_prependFranchiseIconPlayer = true;
  var MFL_prependFranchiseIconPlayerOmitId = new Array("body_options_17", "body_options_18", "body_ir", "body_options_133", "body_fantasy_box_score", "body_weekly", "body_options_205", "body_options_06", "body_lineup", "body_options_02", "body_options_03", "body_options_05", "body_options_07", "body_options_67", "body_options_113", "roster", "transactions", "trade_bait","probowl","probowl_table","probowl_team","body_csetup_revtrad");

  //DEFINE PLAYERS TO FRANCHISE IDs
  var MFL_pid_fid = new Array()
  var url = baseURLDynamic + "/" + year + "/options?L=" + league_id + "&O=07";
  $.ajax({
    type: 'GET',
    url: url,
    async: false
  }).done(function (rostersData) {
    $(rostersData).find("table .report").each(function () {
      var fid = $(this).find("caption span a").attr("href").substr($(this).find("caption span a").attr("href").indexOf('F=') + 2, 4);
      $(this).find("td.player a").each(function () {
        var pid = $(this).attr("href").substring($(this).attr("href").indexOf('P=') + 2, $(this).attr("href").length);
        MFL_pid_fid["pid_" + pid] = ({
          'id': pid,
          'fid': fid
        });
      });
      if (MFL_prependFranchiseIconPlayer)
        if (!includes(MFL_prependFranchiseIconPlayerOmitId, $('body').attr('id'))) doMFL_prependFranchiseIconPlayer();
    });
  });

  ///////////////////////////////////////////
  //MFL FRANCHISE ICON PREPEND TO PLAYER FUNCTIONS
  ///////////////////////////////////////////
  function doMFL_prependFranchiseIconPlayer(thisId) {
    if (thisId == undefined)
      var target = 'body';
    else
      var target = '#' + thisId;
    $(target).find('a[class*="position_"]').each(function () {
      if (!includes(MFL_prependFranchiseIconPlayerOmitId, $(this).closest("table").attr("id"))) {
        var pid = $(this).attr("href").substring($(this).attr("href").indexOf('P=') + 2, $(this).attr("href").length);
        if (MFL_pid_fid.hasOwnProperty("pid_" + pid)) {
          $(this).removeClass("franPlayerFA").addClass("franPlayer_" + MFL_pid_fid["pid_" + pid].fid);
          $(this).parent().css('white-space', 'nowrap')
        } else {
          $(this).addClass("franPlayerFA");
          $(this).parent().css('white-space', 'nowrap')
        }
      }
    });
  }

  ///////////////////////////////////////////
  //MFL FRANCHISE ICON PREPEND TO TEAM FUNCTIONS
  ///////////////////////////////////////////
  function doMFL_prependFranchiseIconTeam() {
    $('body').find('a[class*="franchise_"]').each(function () {
      if (!includes(MFL_prependFranchiseIconTeamOmitId, $(this).closest("table").attr("id"))) {
        //var fid = $(this).attr("href").substring($(this).attr("href").indexOf('F=') + 2, $(this).attr("href").indexOf('F=') + 6);
        var fid = $(this).attr("class").substr($(this).attr("class").indexOf('franchise_') + 10, 4);
        try {
          $(this).parent().css('white-space', 'nowrap');
          $(this).parent().prepend("<div class='franTeam_" + fid + "' title='" + franchiseDatabase["fid_" + fid].name + "'></div>");
        } catch (er) {}
      }
    });
  }

  if (MFL_prependFranchiseIconTeam)
    if (!includes(MFL_prependFranchiseIconTeamOmitId, $('body').attr('id'))) doMFL_prependFranchiseIconTeam();

 

 

 

Here is css , i created a sprite with all his leagues icons , then used background position to show them based on the new class added by his script

 

/* CUSTOM ICONS SPRITE */

.franPlayerFA,
a[class*="franPlayer_"] {
  position: relative;
  padding-left: 24px!important
}

.franPlayerFA:before {
  content: "FA";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  text-align: center;
  background: var(--accent, #B82601);
  top: 50%;
  transform: translate(0, -50%);
  line-height: 16px;
  border-radius: 50%;
  color: white;
  font-size: 9px;
  font-weight: bold
}

/* SPRITE IMAGE FOR EACH LEAGUE */
a[class*="franPlayer_"]:before,div[class*="franTeam_"]{background: url(https://www.mflscripts.com/mfl-apps/global/css/icon_sprite/glffl.png) no-repeat}

/* PLAYER NAME ICONS CSS */
a[class*="franPlayer_"]:before{content:"";width:20px;height:20px;background-size:800% 200%!important;position:absolute;left:0;top:50%;transform:translate(0,-50%)}
a[class*="franPlayer_0001"]:before {background-position: 0px 0!important}
a[class*="franPlayer_0002"]:before{background-position:-20px 0!important}
a[class*="franPlayer_0003"]:before {background-position:-40px 0!important}
a[class*="franPlayer_0004"]:before {background-position:-60px 0!important}
a[class*="franPlayer_0005"]:before {background-position:-80px 0!important}
a[class*="franPlayer_0006"]:before {background-position:-100px 0!important}
a[class*="franPlayer_0007"]:before {background-position:-120px 0!important}
a[class*="franPlayer_0008"]:before {background-position:-140px 0!important}
a[class*="franPlayer_0009"]:before {background-position:0 -20px!important}
a[class*="franPlayer_0010"]:before {background-position:-20px -20px!important}
a[class*="franPlayer_0011"]:before {background-position:-40px -20px!important}
a[class*="franPlayer_0012"]:before {background-position:-60px -20px!important}
a[class*="franPlayer_0013"]:before {background-position:-80px -20px!important}
a[class*="franPlayer_0014"]:before {background-position:-100px -20px!important}
a[class*="franPlayer_0015"]:before {background-position:-120px -20px!important}
a[class*="franPlayer_0016"]:before {background-position:-140px -20px!important}

/* FRANCHISE NAME ICONS CSS */
div[class*="franTeam_"] {display:inline-block;width: 40px;height:40px;vertical-align:middle;margin-right:4px}
div[class*="franTeam_0001"] {background-position:0px 0!important}
div[class*="franTeam_0002"] {background-position:-40px 0!important}
div[class*="franTeam_0003"] {background-position:-80px 0!important}
div[class*="franTeam_0004"] {background-position:-120px 0!important}
div[class*="franTeam_0005"] {background-position:-160px 0!important}
div[class*="franTeam_0006"] {background-position:-200px 0!important}
div[class*="franTeam_0007"] {background-position:-240px 0!important}
div[class*="franTeam_0008"] {background-position:-280px 0!important}
div[class*="franTeam_0009"] {background-position:0 -40px!important}
div[class*="franTeam_0010"] {background-position:-40px -40px!important}
div[class*="franTeam_0011"] {background-position:-80px -40px!important}
div[class*="franTeam_0012"] {background-position:-120px -40px!important}
div[class*="franTeam_0013"] {background-position:-160px -40px!important}
div[class*="franTeam_0014"] {background-position:-200px -40px!important}
div[class*="franTeam_0015"] {background-position:-240px -40px!important}
div[class*="franTeam_0016"] {background-position:-280px -40px!important}

#roster_column_left div[class*="franTeam_"]{margin:0 15px}
@media only screen and (max-width: 1050px) {#roster_column_left div[class*="franTeam_"]{margin:0 11px}}
@media only screen and (max-width: 930px) {#roster_column_left div[class*="franTeam_"]{margin:0 8px}}
@media only screen and (max-width: 800px) {#roster_column_left div[class*="franTeam_"]{margin:0 3px}}
@media only screen and (max-width: 700px) {#roster_column_left div[class*="franTeam_"]{margin:0 0px}}

All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#6 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 16 September 2021 - 07:31 PM

Ohhh that's a good idea, thanks. I'll check it out

#7 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 16 September 2021 - 07:36 PM

Ohhh that's a good idea, thanks. I'll check it out

 

 

if using our template , the script is already in it as well as the css , you can enable it by setting var. Adjustment will need made to css to be site specific, right now i have css to target all 6 of his leagues by adding a class to each of his leagues body to separate them

 

 

Add this var to the footer message , ABOVE the footer.js file

 

var load_playerIcons = true;

 

once var is set to true , then you will get spaces before all teams and players names where you use css to add the team icons.

 

 

If you want to remove icons before the team names add this css

div[class*="franTeam_"] {
  display:none!important;
}

 

 

if you want to remove icons before player names add this css

.franPlayerFA:before,
a[class*="franPlayer_"]:before {
  display:none!important;
}
.franPlayerFA,
a[class*="franPlayer_"] {
  padding-left: 0!important
}

 

 

 

Here is the css to use to add team icons to matching teams and players

/* CUSTOM ICONS SPRITE */

.franPlayerFA,
a[class*="franPlayer_"] {
  position: relative;
  padding-left: 24px!important
}

.franPlayerFA:before {
  content: "FA";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  text-align: center;
  background: var(--accent, #B82601);
  top: 50%;
  transform: translate(0, -50%);
  line-height: 16px;
  border-radius: 50%;
  color: white;
  font-size: 9px;
  font-weight: bold
}

/* SPRITE IMAGE FOR EACH LEAGUE */
a[class*="franPlayer_"]:before,div[class*="franTeam_"]{background: url(https://www.mflscripts.com/mfl-apps/global/css/icon_sprite/glffl.png) no-repeat}

/* PLAYER NAME ICONS CSS */
a[class*="franPlayer_"]:before{content:"";width:20px;height:20px;background-size:800% 200%!important;position:absolute;left:0;top:50%;transform:translate(0,-50%)}
a[class*="franPlayer_0001"]:before {background-position: 0px 0!important}
a[class*="franPlayer_0002"]:before{background-position:-20px 0!important}
a[class*="franPlayer_0003"]:before {background-position:-40px 0!important}
a[class*="franPlayer_0004"]:before {background-position:-60px 0!important}
a[class*="franPlayer_0005"]:before {background-position:-80px 0!important}
a[class*="franPlayer_0006"]:before {background-position:-100px 0!important}
a[class*="franPlayer_0007"]:before {background-position:-120px 0!important}
a[class*="franPlayer_0008"]:before {background-position:-140px 0!important}
a[class*="franPlayer_0009"]:before {background-position:0 -20px!important}
a[class*="franPlayer_0010"]:before {background-position:-20px -20px!important}
a[class*="franPlayer_0011"]:before {background-position:-40px -20px!important}
a[class*="franPlayer_0012"]:before {background-position:-60px -20px!important}
a[class*="franPlayer_0013"]:before {background-position:-80px -20px!important}
a[class*="franPlayer_0014"]:before {background-position:-100px -20px!important}
a[class*="franPlayer_0015"]:before {background-position:-120px -20px!important}
a[class*="franPlayer_0016"]:before {background-position:-140px -20px!important}

/* FRANCHISE NAME ICONS CSS */
div[class*="franTeam_"] {display:inline-block;width: 40px;height:40px;vertical-align:middle;margin-right:4px}
div[class*="franTeam_0001"] {background-position:0px 0!important}
div[class*="franTeam_0002"] {background-position:-40px 0!important}
div[class*="franTeam_0003"] {background-position:-80px 0!important}
div[class*="franTeam_0004"] {background-position:-120px 0!important}
div[class*="franTeam_0005"] {background-position:-160px 0!important}
div[class*="franTeam_0006"] {background-position:-200px 0!important}
div[class*="franTeam_0007"] {background-position:-240px 0!important}
div[class*="franTeam_0008"] {background-position:-280px 0!important}
div[class*="franTeam_0009"] {background-position:0 -40px!important}
div[class*="franTeam_0010"] {background-position:-40px -40px!important}
div[class*="franTeam_0011"] {background-position:-80px -40px!important}
div[class*="franTeam_0012"] {background-position:-120px -40px!important}
div[class*="franTeam_0013"] {background-position:-160px -40px!important}
div[class*="franTeam_0014"] {background-position:-200px -40px!important}
div[class*="franTeam_0015"] {background-position:-240px -40px!important}
div[class*="franTeam_0016"] {background-position:-280px -40px!important}

#roster_column_left div[class*="franTeam_"]{margin:0 15px}
@media only screen and (max-width: 1050px) {#roster_column_left div[class*="franTeam_"]{margin:0 11px}}
@media only screen and (max-width: 930px) {#roster_column_left div[class*="franTeam_"]{margin:0 8px}}
@media only screen and (max-width: 800px) {#roster_column_left div[class*="franTeam_"]{margin:0 3px}}
@media only screen and (max-width: 700px) {#roster_column_left div[class*="franTeam_"]{margin:0 0px}}

 

 

 

A sprite image will need created for the css , exampleglffl.png


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#8 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 19 September 2021 - 04:42 PM

Here is the script he has , what he is doing is adding a class to each player , then i use css to add the image

 

I think there's a missing "{" after this part. I don't know if it was just on this message board or in your live code, so I just wanted to give a heads up. 

if (MFL_prependFranchiseIconTeam)

 

 

Also, this is pretty complicated stuff here. Is this code placing an icon before every player name, except the pages listed in the array? I'm just trying to figure out if I want to move some code around to just target my custom class. 

 

Again, thank you for providing the code. 



#9 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 19 September 2021 - 04:47 PM

The css is the tricky part
The script just places an empty div in front of all players and / or franchise names where the css adds the images

You can set the var to do both players and teams or just one of the two

You could over write that array and target the bodyID or reportID

All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#10 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 19 September 2021 - 04:51 PM

{ are not needed

 

https://stackoverflo...s-in-javascript

 

 

This is acceptable

if (cond) 
    alert("Condition met!")
else
    alert("Condition not met!")

All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#11 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 19 September 2021 - 04:56 PM

{ are not needed after if statements anylonger

 

code didn't work until after I added it :shrug: 



#12 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 19 September 2021 - 04:58 PM

{ are not needed after if statements anylonger

 

code didn't work until after I added it :shrug: 

 

the majority of our scripts don't  have them and its working as is on habmans site in that example as well

 

I use them when i write javascript , but habman doesn't use them


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#13 Screaming Eagle

Screaming Eagle

    Veteran

  • Members
  • PipPipPip
  • 396 posts
  • Gender:Male

  • 2021 MFL: 36134

Posted 19 September 2021 - 07:47 PM

You could add body options 22 and 98 to your player exemption list 



#14 theeohiostate

theeohiostate

    Veteran

  • Members
  • PipPipPip
  • 4,314 posts
  • Gender:Male
  • Location:O-H-I-O

Posted 19 September 2021 - 07:52 PM

You could add body options 22 and 198 to your player exemption list 

 

 

its Habmans script for his sites , i'm not touching it unless he wants to add them.....

 

 

options_22 has all players in table under team caption , not sure if needed to show team icons next to players when they are already grouped for each team


All the scripts I post were created by Habman , with some small contributions from myself. The man has done an outstanding job giving the community a variety of options to enhance the site. Thank you sir !!


#15 habman

habman

    Veteran

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

  • 2021 MFL: 55681
  • , 18835

Posted 19 September 2021 - 09:16 PM

Option 22 make sense. What does option 198 do? Im sure it would make sense too though so by all means if you want to add then you have my permission



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users