<commit_before>var Fangorn = require('js/fangorn').Fangorn;
var m = require('mithril');
var $osf = require('js/osfHelpers');

function FileViewTreebeard(data) {

    // Set item.branch to show the branch of the rendered GitHub / Bitbucket file instead of the default branch
    var addonRootFolders = data.data[0].children;

    if (window.contextVars.file.provider === 'github' || window.contextVars.file.provider === 'bitbucket') {
        for (var i = 0; i < addonRootFolders.length; i++) {
            var item = addonRootFolders[i];
            if (
                (item.provider === 'github' || item.provider === 'bitbucket') &&
                    item.isAddonRoot && window.contextVars.file.extra.branch
            ) {
                item.branch = window.contextVars.file.extra.branch;
            }
        }
    }

    var fangornOpts = {
        divID: 'grid',
        filesData: data.data,
        uploads: false,
        showFilter: false,
        title: undefined,
        hideColumnTitles: true,
        multiselect : true,
        placement : 'fileview',
        allowMove : false,
        filterTemplate: function () {
            var tb = this;
            return m('input.pull-left.form-control[placeholder="' + tb.options.filterPlaceholder + '"][type="text"]', {
                style: 'width:100%;display:inline;',
                onkeyup: tb.filter,
                value: tb.filterText()
            });
        },
        xhrconfig: $osf.setXHRAuthorization,
        onload: function(tree) {
            var tb = this;
            Fangorn.DefaultOptions.onload.call(tb, tree);
        },
        ondataload: function () {
            var tb = this;
            var path = '';
            tb.fangornFolderIndex = 0;
            tb.fangornFolderArray = [''];
            if (window.contextVars.file.path) {
                tb.fangornFolderArray = window.contextVars.file.materializedPath.split('/');
                if (tb.fangornFolderArray.length > 1) {<commit_msg>Fix file browser on file detail page<commit_after>var Fangorn = require('js/fangorn').Fangorn;
var m = require('mithril');
var $osf = require('js/osfHelpers');

function FileViewTreebeard(data) {

    // Set item.branch to show the branch of the rendered GitHub / Bitbucket file instead of the default branch
    var addonRootFolders = data.data[0].children;

    if (window.contextVars.file.provider === 'github' || window.contextVars.file.provider === 'bitbucket') {
        for (var i = 0; i < addonRootFolders.length; i++) {
            var item = addonRootFolders[i];
            if (
                (item.provider === 'github' || item.provider === 'bitbucket') &&
                    item.isAddonRoot && window.contextVars.file.extra.branch
            ) {
                item.branch = window.contextVars.file.extra.branch;
            }
        }
    }

    var fangornOpts = {
        divID: 'grid',
        filesData: data.data,
        uploads: false,
        showFilter: false,
        title: undefined,
        hideColumnTitles: true,
        multiselect : true,
        placement : 'fileview',
        allowMove : false,
        filterTemplate: function () {
            var tb = this;
            return m('input.pull-left.form-control[placeholder="' + tb.options.filterPlaceholder + '"][type="text"]', {
                style: 'width:100%;display:inline;',
                onkeyup: tb.filter,
                value: tb.filterText()
            });
        },
        xhrconfig: $osf.setXHRAuthorization,
        onload: function(tree) {
            var tb = this;
            Fangorn.DefaultOptions.onload.call(tb, tree);
        },
        ondataload: function () {
            var tb = this;
            Fangorn.DefaultOptions.ondataload.call(tb);
            var path = '';
            tb.fangornFolderIndex = 0;
            tb.fangornFolderArray = [''];
            if (window.contextVars.file.path) {
                tb.fangornFolderArray = window.contextVars.file.materializedPath.split('/');
                if (tb.fangornFolderArray.length > 1) {
{'fraction_non_alphanumeric': 0.125030765444253, 'fraction_numerical': 0.0034457297563376815, 'mean_word_length': 1.9216391085549964, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4654746', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1171, 'n_words': 239}