<commit_before>var mostPopularTemplateSrc = $("#most-popular-template").html();
var mostPopularTemplate = Handlebars.compile(mostPopularTemplateSrc);

var getSmasherPopularity = function (callback) {
	$.getJSON("http://fantasysmashbros.com/popular/popular.json", callback);
};

var renderPopularity = function (data) {
	var game = $("input[type=radio][name=game]:checked").val();
	var lastUpdated = data.lastUpdated;
	var pops = data[game];
	var numParticipants = pops.numParticipants;
	var freqs = pops.freqs;
	freqs.forEach(function (player) {
		player.scoreSpread = calculateScoreSpread(player.popularity);
	});
	var context = {numParticipants: numParticipants, freqs: freqs, lastUpdated: lastUpdated};
	var renderedTemplate = mostPopularTemplate(context);
    $("#most-popular-view").html(renderedTemplate);
    var mp = $("#most-popular");
    attachToggleListenersNoBtn(mp);
    adjustPageHeight();
};

var outcomesTemplateSrc = $("#outcomes-template").html();
var outcomesTemplate = Handlebars.compile(outcomesTemplateSrc);

var getStandings = function (game, playerData, callback) {
	var BASEURL = "https://raw.githubusercontent.com/andrewyang96/FantasySmashBros/master/outcome/";
	$.getJSON(BASEURL + game + ".json", function (data) {
		callback(data, playerData);
	});
};

var renderStandings = function (data, playerData) {
	var playerObjs = [];
	var game = $("input[type=radio][name=game]:checked").val();
	ref.child(game).child("participants").once("value", function (snapshot) {
            // First get participants
            var participants = snapshot.val();
            var numParticipants = Infinity;
            if (participants) {
                numParticipants = Object.keys(participants).length;
            }
		// Convert array of IDs to playerObjs
		data.forEachDone(function (key, i, arr, done) {
	        var playerObj = playerData[key];
	        if (!playerObj.handle) {
	            // Assign empty player handle to empty string
	            playerObj.handle = "";
	        }
	        playerObj.id = key;
	        // Calculate popularity
	        ref.child(game).child("freqs").child(key).once("value", function (snap) {
	            var players = snap.val();
	            if (players) {
	                var numPlayers = Object.keys(players).length;
	                playerObj.popularity = round((numPlayers / numParticipants) * 100, 2);
	            } else {
	                playerObj.popularity = 0;
	            }
	            // Calculate score
	            playerObj.scoreSpread = calculateScoreSpread(playerObj.popularity);
	            playerObj.place = i+1;
	            playerObj.score = calculateScore(playerObj.popularity, playerObj.place);
	            playerObjs.push(playerObj);
	            done();
	        });
	    }, this, function () {
	        var context = {players: playerObjs};
	        var renderedTemplate = outcomesTemplate(context);
	        $("#outcomes-view").html(renderedTemplate);
	        attachToggleListenersNoBtn($("#outcomes-view"));
	        adjustPageHeight();
	    });
	});
};

var yourChoicesTemplateSrc = $("#your-choices-template").html();
var yourChoicesTemplate = Handlebars.compile(yourChoicesTemplateSrc);

