<commit_before>var CURRENT_ARTIFACT = {};

function adjustHeight() {
    gadgets.window.adjustHeight();
}

function setActionButtonDisplay(display) {
    var actionBtns = document.getElementById("actionButtons");
    actionBtns.style.display = display;
    adjustHeight();
}

function showActionButtons() {
    setActionButtonDisplay('');
}

function hideActionButtons() {
    setActionButtonDisplay('none');
}

RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, function(ref) {
    CURRENT_ARTIFACT.ref = ref;
    findFormula(CURRENT_ARTIFACT.ref, function(hasFormula) {
        if (hasFormula) {
            showActionButtons();
        }
    });
});

RM.Event.subscribe(RM.Event.ARTIFACT_CLOSED, function(ref) {
    hideActionButtons();
});


function findFormula(ref, cb) {
    RM.Data.getAttributes(ref, [RM.Data.Attributes.FORMAT, 'Formula'], function(opResult) {
        if (opResult.code === RM.OperationResult.OPERATION_OK) {
            var attrs = opResult.data[0];
            if (attrs.values[RM.Data.Attributes.FORMAT] === RM.Data.Formats.WRAPPED && attrs.values['Formula']) {
                CURRENT_ARTIFACT.formula = attrs.values['Formula'];
                cb(true);
            } else {
                cb(false);
            }
        }
    });
}

function loadFormula() {
    if (CURRENT_ARTIFACT.formula) {
        var input = document.getElementById("MathInput");
        input.value = CURRENT_ARTIFACT.formula;
        input.onkeyup();
    }
}
<commit_msg>make formula attr const<commit_after>var CURRENT_ARTIFACT = {},
    FORMULA_ATTR = 'Formula';

function adjustHeight() {
    gadgets.window.adjustHeight();
}

function setActionButtonDisplay(display) {
    var actionBtns = document.getElementById("actionButtons");
    actionBtns.style.display = display;
    adjustHeight();
}

function showActionButtons() {
    setActionButtonDisplay('');
}

function hideActionButtons() {
    setActionButtonDisplay('none');
}

RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, function(ref) {
    CURRENT_ARTIFACT.ref = ref;
    findFormula(CURRENT_ARTIFACT.ref, function(hasFormula) {
        if (hasFormula) {
            showActionButtons();
        }
    });
});

RM.Event.subscribe(RM.Event.ARTIFACT_CLOSED, function(ref) {
    hideActionButtons();
});


function findFormula(ref, cb) {
    RM.Data.getAttributes(ref, [RM.Data.Attributes.FORMAT, FORMULA_ATTR], function(opResult) {
        if (opResult.code === RM.OperationResult.OPERATION_OK) {
            var attrs = opResult.data[0];
            if (attrs.values[RM.Data.Attributes.FORMAT] === RM.Data.Formats.WRAPPED && attrs.values[FORMULA_ATTR]) {
                CURRENT_ARTIFACT.formula = attrs.values[FORMULA_ATTR];
                cb(true);
            } else {
                cb(false);
            }
        }
    });
}

function loadFormula() {
    if (CURRENT_ARTIFACT.formula) {
        var input = document.getElementById("MathInput");
        input.value = CURRENT_ARTIFACT.formula;
        input.onkeyup();
    }
}

{'fraction_non_alphanumeric': 0.13279946613279947, 'fraction_numerical': 0.000667334000667334, 'mean_word_length': 2.9603698811096435, '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': '2377854', 'n_tokens_mistral': 972, 'n_tokens_neox': 940, 'n_words': 131}