<commit_before>"use strict";
//app constructor
function PokitdokApp() {
    this.init();
};
//methods for PokitdokApp object
!(function() {
    PokitdokApp.prototype = {
        constructor: PokitdokApp,
        init: function() {
            this.settings = {
                moduleName: 'PokitdokApp',
                client_id: 'pZG5xNEnHk6aTjj3EgYD',
                client_secr: 'WBoxMy4otoCxChecEGl4Mf3WBSHtppcjh26rGWjY',
                tradingPartnersArr: [],
                retData: "",
                title: 'PokitDok',
                author: 'mmcgraw73'
            };
            this.varSet = {
                pd_orange: '#E88024',
                pd_purp: '#61285f'
            };
            this.addStyleSheet('wwwroot/css/project_x.min.css');
            this.addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
            this.docBuildr();
            this.updateTitle();
            this.addInput();
            this.addButton('submit');
            this.getTradingPartners();


        },
        /*
        load external stylesheet
        @param fileName: 'path/to/stylesheet.css'
        */
        addStyleSheet: function(fileName) {
            var self = this,
                head = document.head,
                link = document.createElement('link');
            link.type = 'text/css';
            link.rel = 'stylesheet';
            link.href = fileName;
            head.appendChild(link);
        },
        /*
        create element and place as child of body
        @param el: str element type
        @param place: 'begin' || 'end'
        @param id: str id of el
        */
        createEle: function(el, place, id) {
            var self = this,
                body = document.getElementsByTagName('body'),
                child = document.createElement(el);
            child.id = id;
            if (place && place === 'begin') {
                body[0].appendChild(child);
            } else body[0].prepend(child);
        },
        //edit beefy.js default title
        updateTitle: function() {
            var self = this,
                title = document.getElementsByTagName('title'),
                body = document.getElementsByTagName('body');
            title[0].innerText = self.settings.title;
            //body[0].insertAdjacentHTML('afterbegin', '<h1 class="author">' + self.settings.author + '</div>');
        },
        docBuildr: function() {
            var self = this;
            for (var i = 0; i < 5; i++) {
                self.createEle('div', 'end', 'div' + i);
            }
        },
        addButton: function(txt) {
            var self = this,
                htmlStr = '<div class="small-30"><button id=' + txt + ' class="square-button">' + txt + '</button></div>',
                div1 = document.getElementById('div1');
            div1.insertAdjacentHTML('beforeend', htmlStr);
        },
        addInput: function() {
            var self = this,
                labelStr = '<div class="small-30"><label id="numLabel" for="tpCount">how many trading partners to view ?</label></div>',
                inputStr = '<div class="small-10"><input type="number" id="tpCount" placeholder="?"></div>',
                div1 = document.getElementById('div1');
            div1.insertAdjacentHTML('afterbegin', labelStr);
            div1.insertAdjacentHTML('beforeend', inputStr);
        },
        //connect + return trading parners json from pokitdok api
        getTradingPartners: function() {
            var self = this,
                cid = self.settings.client_id,
                csc = self.settings.client_secr,
                tparr = self.settings.tradingPartnersArr,
                submit = document.getElementById('submit'),
                tpCount = document.getElementById('tpCount'),
                PokitDok = require('pokitdok-nodejs'),
                pokitdok = new PokitDok(cid, csc),
                loadingStr = '<i style="text-align: center;" class="fa fa-spinner fa-pulse fa-fw"></i>',
                div4 = document.getElementById('div4'),
                div2 = document.getElementById('div2'),
                div3 = document.getElementById('div3'),
                icon = document.querySelector('.fa-spinner');
            div4.insertAdjacentHTML('afterbegin', loadingStr);
            pokitdok.tradingPartners(function(err, res) {
                var i, ilen, tradingPartner, str;
                if (err) {
                    return console.log(err, res.statusCode);
                }
                // print the name and trading_partner_id of each trading partner
                var body = '';
                for (i = 0, ilen = res.data.length; i < ilen; i++) {
                    tradingPartner = res.data[i];
                    tparr.push(tradingPartner);
                    console.log(tparr[i] + '\n');
                }
                //document.body.innerHTML = tparr[0].name + ':' + tparr[0].id;
                self.settings.retData = res.data[0];
                div4.style.display = 'none';
                return self.settings.retData;
            });
            submit.addEventListener('click', function(e) {
                if (tpCount.value > 0 && tpCount.value <= tparr.length && div2.innerHTML === '') {
                    self.createList(tpCount.value);
                    self.updateSpanBackgrounds();
                    self.nameHover();
                } else if (tpCount.value > tparr.length) {
                    alert('whoopsy!! -- the max num is: ' + tparr.length);
                } else {
                    div2.innerHTML = '';
                    div3.innerHTML = '';
                    self.createList(tpCount.value);
                    self.updateSpanBackgrounds();
                    self.nameHover();
                }
            });

        },
        /*
          --createList is the quick + dirty solution for generating table in dom
          --creating external html + using mustache/handlebars for 0.2.0
        */
        createList: function(num) {<commit_msg>updated comments<commit_after>"use strict";
//app constructor
function PokitdokApp() {
    this.init();
};
//methods for PokitdokApp object
!(function() {
    PokitdokApp.prototype = {
        constructor: PokitdokApp,
        init: function() {
            this.settings = {
                moduleName: 'PokitdokApp',
                client_id: 'pZG5xNEnHk6aTjj3EgYD',
                client_secr: 'WBoxMy4otoCxChecEGl4Mf3WBSHtppcjh26rGWjY',
                tradingPartnersArr: [],
                retData: "",
                title: 'PokitDok',
                author: 'mmcgraw73'
            };
            this.addStyleSheet('wwwroot/css/project_x.min.css');
            this.addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
            this.docBuildr();
            this.updateTitle();
            this.addInput();
            this.addButton('submit');
            this.getTradingPartners();
        },
        /*
        load external stylesheet
        @param fileName: 'path/to/stylesheet.css'
        */
        addStyleSheet: function(fileName) {
            var self = this,
                head = document.head,
                link = document.createElement('link');
            link.type = 'text/css';
            link.rel = 'stylesheet';
            link.href = fileName;
            head.appendChild(link);
        },
        /*
        create element and place as child of body
        @param el: str element type
        @param place: 'begin' || 'end'
        @param id: str id of el
        */
        createEle: function(el, place, id) {
            var self = this,
                body = document.getElementsByTagName('body'),
                child = document.createElement(el);
            child.id = id;
            if (place && place === 'begin') {
                body[0].appendChild(child);
            } else body[0].prepend(child);
        },
        //edit beefy.js default title
        updateTitle: function() {
            var self = this,
                title = document.getElementsByTagName('title'),
                body = document.getElementsByTagName('body');
            title[0].innerText = self.settings.title;
            //body[0].insertAdjacentHTML('afterbegin', '<h1 class="author">' + self.settings.author + '</div>');
        },
        docBuildr: function() {
            var self = this;
            for (var i = 0; i < 5; i++) {
                self.createEle('div', 'end', 'div' + i);
            }
        },
        /*
        create a button and add to header element
        @param txt str for button id and the button txt
        */
        addButton: function(txt) {
            var self = this,
                htmlStr = '<div class="small-30"><button id=' + txt + ' class="square-button">' + txt + '</button></div>',
                div1 = document.getElementById('div1');
            div1.insertAdjacentHTML('beforeend', htmlStr);
        },
        //create a number input for the list count
        addInput: function() {
            var self = this,
                labelStr = '<div class="small-30"><label id="numLabel" for="tpCount">how many trading partners to view ?</label></div>',
                inputStr = '<div class="small-10"><input type="number" id="tpCount" placeholder="?"></div>',
                div1 = document.getElementById('div1');
            div1.insertAdjacentHTML('afterbegin', labelStr);
            div1.insertAdjacentHTML('beforeend', inputStr);
        },
        //connect + return trading parners json from pokitdok api
        getTradingPartners: function() {
            var self = this,
                cid = self.settings.client_id,
                csc = self.settings.client_secr,
                tparr = self.settings.tradingPartnersArr,
                submit = document.getElementById('submit'),
                tpCount = document.getElementById('tpCount'),
                PokitDok = require('pokitdok-nodejs'),
                pokitdok = new PokitDok(cid, csc),
                loadingStr = '<i style="text-align: center;" class="fa fa-spinner fa-pulse fa-fw"></i>',
                div4 = document.getElementById('div4'),
                div2 = document.getElementById('div2'),
                div3 = document.getElementById('div3'),
                icon = document.querySelector('.fa-spinner');
            div4.insertAdjacentHTML('afterbegin', loadingStr);
            pokitdok.tradingPartners(function(err, res) {
                var i, ilen, tradingPartner, str;
                if (err) {
                    return console.log(err, res.statusCode);
                }
                // print the name and trading_partner_id of each trading partner
                var body = '';
                for (i = 0, ilen = res.data.length; i < ilen; i++) {
                    tradingPartner = res.data[i];
                    tparr.push(tradingPartner);
                    console.log(tparr[i] + '\n');
                }
                //document.body.innerHTML = tparr[0].name + ':' + tparr[0].id;
                self.settings.retData = res.data[0];
                div4.style.display = 'none';
                return self.settings.retData;
            });
            submit.addEventListener('click', function(e) {
                if (tpCount.value > 0 && tpCount.value <= tparr.length && div2.innerHTML === '') {
                    self.createList(tpCount.value);
                    self.updateSpanBackgrounds();
                    self.nameHover();
                } else if (tpCount.value > tparr.length) {
                    alert('whoopsy!! -- the max num is: ' + tparr.length);
                } else {
                    div2.innerHTML = '';
                    div3.innerHTML = '';
                    self.createList(tpCount.value);
                    self.updateSpanBackgrounds();
                    self.nameHover();
                }
            });
        },
        /*
          --createList is the quick + dirty solution for generating table in dom
          --creating external html + using mustache/handlebars for 0.2.0
        */
        createList: function(num) {
{'fraction_non_alphanumeric': 0.1260737953039352, 'fraction_numerical': 0.009326679211322917, 'mean_word_length': 1.5530492898913952, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 37, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6381727', 'n_tokens_mistral': 3416, 'n_tokens_neox': 3277, 'n_words': 676}