var renderChoices = function (IDs, data) {
    var game = $("input[type=radio][name=game]:checked").val();
    if (IDs) {
        var playerObjs = [];
        IDs = Object.keys(IDs);
        ref.child(game).child("participants").once("value", function (snapshot) {
            // First get participants
            var participants = snapshot.val();
            var numParticipants = Infinity;
            if (participants) {
                numParticipants = Object.keys(participants).length;
            }
            // Then iterate through Smasher IDs
            IDs.forEachDone(function (key, i, arr, done) {
                var playerObj = data[key];
                if (!playerObj.handle) {
                    // Assign empty player handle to empty string
                    playerObj.handle = "";
                }
                playerObj.id = key;
                // Calculate popularity
                ref.child(game).child("freqs").child(key).once("value", function (snap) {
                    var players = snap.val();
                    if (players) {
                        var numPlayers = Object.keys(players).length;
                        playerObj.popularity = round((numPlayers / numParticipants) * 100, 2);
                    } else {
                        playerObj.popularity = 0;
                    }
                    // Calculate score
		            playerObj.scoreSpread = calculateScoreSpread(playerObj.popularity);
		            playerObj.place = i+1;
		            playerObj.score = calculateScore(playerObj.popularity, playerObj.place);
		            playerObjs.push(playerObj);
		            done();
                });
            }, this, function () {
                var context = {players: playerObjs};
                var renderedTemplate = yourChoicesTemplate(context);
                $("#your-choices-view").html(renderedTemplate);
                try {
                    attachToggleListeners($("#your-choices"), false);
                } catch (e) {
                    attachToggleListenersNoBtn($("#your-choices"));
                }
                adjustPageHeight();
            });
        });
    } else {
        // Clear choices
        var context = {players: []};
        var renderedTemplate = yourChoicesTemplate(context);
        $("#your-choices-view").html(renderedTemplate);
        attachToggleListeners($("#your-choices"), false);
        adjustPageHeight();
    }
};

var adjustPageHeight = function () {
    // Reset height first
    $(".col").css({
        height: ""
    });
    var pageHeight = $(document).height();
    $(".col").css({
        height: pageHeight
    });
};

