{"size": 3065, "ext": "js", "max_stars_repo_path": "js/vote.js", "max_stars_repo_name": "gummieCrew/demoMath", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/vote.js", "max_issues_repo_name": "gummieCrew/demoMath", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/vote.js", "max_forks_repo_name": "gummieCrew/demoMath", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.0503597122, "max_line_length": 130, "alphanum_fraction": 0.5530179445}
var ballots = [];                        
var numberOfBallots = 5489;
var greenVote = 0;
var blueVote = 0;
var redVote = 0;



function randColor(){
  return Math.floor(Math.random() * 236 + 20 );
}

/******* this function chooses which ballot the blue, red or green is assigned*****/
function whichArray(){
  var constant = Math.floor(Math.random()*100);
  var array;
  
  if (constant >=50){
    array = 0;
  }else{
    array = 1;
  }
  
  return array;
}

//***********VOTING FUNCTIONS**************************************//

function vote(colorBallot){
  ballots.push(colorBallot);
}

function voterData(voterId, ballot){
  this.voterId = voterId;
  this.ballot = vote(ballot);
}

//********DIV FUNCTIONS*********************************************//


function redDiv(){
	var rgbColor;
  red = 255;
  green = randColor();
  blue = green;
  rgbColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
  html = '<div id = ' +i+' style="background-color:' + rgbColor + '"></div>';
  document.write(html);
}

function greenDiv(){
	var rgbColor;
  green = 255;
  red = randColor();
  blue = red;
  rgbColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
  html = '<div id = ' +i+' style="background-color:' + rgbColor + '"></div>';
  document.write(html)
}


function blueDiv(){
	var rgbColor;
  blue = 255;
  red = randColor();
  green = red;
  rgbColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
  html = '<div id = ' +i+' style="background-color:' + rgbColor + '"></div>';
  document.write(html)
}


//***************VOTING SEQUENCE************************************************//

function votingSequence(){
  for (i=0; i < numberOfBallots; i++){
    var constant = Math.floor(Math.random()*100);
    var blueBallot = [[2,3,1],[2,1,3]];
		 var redBallot = [[3,2,1],[3,1,2]];
		 var greenBallot = [[1,2,3],[1,3,2]];
 	  if (constant>=41){
      new voterData(i,greenBallot[whichArray()]);
      console.log(constant+' ,is greater than 51. Green Vote!')
      greenVote++;
    } else if (41>constant && constant>=11 ){
      new voterData(i,blueBallot[whichArray()]);
      console.log(constant+' ,is in between 51 and 14. Blue Vote!');
      blueVote++;  
    } else if ((11)>constant){  
      new voterData(i,redBallot[whichArray()]);
      console.log(constant+' ,is less than 14. Red Vote!');
      redVote++;
    }
  }
}

/********** DATA FROM THE VOTING SEQUENCE ***********/ 

votingSequence();

console.log('Green tally:'+greenVote+', Blue tally:'+blueVote+', Red tally:'+redVote); 

var numberOfCandidates = Math.floor((redVote/numberOfBallots)*100);
var quota = Math.floor(numberOfBallots/(numberOfCandidates+1))+1;

console.log('There should be '+numberOfCandidates+' candidates. The quota for each elected official should be '+ quota+' votes.');


/***** ELECTION SEQUENCE (STILL WORKING ON IT)**********/	

// if (greenVote>0){
// 	
// 	do {
// 	$("#green.first").innerHTML(greenDiv());
// 	greenVote--;
// 	} while (greenVote>quota)
// 	
// 	else{
// 		do{
// 		$("#green.second");
// 		greenVote--;
// 		}
// 
// 
// 
// 
// 











