{"size": 2809, "ext": "js", "max_stars_repo_path": "static/js/inputChecker.js", "max_stars_repo_name": "naim-panjwani/LocusFocus", "max_stars_repo_stars_event_min_datetime": "2020-01-07T06:06:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-05T14:31:52.000Z", "max_issues_repo_path": "static/js/inputChecker.js", "max_issues_repo_name": "naim-panjwani/LocusFocus", "max_issues_repo_issues_event_min_datetime": "2020-07-21T23:32:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T13:43:37.000Z", "max_forks_repo_path": "static/js/inputChecker.js", "max_forks_repo_name": "naim-panjwani/LocusFocus", "max_forks_repo_forks_event_min_datetime": "2020-10-25T23:05:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-19T04:47:08.000Z"}
{"max_stars_count": 6, "max_issues_count": 4, "max_forks_count": 2, "avg_line_length": 36.4805194805, "max_line_length": 98, "alphanum_fraction": 0.5069419722}

function loadGenes(build, region) {
    var chrom = parseInt(region.split(':')[0].toLowerCase().replace('chr','').replace('x','23'));
    var startbp = parseInt(region.split(':')[1].split('-')[0].replaceAll(',',''));
    var endbp = parseInt(region.split(':')[1].split('-')[1].replaceAll(',',''));
    var genesdiv = d3.select("#region-genes");
    var genesMsgDiv = d3.select("#genes-select");
    d3.json(`/genenames/${build}/${chrom}/${startbp}/${endbp}`).then(response => {
        genesdiv.text('');
        var genenames = response.map(k => k);
        if(genenames.length === 0) {
            genesMsgDiv.text(`No Genes Found in ${region} (${build})`);
        }
        else {
            genesMsgDiv.text(`Select Genes Found in ${region} (${build})`);
        }
        for(var i = 0; i < genenames.length; i++) {
            genesdiv
                .append("option")
                .attr('value', genenames[i])
                .text(genenames[i]);
        }
        $('#region-genes').multiselect('destroy');
        $(document).ready(function() {
            $("#region-genes").multiselect({
                enableFiltering: true,
                includeSelectAllOption: true,
                maxHeight: 400,
                buttonWidth: '400px',
                checkboxName: function(option) {
                    return 'multiselect[]';
                }
            });
        });
    });
}

function checkLocusInput(regiontext) {
    var build = d3.select("#coordinate").property("value");
    var errorSelect = d3.select("#locusErrorDiv");
    errorSelect.text("");
    if(regiontext !== "") {
        d3.json(`/regionCheck/${build}/${regiontext}`).then(response => {
            var message = response['response'];
            if(message !== "OK") {
                errorSelect.text(message);
            }
            else {
                // var genesButton = d3.select("#load-genes-button");
                // genesButton.property('value', `Load Genes in ${regiontext}`);
                loadGenes(build, regiontext);
            }
        })
    }
}

function checkSSInput(regiontext) {
    var build = d3.select("#coordinate").property("value");
    var errorSelect = d3.select("#locusErrorDiv");
    errorSelect.text("");
    if(regiontext !== "") {
        d3.json(`/regionCheck/${build}/${regiontext}`).then(response => {
            var message = response['response'];
            if(message !== "OK") {
                errorSelect.text(message);
            }
        })
    }
}

function checkNumSamplesInput(numsamples) {
    errordiv = d3.select("#numSamplesError-message");
    errordiv.text("");
    if(Number.isInteger(+numsamples) === false) {
        errordiv.text("Must be integer")
    }
}