{"size": 2730, "ext": "js", "max_stars_repo_path": "biology-animations/ThisOrThat/js/thisorthat.js", "max_stars_repo_name": "dsandeep0138/dsandeep0138.github.io", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "biology-animations/ThisOrThat/js/thisorthat.js", "max_issues_repo_name": "dsandeep0138/dsandeep0138.github.io", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "biology-animations/ThisOrThat/js/thisorthat.js", "max_forks_repo_name": "dsandeep0138/dsandeep0138.github.io", "max_forks_repo_forks_event_min_datetime": "2020-05-10T05:41:57.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-10T05:50:29.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 35.9210526316, "max_line_length": 122, "alphanum_fraction": 0.5985347985}
window.onload = function() {
    var q_num = 0;

    var outputText = document.getElementById("output-text");
    var h2 = document.getElementById("question_no");
    var p = document.getElementById("question_body");
    var button1 = document.getElementById("option1");
    var button2 = document.getElementById("option2");

    var randomizedQuestions = [];
    var numQuestions = questions.length;

    for (var i = 0; i < numQuestions; i++) {
        var idx = Math.floor(Math.random() * questions.length);
        randomizedQuestions.push(questions[idx]);
        questions.splice(idx, 1);
    }

    questions = randomizedQuestions;
    genQuestion(q_num);

    document.getElementById("option1").onclick = function() {
        qFunction(document.getElementById("option1").textContent)
    };

    document.getElementById("option2").onclick = function() {
        qFunction(document.getElementById("option2").textContent)
    };

    function genQuestion(q_num) {
        document.getElementById("next").disabled = true;
        h2.innerHTML = "Question " + (q_num+1) + " of " + questions.length + " [Topic: "+ questions[q_num]["topic"] + "]";
        p.innerHTML = questions[q_num]["question"];
        button1.innerHTML = questions[q_num]["options"][0]
        button2.innerHTML = questions[q_num]["options"][1]
    }

    function qFunction(value) {
        if (value.localeCompare(questions[q_num]["answer"]) == 0) {
            outputText.innerHTML = "That's right!";
            outputText.style.color = 'blue';
            document.getElementById("option1").disabled = true;
            document.getElementById("option2").disabled = true;

            if (q_num >= questions.length - 1) {
                document.getElementById("next").disabled = true;
                h2.disabled = true;
                p.disabled = true;
            } else {
                document.getElementById("next").disabled = false;
                outputText.innerHTML += " Click Next to continue.";
            }
        } else {
            outputText.innerHTML = questions[q_num]["hint"];
            outputText.style.color = 'red';
            document.getElementById("option1").disabled = true;
            document.getElementById("option2").disabled = true;

            if (q_num < questions.length - 1) {
                document.getElementById("next").disabled = false;
                outputText.innerHTML += " or Click Next.";
	    }
        }
    }

    document.getElementById("next").onclick = function() {
        document.getElementById("option1").disabled = false;
        document.getElementById("option2").disabled = false;

        q_num += 1;
        outputText.innerHTML = "";

        genQuestion(q_num);
    };
}
