<commit_before>/*
Outstanding concerns:
[ ] is the database secure? can people upload malicious files?
[ ] SSL would help us save ALLOW/DENY pref. for microphone
*/

//================================================================================
//GLOBAL VARIABLES
//================================================================================

//General
var language = "UNASSIGNED"; //"English" or "Spanish"
var recording = 0; //0: waiting, 1: recording, 2: submitting
var loggedIn = false;

//Current Question/Video Settings
var questionCounter = 0;
var questionTitle = "Question Title";
var questionURL = "http://www.youtube.com/embed/fgxuM8DH6k8";
var questionLogic = false; //true when question requires YES/NO answer
var questionBack = []; //index = this question, value = the previous question (how we got here)

var userName;
var userID;
// var currentBlob;
var blobArray = [];

//================================================================================
// MAIN
//================================================================================

//Initialization
document.getElementById("content-prompt-english").style.display = "none";

//login
$(document).ready(function() {

$("#login,#login-es").on("click", function() {
    var username = document.getElementById("inputName").value;
    var password  = document.getElementById("inputID").value;
    $.ajax({
         type: 'POST',
         url: 'login/',
         data: {'username': username, 'password': password},
         //success: function(data) {
         //   beginInterview('English');
         //   }
        success: function(data, textStatus, request){
        console.log("You've returned to Question #: " + data);
        beginInterview(); //initialize
        resumeInterview(data); //go to video
        }
    });
});
});

//initialize login settings
function beginInterview(userLang) {
	loggedIn = true;
	language = userLang;
	userName = document.getElementById("inputName").value;
	userID = document.getElementById("inputID").value;
	// console.log("name: " + userName);
	// console.log("ID: " + userID);

	// if ((userName !== "") && (userID !== "")) { //required info was provided
		//submit NAME/ID to database
		//get back question number; store as questionCounter (GLOBAL)

		//switch to video display screen
		// document.getElementById("content-welcome").style.display = "none";
		// document.getElementById("content-prompt-english").style.display = "block";

		// //display first video
		// goToQuestion(0, false); //first video
	// }
}

function resumeInterview(questionNumber) {
	document.getElementById("content-welcome").style.display = "none";
	document.getElementById("content-prompt-english").style.display = "block";
	goToQuestion(questionNumber, false);
}

//for playing a particular video based on known question number
function goToQuestion(num, fromPrev) {
		resetVideoControls();
		loadVideo(num, fromPrev);
		displayButtons();
		document.getElementById("question-title").innerHTML = questionCounter + ". " + questionTitle;
		document.getElementById("video-frame").src = questionURL + '?rel=0&autoplay=1';	
}

//toggles the record/success button
function toggleAudio() {
	if (recording ==1) { //capturing --> begin sending
		recording = 2;
		document.getElementById("recording-icon").className = "glyphicon glyphicon-ok";
		document.getElementById("recording-button").className = "btn btn-lg btn-success col-md-offset-3";
		document.getElementById("next-button").className = "btn btn-lg btn-primary col-md-offset-3";
		submitData('n/a');
	}
	else { //waiting or sent --> begin capturing
		recording = 1;
		document.getElementById("recording-button").className = "btn btn-lg btn-danger col-md-offset-3";
		document.getElementById("recording-icon").className = "glyphicon glyphicon-record";
	}
}

//change button after user accepts/denies permission to use microphone
function recordButton(userChoice) {
	if (userChoice == "allow") {
		document.getElementById("recording-icon").className = "glyphicon glyphicon-record blink";
	} else {
		document.getElementById("recording-icon").className = "glyphicon glyphicon-exclamation-sign";
	}<commit_msg>does not submit on record-to-green-checkmark<commit_after>/*
Outstanding concerns:
[ ] is the database secure? can people upload malicious files?
[ ] SSL would help us save ALLOW/DENY pref. for microphone
*/

//================================================================================
//GLOBAL VARIABLES
//================================================================================

//General
var language = "UNASSIGNED"; //"English" or "Spanish"
var recording = 0; //0: waiting, 1: recording, 2: submitting
var loggedIn = false;

//Current Question/Video Settings
var questionCounter = 0;
var questionTitle = "Question Title";
var questionURL = "http://www.youtube.com/embed/fgxuM8DH6k8";
var questionLogic = false; //true when question requires YES/NO answer
var questionBack = []; //index = this question, value = the previous question (how we got here)

var userName;
var userID;
// var currentBlob;
var blobArray = [];

//================================================================================
// MAIN
//================================================================================

//Initialization
document.getElementById("content-prompt-english").style.display = "none";

//login
$(document).ready(function() {

$("#login,#login-es").on("click", function() {
    var username = document.getElementById("inputName").value;
    var password  = document.getElementById("inputID").value;
    $.ajax({
         type: 'POST',
         url: 'login/',
         data: {'username': username, 'password': password},
         //success: function(data) {
         //   beginInterview('English');
         //   }
        success: function(data, textStatus, request){
        console.log("You've returned to Question #: " + data);
        beginInterview(); //initialize
        resumeInterview(data); //go to video
        }
    });
});
});

//initialize login settings
function beginInterview(userLang) {
	loggedIn = true;
	language = userLang;
	userName = document.getElementById("inputName").value;
	userID = document.getElementById("inputID").value;
	// console.log("name: " + userName);
	// console.log("ID: " + userID);

	// if ((userName !== "") && (userID !== "")) { //required info was provided
		//submit NAME/ID to database
		//get back question number; store as questionCounter (GLOBAL)

		//switch to video display screen
		// document.getElementById("content-welcome").style.display = "none";
		// document.getElementById("content-prompt-english").style.display = "block";

		// //display first video
		// goToQuestion(0, false); //first video
	// }
}

function resumeInterview(questionNumber) {
	document.getElementById("content-welcome").style.display = "none";
	document.getElementById("content-prompt-english").style.display = "block";
	goToQuestion(questionNumber, false);
}

//for playing a particular video based on known question number
function goToQuestion(num, fromPrev) {
		resetVideoControls();
		loadVideo(num, fromPrev);
		displayButtons();
		document.getElementById("question-title").innerHTML = questionCounter + ". " + questionTitle;
		document.getElementById("video-frame").src = questionURL + '?rel=0&autoplay=1';	
}

//toggles the record/success button
function toggleAudio() {
	if (recording ==1) { //capturing --> begin sending
		recording = 2;
		document.getElementById("recording-icon").className = "glyphicon glyphicon-ok";
		document.getElementById("recording-button").className = "btn btn-lg btn-success col-md-offset-3";
		document.getElementById("next-button").className = "btn btn-lg btn-primary col-md-offset-3";
		// submitData('n/a');
	}
	else { //waiting or sent --> begin capturing
		recording = 1;
		document.getElementById("recording-button").className = "btn btn-lg btn-danger col-md-offset-3";
		document.getElementById("recording-icon").className = "glyphicon glyphicon-record";
	}
}

//change button after user accepts/denies permission to use microphone
function recordButton(userChoice) {
	if (userChoice == "allow") {
		document.getElementById("recording-icon").className = "glyphicon glyphicon-record blink";
	} else {
		document.getElementById("recording-icon").className = "glyphicon glyphicon-exclamation-sign";
	}
{'fraction_non_alphanumeric': 0.21630356715345941, 'fraction_numerical': 0.004069906631553747, 'mean_word_length': 4.464355788096795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '223152', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2215, 'n_words': 556}