<commit_before>window.onload = function() {


// GLOBAL ARRAYS ----------------------------------------------------

//individuals
var empty = [];

//totals
var calc = [];

//-------------------------------------------------------------------

//REFERENCE VARIABLES -----------------------------------------------

// includes divide symbol after 'TOP Numbers' code.
var ops = ["+", "-", "*"];

var dot = '.';

var dotReg = /\./;

//------------------------------------------------------------------

// TOP Numbers-----------------------------------------------
var theNode = document.getElementById('divide').innerHTML;

// adds divide symbol to 'ops' array
ops.push(theNode);

// var textnode = document.createTextNode(theNode);
//
// document.getElementById('topSpan').appendChild(textnode);4

console.log(document.getElementById('divideAmp').innerHTML);

//------------------------------------------------------------

                     // NUMBERS 1 - 9

var oneNine = document.getElementsByClassName('nonZero');

//ATTACHES EVENT LISTENER TO EACH NUMBER
for (var i = 0; i < oneNine.length; i++) {

    oneNine[i].addEventListener('click', function() {

        //WHEN BUTTON IS CLICKED...

        //variables ------------------------------------------
        var topOp = "no";

        var textNode = document.createTextNode(this.innerHTML);

        var textNode2 = document.createTextNode(this.innerHTML);
        //-----------------------------------------------------

        // pushes # to 'empty' array
        empty.push(this.innerHTML);

        // TOP-DISPLAY FUNCTIONALITY---------------------------

        // checks for op in top-display
        for (var e = 0; e < ops.length; e++) {

            if(ops[e] == document.getElementById('topSpan').innerHTML) {

                topOp = "yes";
            }
        }

        // CLEARS and ADDS # to top-display IF OP in top-display
        if (topOp == 'yes') {
            // clears top-display
            document.getElementById('topSpan').innerHTML = '';
            // adds # to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }

        else {
            // adds # to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }
        //-----------------------------------------------------------

        // BOTTOM-DISPLAY FUNCTIONALITY -----------------------------

        // adds # to bottom-display
        document.getElementById('bottomSpan').appendChild(textNode2);

        //-----------------------------------------------------------

    }); // END OF CURRENT ELEMENT EVENT LISTENER FUNCTION

} // END OF EVENT LISTENER ATTACHING LOOP

//-------------------------------------------------------------------------

                    // DOT BUTTON

//ATTACHES EVENT LISTENER DOT BUTTON
document.getElementById('dot').addEventListener('click', function() {

    //WHEN BUTTON IS CLICKED...

    //variables ------------------------------------------
    var topOp = "no";

    var textNode = document.createTextNode(this.innerHTML);

    var textNode2 = document.createTextNode(this.innerHTML);
    //-----------------------------------------------------

    // TOP-DISPLAY FUNCTIONALITY---------------------------

    // checks for op in top-display
    for (var u = 0; u < ops.length; u++) {

        if(ops[u] == document.getElementById('topSpan').innerHTML) {

            topOp = "yes";
        }
    }

    // if dot NOT in 'empty' array...
    if (empty.join('').match(dotReg) === null) {

        // pushes dot to 'empty' array
        empty.push(dot);

        // CLEARS and ADDS dot to top-display IF OP in top-display
        if (topOp == 'yes') {
            // clears top-display
            document.getElementById('topSpan').innerHTML = '';
            // adds dot to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }

        else {
            // adds dot to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }
        //-------------------------------------------------------

        // BOTTOM-DISPLAY FUNCTIONALITY -----------------------------

        // adds # to bottom-display
        document.getElementById('bottomSpan').appendChild(textNode2);

        //-----------------------------------------------------------

    } // ENDS "if dot NOT in 'empty' array" CONDITIONAL

});
//-------------------------------------------------------------------------


                    // OPERATOR BUTTONS

//ATTACHES EVENT LISTENER OP BUTTONS
var opButtons = document.getElementsByClassName('operator');

//ATTACHES EVENT LISTENER TO EACH NUMBER
for (var r = 0; r < opButtons.length; r++) {

    opButtons[r].addEventListener('click', function() {

        //WHEN BUTTON IS CLICKED...

        // checks for valid number in 'empty' array
        if (empty.length > 1 || empty.length == 1 && empty[0] !== dot) {

            // pushes number currently in top-display to 'calc' array
            calc.push(Number(empty.join('')));

            // pushes op symbol to 'calc' array
            switch(this.innerHTML) {

                case '+':
                    calc.push('add');
                    break;
                case '-':
                    calc.push('minus');
                    break;
                case 'x':
                    calc.push('times');
                    break;
                case theNode:
                    calc.push('divide');
            };

            console.log(calc);
<commit_msg>added  more functionality to operator buttons.<commit_after>window.onload = function() {


// GLOBAL ARRAYS ----------------------------------------------------

//individuals
var empty = [];

//totals
var calc = [];

//-------------------------------------------------------------------

//REFERENCE VARIABLES -----------------------------------------------

// includes divide symbol after 'TOP Numbers' code.
var ops = ["+", "-", "x"];

var dot = '.';

var dotReg = /\./;

//------------------------------------------------------------------

// TOP Numbers-----------------------------------------------
var theNode = document.getElementById('divide').innerHTML;

// adds divide symbol to 'ops' array
ops.push(theNode);

// var textnode = document.createTextNode(theNode);
//
// document.getElementById('topSpan').appendChild(textnode);4

//------------------------------------------------------------

                     // NUMBERS 1 - 9

var oneNine = document.getElementsByClassName('nonZero');

//ATTACHES EVENT LISTENER TO EACH NUMBER
for (var i = 0; i < oneNine.length; i++) {

    oneNine[i].addEventListener('click', function() {

        //WHEN BUTTON IS CLICKED...

        //variables ------------------------------------------
        var topOp = "no";

        var textNode = document.createTextNode(this.innerHTML);

        var textNode2 = document.createTextNode(this.innerHTML);
        //-----------------------------------------------------

        // pushes # to 'empty' array
        empty.push(this.innerHTML);

        // TOP-DISPLAY FUNCTIONALITY---------------------------

        // checks for op in top-display
        for (var e = 0; e < ops.length; e++) {

            if(ops[e] == document.getElementById('topSpan').innerHTML) {

                topOp = "yes";
            }
        }

        // CLEARS and ADDS # to top-display IF OP in top-display
        if (topOp == 'yes') {
            // clears top-display
            document.getElementById('topSpan').innerHTML = '';
            // adds # to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }

        else {
            // adds # to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }
        //-----------------------------------------------------------

        // BOTTOM-DISPLAY FUNCTIONALITY -----------------------------

        // adds # to bottom-display
        document.getElementById('bottomSpan').appendChild(textNode2);

        //-----------------------------------------------------------

    }); // END OF CURRENT ELEMENT EVENT LISTENER FUNCTION

} // END OF EVENT LISTENER ATTACHING LOOP

//-------------------------------------------------------------------------

                    // DOT BUTTON

//ATTACHES EVENT LISTENER DOT BUTTON
document.getElementById('dot').addEventListener('click', function() {

    //WHEN BUTTON IS CLICKED...

    //variables ------------------------------------------
    var topOp = "no";

    var textNode = document.createTextNode(this.innerHTML);

    var textNode2 = document.createTextNode(this.innerHTML);
    //-----------------------------------------------------

    // TOP-DISPLAY FUNCTIONALITY---------------------------

    // checks for op in top-display
    for (var u = 0; u < ops.length; u++) {

        if(ops[u] == document.getElementById('topSpan').innerHTML) {

            topOp = "yes";
        }
    }

    // if dot NOT in 'empty' array...
    if (empty.join('').match(dotReg) === null) {

        // pushes dot to 'empty' array
        empty.push(dot);

        // CLEARS and ADDS dot to top-display IF OP in top-display
        if (topOp == 'yes') {
            // clears top-display
            document.getElementById('topSpan').innerHTML = '';
            // adds dot to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }

        else {
            // adds dot to top-display
            document.getElementById('topSpan').appendChild(textNode);
        }
        //-------------------------------------------------------

        // BOTTOM-DISPLAY FUNCTIONALITY -----------------------------

        // adds # to bottom-display
        document.getElementById('bottomSpan').appendChild(textNode2);

        //-----------------------------------------------------------

    } // ENDS "if dot NOT in 'empty' array" CONDITIONAL

});
//-------------------------------------------------------------------------


                    // OPERATOR BUTTONS

//ATTACHES EVENT LISTENER OP BUTTONS
var opButtons = document.getElementsByClassName('operator');

//ATTACHES EVENT LISTENER TO EACH NUMBER
for (var r = 0; r < opButtons.length; r++) {

    opButtons[r].addEventListener('click', function() {

        //WHEN BUTTON IS CLICKED...

        //variables ------------------------------------------

        var textNode = document.createTextNode(this.innerHTML);

        var textNode2 = document.createTextNode(this.innerHTML);
        //-----------------------------------------------------

        // checks for valid number in 'empty' array
        if (empty.length > 1 || empty.length == 1 && empty[0] !== dot) {

            // pushes number currently in top-display to 'calc' array
            calc.push(Number(empty.join('')));

            // pushes correct OP symbol to 'calc' array
            switch(this.innerHTML) {

                case '+':
                    calc.push('add');
                    break;
                case '-':
                    calc.push('minus');
                    break;
                case 'x':
                    calc.push('times');
                    break;
                case theNode:
                    calc.push('divide');
            };

            // TOP-DISPLAY FUNCTIONALITY -----------------------------

            // adds OP to top-display

            // clears top-display
            document.getElementById('topSpan').innerHTML = '';
            // adds OP to top-display
            document.getElementById('topSpan').appendChild(textNode);

            //-----------------------------------------------------------

            // BOTTOM-DISPLAY FUNCTIONALITY -----------------------------

            // adds OP to bottom-display
            document.getElementById('bottomSpan').appendChild(textNode2);

            //-----------------------------------------------------------

            empty = [];

{'fraction_non_alphanumeric': 0.2972749109583368, 'fraction_numerical': 0.002484883624616914, 'mean_word_length': 1.0611130078525093, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '2295007', 'n_tokens_mistral': 2880, 'n_tokens_neox': 2688, 'n_words': 660}