<commit_before>/* global $C */
/* global chrome */
/* global $CR */
(function() {
    'use strict';

    var updatePanelTimer;
    var currentFrames;
    var currentFrameId;
    var currentDetails;
    var newFrameId;
    var lastExpose;
    var framesNode;
    var detailsNode;

    $C.define('template', function(item, index, arr, args) {
        lastExpose = $C.tpl[args[0]].apply(this, Array.prototype.slice.call(args, 1));
    });

    window.conkittyRoutePanelUpdate = conkittyRoutePanelUpdate;
    window.conkittyRoutePanelUpdatePause = conkittyRoutePanelUpdatePause;

    document.addEventListener('click', function(e) {
        var node = e.target,
            id = null,
            index = null;

        while (node &&
               (((id = node.getAttribute('frame-id')) === null)) &&
               (((index = node.getAttribute('tag-index'))) === null))
        {
            node = node.parentNode;
        }

        if (id !== null) {
            newFrameId = id;
            conkittyRoutePanelUpdate();
        }

        if (index !== null) {
            chrome.devtools.inspectedWindow.eval('(' + __inspectElement.toString() + ')(' + index + ', ' + (JSON.stringify(newFrameId)) + ')');
        }
    }, false);


    function conkittyRoutePanelUpdate() {
        if (updatePanelTimer) { clearTimeout(updatePanelTimer); }

        chrome.devtools.inspectedWindow.eval('(' + __serializeRouter.toString() + ')(' + (JSON.stringify(newFrameId)) + ')', function(frames) {
            if (frames !== undefined) {
                if (frames) {
                    if (!currentFrames || currentFrames === true) {
                        $C(document.body, true).template('panel').end();
                        framesNode = lastExpose.frames;
                        detailsNode = lastExpose.details;
                    }

                    if ((currentFrames !== frames) || (currentFrameId !== newFrameId)) {
                        currentFrames = frames;
                        currentFrameId = newFrameId;

                        $C(framesNode, true).template('frames', JSON.parse(frames), currentFrameId).end();

                        var tmpJSON = JSON.stringify(lastExpose || null);
                        if (tmpJSON !== currentDetails) {
                            currentDetails = tmpJSON;
                            $C(detailsNode, true).template('details', lastExpose).end();
                        }
                    }
                } else {
                    if (currentFrames !== true) {
                        currentFrames = true;
                        currentFrameId = newFrameId = undefined;
                        tmpJSON = null;
                        $C(document.body, true).template('nothing', 'Conkitty Route is not running').end();
                    }
                }
            } else {
                if (currentFrames !== false) {
                    currentFrames = false;
                    currentFrameId = newFrameId = undefined;
                    tmpJSON = null;
                    $C(document.body, true).template('nothing').end();
                }
            }

            updatePanelTimer = setTimeout(function() {
                updatePanelTimer = null;
                conkittyRoutePanelUpdate();
            }, 300);
        });
    }


    function conkittyRoutePanelUpdatePause() {
        if (updatePanelTimer) {
            clearTimeout(updatePanelTimer);
            updatePanelTimer = null;
        }
    }


    function __serializeRouter(currentFrameId) {
        // This function will run in the context of the inspectedWindow and
        // should return JSON serializable structure.
        if (window.$CR) {
            if ($CR._debug) {
                var ret = [];
                serializeFrames($CR._debug.f, ret);
                return JSON.stringify(ret);
            } else {
                return JSON.stringify(null);
            }
        }

        function serializeFrames(frames, ret) {
            var i,
                frame,
                f,
                status;

            for (i = 0; i < frames.length; i++) {
                frame = frames[i];

                if (frame._data && (typeof frame._data.reject === 'function')) {
                    status = 'loading';
                } else if (frame._dataError) {
                    status = 'error';
                } else if (frame._data !== undefined) {<commit_msg>Progress indication fix for the newer version.<commit_after>/* global $C */
/* global chrome */
/* global $CR */
(function() {
    'use strict';

    var updatePanelTimer;
    var currentFrames;
    var currentFrameId;
    var currentDetails;
    var newFrameId;
    var lastExpose;
    var framesNode;
    var detailsNode;

    $C.define('template', function(item, index, arr, args) {
        lastExpose = $C.tpl[args[0]].apply(this, Array.prototype.slice.call(args, 1));
    });

    window.conkittyRoutePanelUpdate = conkittyRoutePanelUpdate;
    window.conkittyRoutePanelUpdatePause = conkittyRoutePanelUpdatePause;

    document.addEventListener('click', function(e) {
        var node = e.target,
            id = null,
            index = null;

        while (node &&
               (((id = node.getAttribute('frame-id')) === null)) &&
               (((index = node.getAttribute('tag-index'))) === null))
        {
            node = node.parentNode;
        }

        if (id !== null) {
            newFrameId = id;
            conkittyRoutePanelUpdate();
        }

        if (index !== null) {
            chrome.devtools.inspectedWindow.eval('(' + __inspectElement.toString() + ')(' + index + ', ' + (JSON.stringify(newFrameId)) + ')');
        }
    }, false);


    function conkittyRoutePanelUpdate() {
        if (updatePanelTimer) { clearTimeout(updatePanelTimer); }

        chrome.devtools.inspectedWindow.eval('(' + __serializeRouter.toString() + ')(' + (JSON.stringify(newFrameId)) + ')', function(frames) {
            if (frames !== undefined) {
                if (frames) {
                    if (!currentFrames || currentFrames === true) {
                        $C(document.body, true).template('panel').end();
                        framesNode = lastExpose.frames;
                        detailsNode = lastExpose.details;
                    }

                    if ((currentFrames !== frames) || (currentFrameId !== newFrameId)) {
                        currentFrames = frames;
                        currentFrameId = newFrameId;

                        $C(framesNode, true).template('frames', JSON.parse(frames), currentFrameId).end();

                        var tmpJSON = JSON.stringify(lastExpose || null);
                        if (tmpJSON !== currentDetails) {
                            currentDetails = tmpJSON;
                            $C(detailsNode, true).template('details', lastExpose).end();
                        }
                    }
                } else {
                    if (currentFrames !== true) {
                        currentFrames = true;
                        currentFrameId = newFrameId = undefined;
                        tmpJSON = null;
                        $C(document.body, true).template('nothing', 'Conkitty Route is not running').end();
                    }
                }
            } else {
                if (currentFrames !== false) {
                    currentFrames = false;
                    currentFrameId = newFrameId = undefined;
                    tmpJSON = null;
                    $C(document.body, true).template('nothing').end();
                }
            }

            updatePanelTimer = setTimeout(function() {
                updatePanelTimer = null;
                conkittyRoutePanelUpdate();
            }, 300);
        });
    }


    function conkittyRoutePanelUpdatePause() {
        if (updatePanelTimer) {
            clearTimeout(updatePanelTimer);
            updatePanelTimer = null;
        }
    }


    function __serializeRouter(currentFrameId) {
        // This function will run in the context of the inspectedWindow and
        // should return JSON serializable structure.
        if (window.$CR) {
            if ($CR._debug) {
                var ret = [];
                serializeFrames($CR._debug.f, ret);
                return JSON.stringify(ret);
            } else {
                return JSON.stringify(null);
            }
        }

        function serializeFrames(frames, ret) {
            var i,
                frame,
                f,
                status;

            for (i = 0; i < frames.length; i++) {
                frame = frames[i];

                if (frame._l) {
                    status = 'loading';
                } else if (frame._dataError) {
                    status = 'error';
                } else if (frame._data !== undefined) {
{'fraction_non_alphanumeric': 0.11759405271457536, 'fraction_numerical': 0.0013516557783284523, 'mean_word_length': 1.4412977728897443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2180244', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2131, 'n_words': 459}