<commit_before>var Formula = function () {
    this.init();
};
(function () {
    var importBar = $G('J_importBar'),
        textEditor = $G('J_textarea'),
        outputBar = $G('J_outputBar'),
        bk;

    Formula.prototype = {
        init:function () {
            var me = this;
            window.onload = function () {
                editor._MathJaxList = [];
                me._initTextEditor();//初始化文本输入区域
                me._initImportBar();//初始化输入工具栏
                me._initOutputBar();//同步编辑器中的字体大小与公式一致
                me._autoShowRes();//自动显示结果
            };
        },
        _initTextEditor:function () {
            var me = this;
            textEditor.focus();

            domUtils.on(textEditor, "mouseup", function () {
                document.selection && (bk = document.selection.createRange().getBookmark());
            });
            domUtils.on(textEditor, "keyup", function () {
                me._updateFormula.call(this, this.value);
            });
        },
        _initImportBar:function () {
            var me=this;

            domUtils.on(importBar, "click", function (e) {
                var target = e.target || e.srcElement,
                    signal,
                    posStart,
                    posEnd;
                if (target.tagName.toLowerCase() === 'td' && (signal = target.getAttribute('data'))) {
                    if (!((posStart = textEditor.selectionStart) != undefined && (posEnd = textEditor.selectionEnd) != undefined)) {
                        var range = textEditor.createTextRange();
                        range.moveToBookmark(bk);
                        range.select();
                        var pos = me._getPos();
                        posStart = pos[0];
                        posEnd = pos[1];
                    }
                    textEditor.value = textEditor.value.slice(0, posStart) + signal + textEditor.value.slice(posEnd);
                    me._updateFormula(textEditor.value);
                }
            });
        },
        _initOutputBar:function () {
            outputBar.style.fontSize = domUtils.getComputedStyle(editor.selection.getRange().startContainer, 'font-size');
        },
        _autoShowRes:function () {
            if (editor.queryCommandState("formula")) {
                var range = editor.selection.getRange(),
                    ele = domUtils.findParent(range.startContainer, function (node) {
                        return node.nodeType == 1 && node.tagName.toLowerCase() == 'span' && domUtils.hasClass(node, 'MathJax')
                    }, true);<commit_msg>[fixed] byxuheng<commit_after>var Formula = function () {
    this.init();
};
(function () {
    var importBar = $G('J_importBar'),
        textEditor = $G('J_textarea'),
        outputBar = $G('J_outputBar'),
        bk;

    Formula.prototype = {
        init:function () {
            var me = this;
            window.onload = function () {
                editor._MathJaxList = [];
                me._initTextEditor();//初始化文本输入区域
                me._initImportBar();//初始化输入工具栏
                me._initOutputBar();//同步编辑器中的字体大小与公式一致
                me._autoShowRes();//自动显示结果
            };
        },
        _initTextEditor:function () {
            var me = this;
            textEditor.focus();

            domUtils.on(textEditor, "mouseup", function () {
                document.selection && (bk = document.selection.createRange().getBookmark());
            });
            domUtils.on(textEditor, "keyup", function () {
                me._updateFormula.call(this, this.value);
            });
        },
        _initImportBar:function () {
            var me=this;

            domUtils.on(importBar, "click", function (e) {
                var target = e.target || e.srcElement,
                    signal,
                    posStart,
                    posEnd;
                if (target.tagName.toLowerCase() === 'td' && (signal = target.getAttribute('data'))) {
                    if (!((posStart = textEditor.selectionStart) != undefined && (posEnd = textEditor.selectionEnd) != undefined)) {
                        var range = textEditor.createTextRange();
                        range.moveToBookmark(bk);
                        range.select();
                        var pos = me._getPos();
                        posStart = pos[0];
                        posEnd = pos[1];
                    }
                    textEditor.value = textEditor.value.slice(0, posStart) + signal + textEditor.value.slice(posEnd);
                    me._updateFormula(textEditor.value);
                }
            });
        },
        _initOutputBar:function () {
            outputBar.style.fontSize = domUtils.getComputedStyle(editor.selection.getRange().startContainer, 'font-size');
        },
        _autoShowRes:function () {
            var me=this;
            if (editor.queryCommandState("formula")) {
                var range = editor.selection.getRange(),
                    ele = domUtils.findParent(range.startContainer, function (node) {
                        return node.nodeType == 1 && node.tagName.toLowerCase() == 'span' && domUtils.hasClass(node, 'MathJax')
                    }, true);
{'fraction_non_alphanumeric': 0.1282442748091603, 'fraction_numerical': 0.0015267175572519084, 'mean_word_length': 1.4909695817490494, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1750227', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1387, 'n_words': 216}