var attachToggleListenersNoBtn = function (olElement) {
    olElement.find("li").each(function () {
        // Store heights beforehand
        $(this).data("fullHeight", $(this).outerHeight());
        var previewEl = $(this).find(".preview");
        var previewRelTop = previewEl.offset().top - $(this).offset().top;
        var previewHeight = previewEl.outerHeight(true);<commit_msg>Fix your choices standings code<commit_after>var mostPopularTemplateSrc = $("#most-popular-template").html();
var mostPopularTemplate = Handlebars.compile(mostPopularTemplateSrc);

var getSmasherPopularity = function (callback) {
	$.getJSON("http://fantasysmashbros.com/popular/popular.json", callback);
};

var renderPopularity = function (data) {
	var game = $("input[type=radio][name=game]:checked").val();
	var lastUpdated = data.lastUpdated;
	var pops = data[game];
	var numParticipants = pops.numParticipants;
	var freqs = pops.freqs;
	freqs.forEach(function (player) {
		player.scoreSpread = calculateScoreSpread(player.popularity);
	});
	var context = {numParticipants: numParticipants, freqs: freqs, lastUpdated: lastUpdated};
	var renderedTemplate = mostPopularTemplate(context);
    $("#most-popular-view").html(renderedTemplate);
    var mp = $("#most-popular");
    attachToggleListenersNoBtn(mp);
    adjustPageHeight();
};

var outcomesTemplateSrc = $("#outcomes-template").html();
var outcomesTemplate = Handlebars.compile(outcomesTemplateSrc);

var getStandings = function (game, playerData, callback) {
	var BASEURL = "https://raw.githubusercontent.com/andrewyang96/FantasySmashBros/master/outcome/";
	$.getJSON(BASEURL + game + ".json", function (data) {
		callback(data, playerData);
	});
};

var renderStandings = function (data, playerData) {
	var playerObjs = [];
	var game = $("input[type=radio][name=game]:checked").val();
	ref.child(game).child("participants").once("value", function (snapshot) {
        // First get participants
        var participants = snapshot.val();
        var numParticipants = Infinity;
        if (participants) {
            numParticipants = Object.keys(participants).length;
        }
		// Convert array of IDs to playerObjs
		data.forEachDone(function (key, i, arr, done) {
	        var playerObj = playerData[key];
	        if (!playerObj.handle) {
	            // Assign empty player handle to empty string
	            playerObj.handle = "";
	        }
	        playerObj.id = key;
	        // Calculate popularity
	        ref.child(game).child("freqs").child(key).once("value", function (snap) {
	            var players = snap.val();
	            if (players) {
	                var numPlayers = Object.keys(players).length;
	                playerObj.popularity = round((numPlayers / numParticipants) * 100, 2);
	            } else {
	                playerObj.popularity = 0;
	            }
	            // Calculate score
	            playerObj.scoreSpread = calculateScoreSpread(playerObj.popularity);
	            playerObj.place = i+1;
	            playerObj.score = calculateScore(playerObj.popularity, playerObj.place);
	            playerObjs.push(playerObj);
	            done();
	        });
	    }, this, function () {
	        var context = {players: playerObjs};
	        var renderedTemplate = outcomesTemplate(context);
	        $("#outcomes-view").html(renderedTemplate);
	        attachToggleListenersNoBtn($("#outcomes-view"));
	        adjustPageHeight();
	    });
	});
};

var yourChoicesTemplateSrc = $("#your-choices-template").html();
var yourChoicesTemplate = Handlebars.compile(yourChoicesTemplateSrc);

var renderChoices = function (IDs, data) {
    var game = $("input[type=radio][name=game]:checked").val();
    if (IDs) {
        var playerObjs = [];
        IDs = Object.keys(IDs);
        ref.child(game).child("participants").once("value", function (snapshot) {
        	getStandings(game, null, function (standings) {
        		// First get participants
	            var participants = snapshot.val();
	            var numParticipants = Infinity;
	            if (participants) {
	                numParticipants = Object.keys(participants).length;
	            }
	            // Then iterate through Smasher IDs
	            IDs.forEachDone(function (key, i, arr, done) {
	                var playerObj = data[key];
	                if (!playerObj.handle) {
	                    // Assign empty player handle to empty string
	                    playerObj.handle = "";
	                }
	                playerObj.id = key;
	                // Calculate popularity
	                ref.child(game).child("freqs").child(key).once("value", function (snap) {
	                    var players = snap.val();
	                    if (players) {
	                        var numPlayers = Object.keys(players).length;
	                        playerObj.popularity = round((numPlayers / numParticipants) * 100, 2);
	                    } else {
	                        playerObj.popularity = 0;
	                    }
	                    // Calculate score
			            playerObj.scoreSpread = calculateScoreSpread(playerObj.popularity);
			            playerObj.place = standings.indexOf(playerObj.id);
			           	if (playerObj.place == -1) playerObj.place = Infinity;
			            playerObj.score = calculateScore(playerObj.popularity, playerObj.place);
			            playerObjs.push(playerObj);
			            done();
	                });
	            }, this, function () {
	                var context = {players: playerObjs};
	                var renderedTemplate = yourChoicesTemplate(context);
	                $("#your-choices-view").html(renderedTemplate);
	                try {
	                    attachToggleListeners($("#your-choices"), false);
	                } catch (e) {
	                    attachToggleListenersNoBtn($("#your-choices"));
	                }
	                adjustPageHeight();
	            });
        	});
        });
    } else {
        // Clear choices
        var context = {players: []};
        var renderedTemplate = yourChoicesTemplate(context);
        $("#your-choices-view").html(renderedTemplate);
        attachToggleListeners($("#your-choices"), false);
        adjustPageHeight();
    }
};

var adjustPageHeight = function () {
    // Reset height first
    $(".col").css({
        height: ""
    });
    var pageHeight = $(document).height();
    $(".col").css({
        height: pageHeight
    });
};

var attachToggleListenersNoBtn = function (olElement) {
    olElement.find("li").each(function () {
        // Store heights beforehand
        $(this).data("fullHeight", $(this).outerHeight());
        var previewEl = $(this).find(".preview");
        var previewRelTop = previewEl.offset().top - $(this).offset().top;
        var previewHeight = previewEl.outerHeight(true);
{'fraction_non_alphanumeric': 0.13105570459207827, 'fraction_numerical': 0.002209247277891747, 'mean_word_length': 2.2202743902439024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3338643', 'n_tokens_mistral': 3612, 'n_tokens_neox': 3279, 'n_words': 666}