<commit_before>function Controller()
{
    var self = this; //<- I hate javascript.
    this.setLayout = function(sender)
    {
        switch(sender)
        {
            case model.views.mapLayoutButton:
                model.views.listLayoutButton.deselect();
                model.views.listLayout.style.display = 'none';
                model.views.sortSelector.style.display = 'none';
                model.views.mapLayout.style.display = 'block';
                model.views.mapNoteViewContainer.appendChild(model.views.noteView.html);
                break;
            case model.views.listLayoutButton:
                model.views.mapLayoutButton.deselect();
                model.views.mapLayout.style.display = 'none';
                model.views.sortSelector.style.display = 'block';
                model.views.listLayout.style.display = 'block';
                model.views.listNoteViewContainer.appendChild(model.views.noteView.html);
                break;
        }
    };
    this.setSort = function(sender)
    {
        switch(sender)
        {
            case model.views.contributorSortButton:
                model.views.tagSortButton.deselect();
                model.views.popularitySortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '245px';
                model.views.noteListSelectorContainer.style.margin = '10px 0px 0px 0px';
                model.views.noteListSelector.style.height = '223px';
                model.views.tagListFilterSelectorContainer.style.display = 'none';
                model.views.contributorListFilterSelectorContainer.style.display = 'block';
                self.populateNotesByContributor();
                break;
            case model.views.tagSortButton:
                model.views.contributorSortButton.deselect();
                model.views.popularitySortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '245px';
                model.views.noteListSelectorContainer.style.margin = '10px 0px 0px 0px';
                model.views.noteListSelector.style.height = '223px';
                model.views.contributorListFilterSelectorContainer.style.display = 'none';
                model.views.tagListFilterSelectorContainer.style.display = 'block';
                self.populateNotesByTag();
                break;
            case model.views.popularitySortButton:
                model.views.contributorSortButton.deselect();
                model.views.tagSortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '500px';
                model.views.noteListSelectorContainer.style.margin = '0px 0px 0px 0px';
                model.views.noteListSelector.style.height = '478px';
                model.views.contributorListFilterSelectorContainer.style.display = 'none';
                model.views.tagListFilterSelectorContainer.style.display = 'none';
                self.populateNotesByPopularity();
                break;
        }
    };

    this.mapContributorClicked = function(sender, selected) 
    {
        self.populateMapNotes(false);
    };
    this.selectAllMapContributors = function() 
    {
        for(var i = 0; i < model.contributorMapCells.length; i++)
            model.contributorMapCells[i].select();
        self.populateMapNotes(false);
    };
    this.deselectAllMapContributors = function()
    {
        for(var i = 0; i < model.contributorMapCells.length; i++)
            model.contributorMapCells[i].deselect();
        self.populateMapNotes(false);
    };
    this.mapTagClicked = function(sender,selected) 
    {
        self.populateMapNotes(false);
    };
    this.selectAllMapTags = function()
    {
        for(var i = 0; i < model.tagMapCells.length; i++)
            model.tagMapCells[i].select();
        self.populateMapNotes(false);
    };
    this.deselectAllMapTags = function()
    {
        for(var i = 0; i < model.tagMapCells.length; i++)
            model.tagMapCells[i].deselect();
        self.populateMapNotes(false);
    };
    this.listContributorClicked = function(sender,selected) 
    {
        self.populateNotesByContributor();
    };
    this.selectAllListContributors = function()
    {
        for(var i = 0; i < model.contributorListCells.length; i++)
            model.contributorListCells[i].select();
        self.populateNotesByContributor();
    };
    this.deselectAllListContributors = function()
    {
        for(var i = 0; i < model.contributorListCells.length; i++)
            model.contributorListCells[i].deselect();
        self.populateNotesByContributor();
    };
    this.listTagClicked = function(sender,selected)
    {
        self.populateNotesByTag();
    };
    this.selectAllListTags = function()
    {
        for(var i = 0; i < model.tagListCells.length; i++)
            model.tagListCells[i].select();
        self.populateNotesByTag();
    };
    this.deselectAllListTags = function()
    {
        for(var i = 0; i < model.tagListCells.length; i++)
            model.tagListCells[i].deselect();
        self.populateNotesByTag();
    };
    this.noteSelected = function(sender) 
    {
        var note = sender.object;
        var html = model.views.constructNoteView.cloneNode(true);
        model.views.noteView = new NoteView(html, note);
        model.views.mapNoteViewContainer.innerHTML = '';
        model.views.listNoteViewContainer.innerHTML = '';
        if(model.views.mapLayoutButton.selected)
        {
            model.views.mapNoteViewContainer.appendChild(model.views.mapNoteViewCloseButton.html);
            model.views.mapNoteViewContainer.appendChild(model.views.noteView.html);
            model.views.mapNoteViewContainer.style.display = 'block';
            setTimeout(function() { model.views.mapLayout.addEventListener('click', controller.hideMapNoteView, false); }, 100); //timeout to disallow imediate hiding
        }
        if(model.views.listLayoutButton.selected) 
        {
            model.views.listNoteViewContainer.appendChild(model.views.noteView.html);
            if(model.views.contributorSortButton.selected) for(var i = 0; i < model.views.contributorNoteCells.length; i++) model.views.contributorNoteCells[i].deselect();
            if(model.views.tagSortButton.selected) for(var i = 0; i < model.views.tagNoteCells.length; i++) model.views.tagNoteCells[i].deselect();
            if(model.views.popularitySortButton.selected) for(var i = 0; i < model.views.popularNoteCells.length; i++) model.views.popularNoteCells[i].deselect();
        }
    };

    this.populateModel = function(gameData)
    {
        model.gameData = gameData;

        model.backpacks = model.gameData.backpacks;
        for(var i = 0; i < model.backpacks.length; i++)
        {
            for(var j = 0; j < model.backpacks[i].notes.length; j++)
            {
                //Fix up note tags
                model.backpacks[i].notes[j].tags.sort(
                    function(a, b) {
                        if (a.tag.toLowerCase() < b.tag.toLowerCase()) return -1;
                        if (a.tag.toLowerCase() > b.tag.toLowerCase()) return 1;
                        return 0;
                    });<commit_msg>accounted for invalid player in backpack data for web notebook<commit_after>function Controller()
{
    var self = this; //<- I hate javascript.
    this.setLayout = function(sender)
    {
        switch(sender)
        {
            case model.views.mapLayoutButton:
                model.views.listLayoutButton.deselect();
                model.views.listLayout.style.display = 'none';
                model.views.sortSelector.style.display = 'none';
                model.views.mapLayout.style.display = 'block';
                model.views.mapNoteViewContainer.appendChild(model.views.noteView.html);
                break;
            case model.views.listLayoutButton:
                model.views.mapLayoutButton.deselect();
                model.views.mapLayout.style.display = 'none';
                model.views.sortSelector.style.display = 'block';
                model.views.listLayout.style.display = 'block';
                model.views.listNoteViewContainer.appendChild(model.views.noteView.html);
                break;
        }
    };
    this.setSort = function(sender)
    {
        switch(sender)
        {
            case model.views.contributorSortButton:
                model.views.tagSortButton.deselect();
                model.views.popularitySortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '245px';
                model.views.noteListSelectorContainer.style.margin = '10px 0px 0px 0px';
                model.views.noteListSelector.style.height = '223px';
                model.views.tagListFilterSelectorContainer.style.display = 'none';
                model.views.contributorListFilterSelectorContainer.style.display = 'block';
                self.populateNotesByContributor();
                break;
            case model.views.tagSortButton:
                model.views.contributorSortButton.deselect();
                model.views.popularitySortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '245px';
                model.views.noteListSelectorContainer.style.margin = '10px 0px 0px 0px';
                model.views.noteListSelector.style.height = '223px';
                model.views.contributorListFilterSelectorContainer.style.display = 'none';
                model.views.tagListFilterSelectorContainer.style.display = 'block';
                self.populateNotesByTag();
                break;
            case model.views.popularitySortButton:
                model.views.contributorSortButton.deselect();
                model.views.tagSortButton.deselect();
                model.views.noteListSelectorContainer.style.height = '500px';
                model.views.noteListSelectorContainer.style.margin = '0px 0px 0px 0px';
                model.views.noteListSelector.style.height = '478px';
                model.views.contributorListFilterSelectorContainer.style.display = 'none';
                model.views.tagListFilterSelectorContainer.style.display = 'none';
                self.populateNotesByPopularity();
                break;
        }
    };

    this.mapContributorClicked = function(sender, selected) 
    {
        self.populateMapNotes(false);
    };
    this.selectAllMapContributors = function() 
    {
        for(var i = 0; i < model.contributorMapCells.length; i++)
            model.contributorMapCells[i].select();
        self.populateMapNotes(false);
    };
    this.deselectAllMapContributors = function()
    {
        for(var i = 0; i < model.contributorMapCells.length; i++)
            model.contributorMapCells[i].deselect();
        self.populateMapNotes(false);
    };
    this.mapTagClicked = function(sender,selected) 
    {
        self.populateMapNotes(false);
    };
    this.selectAllMapTags = function()
    {
        for(var i = 0; i < model.tagMapCells.length; i++)
            model.tagMapCells[i].select();
        self.populateMapNotes(false);
    };
    this.deselectAllMapTags = function()
    {
        for(var i = 0; i < model.tagMapCells.length; i++)
            model.tagMapCells[i].deselect();
        self.populateMapNotes(false);
    };
    this.listContributorClicked = function(sender,selected) 
    {
        self.populateNotesByContributor();
    };
    this.selectAllListContributors = function()
    {
        for(var i = 0; i < model.contributorListCells.length; i++)
            model.contributorListCells[i].select();
        self.populateNotesByContributor();
    };
    this.deselectAllListContributors = function()
    {
        for(var i = 0; i < model.contributorListCells.length; i++)
            model.contributorListCells[i].deselect();
        self.populateNotesByContributor();
    };
    this.listTagClicked = function(sender,selected)
    {
        self.populateNotesByTag();
    };
    this.selectAllListTags = function()
    {
        for(var i = 0; i < model.tagListCells.length; i++)
            model.tagListCells[i].select();
        self.populateNotesByTag();
    };
    this.deselectAllListTags = function()
    {
        for(var i = 0; i < model.tagListCells.length; i++)
            model.tagListCells[i].deselect();
        self.populateNotesByTag();
    };
    this.noteSelected = function(sender) 
    {
        var note = sender.object;
        var html = model.views.constructNoteView.cloneNode(true);
        model.views.noteView = new NoteView(html, note);
        model.views.mapNoteViewContainer.innerHTML = '';
        model.views.listNoteViewContainer.innerHTML = '';
        if(model.views.mapLayoutButton.selected)
        {
            model.views.mapNoteViewContainer.appendChild(model.views.mapNoteViewCloseButton.html);
            model.views.mapNoteViewContainer.appendChild(model.views.noteView.html);
            model.views.mapNoteViewContainer.style.display = 'block';
            setTimeout(function() { model.views.mapLayout.addEventListener('click', controller.hideMapNoteView, false); }, 100); //timeout to disallow imediate hiding
        }
        if(model.views.listLayoutButton.selected) 
        {
            model.views.listNoteViewContainer.appendChild(model.views.noteView.html);
            if(model.views.contributorSortButton.selected) for(var i = 0; i < model.views.contributorNoteCells.length; i++) model.views.contributorNoteCells[i].deselect();
            if(model.views.tagSortButton.selected) for(var i = 0; i < model.views.tagNoteCells.length; i++) model.views.tagNoteCells[i].deselect();
            if(model.views.popularitySortButton.selected) for(var i = 0; i < model.views.popularNoteCells.length; i++) model.views.popularNoteCells[i].deselect();
        }
    };

    this.populateModel = function(gameData)
    {
        model.gameData = gameData;

        model.backpacks = model.gameData.backpacks;
        for(var i = 0; i < model.backpacks.length; i++)
        {
            if(model.backpacks = "Invalid Player ID") continue;
            for(var j = 0; j < model.backpacks[i].notes.length; j++)
            {
                //Fix up note tags
                model.backpacks[i].notes[j].tags.sort(
                    function(a, b) {
                        if (a.tag.toLowerCase() < b.tag.toLowerCase()) return -1;
                        if (a.tag.toLowerCase() > b.tag.toLowerCase()) return 1;
                        return 0;
                    });
{'fraction_non_alphanumeric': 0.11518648258808985, 'fraction_numerical': 0.007005975685143211, 'mean_word_length': 2.190883190883191, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '5824664', 'n_tokens_mistral': 4288, 'n_tokens_neox': 3967, 'n_words': 570}