<commit_before>require(['lib/knockout', 'Connector', 'Brain', 'History', 'Messenger', 'constants/MergeConstant',
    'constants/HistoryConstant', 'constants/NotificationConstant', 'view/ConfigViewModel', 'view/DynamicViewModel',
    'utils/getValues', 'utils/parseUrlParams', 'UrlJuggler', 'utils/generateId', 'constants/InputConstant', 'App',
    'ConnectionManager', 'HistoryManager', 'SubscriptionManager',
    'lib/domReady'], function (ko, Connector, Brain, History, Messenger, MergeConstant, HistoryConstant, NotificationConstant, ConfigViewModel, DynamicViewModel, getValues, parseUrlParams, UrlJuggler, generateId, InputConstant, App, ConnectionManager, HistoryManager, SubscriptionManager) {

    var URL = location.origin;
    var LOCAL_CSS = "label-info";
    var REMOTE_CSS = "label-warning";

    var connector = new Connector();
    var brain = new Brain();
    var history = new History();
    var messenger = new Messenger();
    var urlJuggler = new UrlJuggler(location.pathname, window.history.pushState.bind(window.history));
    var urlParams = parseUrlParams(location.search);


    var mergeParam = urlParams['merge'];
    var mergeStrategy = mergeParam !== undefined ? mergeParam : MergeConstant.PLAIN;
    var historyParam = urlParams['history'];
    var historyStrategy = historyParam !== undefined ? historyParam : HistoryConstant.BY_TIME;
    var notifyParam = urlParams['notification'];
    var notificationStrategy = notifyParam !== undefined ? notifyParam : NotificationConstant.BUBBLE;

    var configView = new ConfigViewModel(getValues(MergeConstant), getValues(HistoryConstant),
        getValues(NotificationConstant),
        mergeStrategy, historyStrategy, notificationStrategy, urlParams['user']);

    var userName = urlParams['user'];

    if (userName !== undefined) {
        brain.userId = userName;
    }

    var inputIds = [];
    var inputs = document.querySelectorAll('input[id*=' + InputConstant.PREFIX + ']');
    for (var i = 0; i < inputs.length; i++) {
        inputIds.push(inputs[i].id);
    }

    var view = new DynamicViewModel(inputIds, history, configView.history(), configView.merge());

    var isUserUpdate = false;
    ko.bindingHandlers.contentEditable = {
        init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
            var textObservable = valueAccessor().text;
            var htmlObservable = valueAccessor().html;

            element.addEventListener('keyup', function (event) {
                if (event.target.textContent == textObservable())
                    return;

                var selectedNode, anchorOffset, focusOffset, updateDom = false;

                var textNodes = [];
                for (var i = 0; i < event.target.children.length; i++)
                    textNodes.push({css: event.target.children[i].classList[1], text: event.target.children[i].textContent});

                // if it's the 1st character help with init
                if (textNodes.length == 0 && event.target.textContent.length > 0)
                    textNodes.push({css: LOCAL_CSS, text: event.target.textContent});

                if (event.target.textContent.length >= (textObservable() != null ? textObservable() : "").length) {

                    var oldDomNodes = document.createElement("div");
                    oldDomNodes.innerHTML = htmlObservable();<commit_msg>fix user starting on empty element<commit_after>require(['lib/knockout', 'Connector', 'Brain', 'History', 'Messenger', 'constants/MergeConstant',
    'constants/HistoryConstant', 'constants/NotificationConstant', 'view/ConfigViewModel', 'view/DynamicViewModel',
    'utils/getValues', 'utils/parseUrlParams', 'UrlJuggler', 'utils/generateId', 'constants/InputConstant', 'App',
    'ConnectionManager', 'HistoryManager', 'SubscriptionManager',
    'lib/domReady'], function (ko, Connector, Brain, History, Messenger, MergeConstant, HistoryConstant, NotificationConstant, ConfigViewModel, DynamicViewModel, getValues, parseUrlParams, UrlJuggler, generateId, InputConstant, App, ConnectionManager, HistoryManager, SubscriptionManager) {

    var URL = location.origin;
    var LOCAL_CSS = "label-info";
    var REMOTE_CSS = "label-warning";

    var connector = new Connector();
    var brain = new Brain();
    var history = new History();
    var messenger = new Messenger();
    var urlJuggler = new UrlJuggler(location.pathname, window.history.pushState.bind(window.history));
    var urlParams = parseUrlParams(location.search);


    var mergeParam = urlParams['merge'];
    var mergeStrategy = mergeParam !== undefined ? mergeParam : MergeConstant.PLAIN;
    var historyParam = urlParams['history'];
    var historyStrategy = historyParam !== undefined ? historyParam : HistoryConstant.BY_TIME;
    var notifyParam = urlParams['notification'];
    var notificationStrategy = notifyParam !== undefined ? notifyParam : NotificationConstant.BUBBLE;

    var configView = new ConfigViewModel(getValues(MergeConstant), getValues(HistoryConstant),
        getValues(NotificationConstant),
        mergeStrategy, historyStrategy, notificationStrategy, urlParams['user']);

    var userName = urlParams['user'];

    if (userName !== undefined) {
        brain.userId = userName;
    }

    var inputIds = [];
    var inputs = document.querySelectorAll('input[id*=' + InputConstant.PREFIX + ']');
    for (var i = 0; i < inputs.length; i++) {
        inputIds.push(inputs[i].id);
    }

    var view = new DynamicViewModel(inputIds, history, configView.history(), configView.merge());

    var isUserUpdate = false;
    ko.bindingHandlers.contentEditable = {
        init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {

            element.addEventListener('keyup', function (event) {
                var textObservable = valueAccessor().text;
                var htmlObservable = valueAccessor().html;

                if (event.target.textContent == textObservable())
                    return;

                var selectedNode, anchorOffset, focusOffset, updateDom = false;

                var textNodes = [];
                for (var i = 0; i < event.target.children.length; i++)
                    textNodes.push({css: event.target.children[i].classList[1], text: event.target.children[i].textContent});

                // if it's the 1st character help with init
                if (textNodes.length == 0 && event.target.textContent.length > 0) {
                    textNodes.push({css: LOCAL_CSS, text: event.target.textContent});
                    selectedNode = 0;
                    anchorOffset = event.target.textContent.length;
                    focusOffset = event.target.textContent.length;
                    updateDom = true;
                }

                if (event.target.textContent.length >= (textObservable() != null ? textObservable() : "").length) {

                    var oldDomNodes = document.createElement("div");
                    oldDomNodes.innerHTML = htmlObservable();
{'fraction_non_alphanumeric': 0.11972131380634153, 'fraction_numerical': 0.0018484288354898336, 'mean_word_length': 3.250151057401813, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '184120', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1775, 'n_words': 432}