<commit_before>{% extends "cloud_browser/admin/base.html" %}

{% comment %}
###############################################################################
# Browser
#
# Admin version (for integration in Django admin area).
###############################################################################
{% endcomment %}

{% load adminmedia %}
{% load cloud_browser_extras %}

{% block title %}
Cloud Browser - {{ path }}
{% endblock %}

{% block cloud_browser_breadcrumbs %}
    {% include "cloud_browser/_breadcrumbs.html" %}
{% endblock %}

{% block cloud_browser_template_head %}
{# Use jQuery from Admin #}
<script type="text/javascript" 
        src="{% admin_media_prefix %}js/jquery.js"></script>
<script type="text/javascript" 
        src="{% admin_media_prefix %}js/jquery.init.js"></script>

{% cloud_browser_media_link "css/cloud-browser.css" %}
{% cloud_browser_media_link "css/cloud-browser-admin.css" %}
{% cloud_browser_media_link "js/browser.js" %}

<script type="text/javascript">
(function ($) {
    /**
     * Set state on all links.
     */
    var setLinkState = function ($allLinks, $allForms, closed) {
        closed = closed === true;

        var patchQuery = function (query) {
            var queryObj = CloudBrowser.getQueryObj(query);
            queryObj.params.closed = closed ? '1' : '0';
            return CloudBrowser.toQueryString(queryObj);
        };

        $allLinks.each(function (index, element) {
            var $element = $(element);
            $element.attr('href', patchQuery($element.attr('href')));
        });

        $allForms.each(function (index, element) {
            var $element = $(element);
            $element.attr('action', patchQuery($element.attr('action')));
        });
    }

    /**
     * Add all hider elements to page.
     */
    var addHider = function ($all, $conts, $objs, closed, hiderCallback) {
        closed = closed === true;
        hiderCallback = hiderCallback || function () {};

        // Add show/hide "hider" element.
        var hiderOpen = "-";
        var hiderClosed = "+";
        var $hiderOuter = $('<div />').
            attr('id', "cloud-browser-containers-hider-outer").
            prependTo($conts);
        var $hiderFull = $('<div />').
            addClass("cloud-browser-containers-hider").
            text(hiderOpen).
            prependTo($hiderOuter);

        // Add hidden "minimized" element.
        var $hiderMin = $hiderFull.clone().text(hiderClosed);
        var $min = $('<div />').
            attr('id', "cloud-browser-containers-min").
            height($objs.height()).
            hide().
            append($hiderMin).
            prependTo($all);

        var objsOpenMargin = $objs.css('marginLeft');
        var objsClosedMargin = $min.width() + 10;

        // Initial setup.
        if (closed) {
            $conts.hide();
            $min.show();
            $objs.css('marginLeft', objsClosedMargin);
        }

        var closeFn = function () {
            // Currently open. Close.
            $conts.fadeOut('fast', function () {
                $min.fadeIn('fast');
                $objs.css('marginLeft', objsClosedMargin);
                hiderCallback(true /* closed */);
            });
        }

        var openFn = function () {
            // Currently closed. Open.
            $min.fadeOut('fast', function () {
                $conts.fadeIn('fast');
                $objs.css('marginLeft', objsOpenMargin);
                hiderCallback(false /* opened */);
            });
        };
        
        // Toggle Functions.
        $hiderFull.click(closeFn);
        $hiderMin.click(openFn);
    };

    $(document).ready(function ($) {
        // Elements.
        var $all = $('#cloud-browser-all');
        var $conts = $('#cloud-browser-containers');
        var $objs = $('#cloud-browser-objects');

        // Detect current state from URL.
        var currentUrl = window.location.href;
        var queryObj = CloudBrowser.getQueryObj(currentUrl);
        var closed = queryObj.params.closed === '1';

        // Gather all links.
        var $allLinks = $('.cloud-browser-document-link');
        var $allForms = $('.cloud-browser-form');

        // Setup initial link state.
        setLinkState($allLinks, $allForms, closed);<commit_msg>Admin: Add breadcrumb links to also keep state.<commit_after>{% extends "cloud_browser/admin/base.html" %}

{% comment %}
###############################################################################
# Browser
#
# Admin version (for integration in Django admin area).
###############################################################################
{% endcomment %}

{% load adminmedia %}
{% load cloud_browser_extras %}

{% block title %}
Cloud Browser - {{ path }}
{% endblock %}

{% block cloud_browser_breadcrumbs %}
    {% include "cloud_browser/_breadcrumbs.html" %}
{% endblock %}

{% block cloud_browser_template_head %}
{# Use jQuery from Admin #}
<script type="text/javascript" 
        src="{% admin_media_prefix %}js/jquery.js"></script>
<script type="text/javascript" 
        src="{% admin_media_prefix %}js/jquery.init.js"></script>

{% cloud_browser_media_link "css/cloud-browser.css" %}
{% cloud_browser_media_link "css/cloud-browser-admin.css" %}
{% cloud_browser_media_link "js/browser.js" %}

<script type="text/javascript">
(function ($) {
    /**
     * Set state on all links.
     */
    var setLinkState = function ($allLinks, $allForms, closed) {
        closed = closed === true;

        var patchQuery = function (query) {
            var queryObj = CloudBrowser.getQueryObj(query);
            queryObj.params.closed = closed ? '1' : '0';
            return CloudBrowser.toQueryString(queryObj);
        };

        $allLinks.each(function (index, element) {
            var $element = $(element);
            $element.attr('href', patchQuery($element.attr('href')));
        });

        $allForms.each(function (index, element) {
            var $element = $(element);
            $element.attr('action', patchQuery($element.attr('action')));
        });
    }

    /**
     * Add all hider elements to page.
     */
    var addHider = function ($all, $conts, $objs, closed, hiderCallback) {
        closed = closed === true;
        hiderCallback = hiderCallback || function () {};

        // Add show/hide "hider" element.
        var hiderOpen = "-";
        var hiderClosed = "+";
        var $hiderOuter = $('<div />').
            attr('id', "cloud-browser-containers-hider-outer").
            prependTo($conts);
        var $hiderFull = $('<div />').
            addClass("cloud-browser-containers-hider").
            text(hiderOpen).
            prependTo($hiderOuter);

        // Add hidden "minimized" element.
        var $hiderMin = $hiderFull.clone().text(hiderClosed);
        var $min = $('<div />').
            attr('id', "cloud-browser-containers-min").
            height($objs.height()).
            hide().
            append($hiderMin).
            prependTo($all);

        var objsOpenMargin = $objs.css('marginLeft');
        var objsClosedMargin = $min.width() + 10;

        // Initial setup.
        if (closed) {
            $conts.hide();
            $min.show();
            $objs.css('marginLeft', objsClosedMargin);
            hiderCallback(true /* closed */);
        }

        var closeFn = function () {
            // Currently open. Close.
            $conts.fadeOut('fast', function () {
                $min.fadeIn('fast');
                $objs.css('marginLeft', objsClosedMargin);
                hiderCallback(true /* closed */);
            });
        }

        var openFn = function () {
            // Currently closed. Open.
            $min.fadeOut('fast', function () {
                $conts.fadeIn('fast');
                $objs.css('marginLeft', objsOpenMargin);
                hiderCallback(false /* opened */);
            });
        };
        
        // Toggle Functions.
        $hiderFull.click(closeFn);
        $hiderMin.click(openFn);
    };

    $(document).ready(function ($) {
        // Elements.
        var $all = $('#cloud-browser-all');
        var $conts = $('#cloud-browser-containers');
        var $objs = $('#cloud-browser-objects');

        // Detect current state from URL.
        var currentUrl = window.location.href;
        var queryObj = CloudBrowser.getQueryObj(currentUrl);
        var closed = queryObj.params.closed === '1';

        // Gather all links.
        var $allLinks = $(
            '.cloud-browser-document-link, .cloud-browser-breadcrumb-link');
        console.log($allLinks);
        var $allForms = $('.cloud-browser-form');

        // Setup initial link state.
        setLinkState($allLinks, $allForms, closed);
{'fraction_non_alphanumeric': 0.1876782658300057, 'fraction_numerical': 0.0011409013120365088, 'mean_word_length': 2.1864776444929115, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5933013', 'n_tokens_mistral': 2568, 'n_tokens_neox': 2430, 'n_words': 490}