<commit_before><!DOCTYPE html>
<html>
<head>
<title>Sistema de Recomendacao de musica</title>
<meta charset="UTF-8">
</head>
<body>

<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='principal.css') }}">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="<KEY>" crossorigin="anonymous">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="<KEY>" crossorigin="anonymous"></script>

<script src="{{url_for('static', filename='jquery.blockUI.js') }}"></script>
<script type="text/javascript">

  function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);

    if (response.status === 'connected')
     {      
      incializar();
    } 
    else if (response.status === 'not_authorized')
    {     
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    } else 
    {     
      document.getElementById('status').innerHTML = 'Please log ' +
        'into Facebook.';
    }
  }

  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  window.fbAsyncInit = function() {
    FB.init({
      appId      : '400417863497411',
      cookie     : true,  // enable cookies to allow the server to access 
                          // the session
      xfbml      : true,  // parse social plugins on this page
      version    : 'v2.8' // use graph api version 2.8
    });

   
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });

  };

  // Load the SDK asynchronously
  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

  var resultLogar = []
  
  function incializar() {
    
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      
      console.log('Successful login for: ' + response.name);     
      $.ajax({
        url: "/logar/"+ response.id,
        success: function(result) {        
          resultLogar = JSON.parse(result);
          console.log(result);
          $("#usuarioNome").html("Olá "+response.name);
          $("#photoUsuario").attr("src","http://graph.facebook.com/"+response.id+"/picture?type=normal");
          // Se o for a primeira vez a logar, iniciar a tela em que ele escolhe bandas favoritas.
          if(resultLogar[1] == true) {            
            primeiroLogin(resultLogar[0]);
          }
          else {
            //recomendar(resultLogar[0]); Usar quando a tela do primeiro Login estiver Funcionando.
            recomendar(resultLogar[0]);
          }
      }}); 7     
     
    });
  }

  function primeiroLogin(user_id, user_name) {

    $.blockUI({ message: '<h1>Carregando...</h1>' });

    $.ajax({
        url: "/tops/",
        success: function(result) {

          $.unblockUI();

          bandas = JSON.parse(result);   

          $(".logarFacebook").hide();

          $("#listaBandas").html("");
          $("#primeiroLogin").html("");
          $("#divRecomendar").html("");          

          $("#listaBandas").show();

          $("#listaBandas").append("<h2 class='form-signin-heading'>Selecione as bandas preferidas:</h2>")                  
          $("#listaBandas").append("<div class='row'><form action=''>");

          for (i in bandas) {
            var banda = bandas[i];
            $("#listaBandas").append("<div class='col-sm-6'><input type='checkbox' name='banda' style='margin-left:20px; font-size:18px; margin-right:5px;' value='"+banda+"'id='bandas'>"+banda+"</input></div>");              

            if(i%2 != 0){
                $("#listaBandas").append("<br>");
            }
          }
        
          $("#listaBandas").append("</form></div>");
          $("#listaBandas").append("<br><br><br><button type='button' id='buttonRecomende' style='background-color:#4267b2;color:white; border:none; padding:6px 12px;float:right; width:100%;'>Recomende-me</button>");

          $("#listaBandas").append("<br><br><br><button type='button' id='buttonTroca' style='background-color:#4267b2;color:white; border:none; padding:6px 12px;float:right; width:100%;'>Trocar opções</button>");

          var escolhidas = '';
          $("#buttonRecomende").click(function() {            
              
              $("input:checkbox[name='banda']:checked").each(function(){                
                  if (escolhidas == '') {
                      escolhidas = $(this).val();
                  } else {                    
                    escolhidas += ',' + $(this).val();
                  }
              });

              $.blockUI({ message: '<h1>Carregando...</h1>' });

              $.ajax({
                url: "/knowUser/"+escolhidas+"/"+ user_id,
                success: function(result) { 
                  $.unblockUI();

                  console.log(escolhidas);
                  
                  if (result == 'True'){
                    recomendar(user_id);
                    
                  }                  
                }
              })

              
          });


          $("#buttonTroca").click(function() {
              primeiroLogin(user_id, user_name);
          });
      }}); 
  }

var bandasSpotify = [];
var bandas = [];
  function recomendar(user_id, user_name) {
<commit_msg>Adding button Adicionar mais bandas<commit_after><!DOCTYPE html>
<html>
<head>
<title>Sistema de Recomendacao de musica</title>
<meta charset="UTF-8">
</head>
<body>

<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='principal.css') }}">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="<KEY>" crossorigin="anonymous">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="<KEY>" crossorigin="anonymous"></script>

<script src="{{url_for('static', filename='jquery.blockUI.js') }}"></script>
<script type="text/javascript">

  var escolhidas = '';

  function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);

    if (response.status === 'connected')
     {      
      incializar();
    } 
    else if (response.status === 'not_authorized')
    {     
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    } else 
    {     
      document.getElementById('status').innerHTML = 'Please log ' +
        'into Facebook.';
    }
  }

  function checkLoginState() {
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });
  }

  window.fbAsyncInit = function() {
    FB.init({
      appId      : '400417863497411',
      cookie     : true,  // enable cookies to allow the server to access 
                          // the session
      xfbml      : true,  // parse social plugins on this page
      version    : 'v2.8' // use graph api version 2.8
    });

   
    FB.getLoginStatus(function(response) {
      statusChangeCallback(response);
    });

  };

  // Load the SDK asynchronously
  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

  var resultLogar = []
  
  function incializar() {
    
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      
      console.log('Successful login for: ' + response.name);     
      $.ajax({
        url: "/logar/"+ response.id,
        success: function(result) {        
          resultLogar = JSON.parse(result);
          console.log(result);
          $("#usuarioNome").html("Olá "+response.name);
          $("#photoUsuario").attr("src","http://graph.facebook.com/"+response.id+"/picture?type=normal");
          // Se o for a primeira vez a logar, iniciar a tela em que ele escolhe bandas favoritas.
          if(resultLogar[1] == true) {            
            primeiroLogin(resultLogar[0]);
          }
          else {
            //recomendar(resultLogar[0]); Usar quando a tela do primeiro Login estiver Funcionando.
            recomendar(resultLogar[0]);
          }
      }}); 7     
     
    });
  }

  function primeiroLogin(user_id, user_name) {

    $.blockUI({ message: '<h1>Carregando...</h1>' });

    $.ajax({
        url: "/tops/",
        success: function(result) {

          $.unblockUI();

          bandas = JSON.parse(result);   

          $(".logarFacebook").hide();

          $("#listaBandas").html("");
          $("#primeiroLogin").html("");
          $("#divRecomendar").html("");          

          $("#listaBandas").show();

          $("#listaBandas").append("<h2 class='form-signin-heading'>Selecione as bandas preferidas:</h2>")                  
          $("#listaBandas").append("<div class='row'><form action=''>");

          for (i in bandas) {
            var banda = bandas[i];
            $("#listaBandas").append("<div class='col-sm-6'><input type='checkbox' name='banda' style='font-size:18px; margin-right:5px;' value='"+banda+"'id='bandas'>"+banda+"</input></div>");              

            if(i%2 != 0){
                $("#listaBandas").append("<br>");
            }
          }
        
          $("#listaBandas").append("</form></div>");
          $("#listaBandas").append("<br><br><br><button type='button' id='buttonRecomende' style='background-color:#4267b2;color:white; border:none; padding:6px 12px;float:right; width:100%;'>Recomende-me</button>");

          $("#listaBandas").append("<br><br><br><button type='button' id='buttonTroca' style='background-color:#4267b2;color:white; border:none; padding:6px 12px;float:right; width:100%;'>Adicionar mais bandas</button>");

          
          $("#buttonRecomende").click(function() {                            

              $.blockUI({ message: '<h1>Carregando...</h1>' });

              if(escolhidas == ''){

                  recomendar(user_id);

              } else {
                  
                  $.ajax({
                  url: "/knowUser/"+escolhidas+"/"+ user_id,
                  success: function(result) { 
                    $.unblockUI();

                    console.log(escolhidas);
                    
                    if (result == 'True'){
                      recomendar(user_id);
                      
                    }                  
                  }
                });  

              }              

              escolhidas = '';
          });


          $("#buttonTroca").click(function() {

              $("input:checkbox[name='banda']:checked").each(function(){                
                  if (escolhidas == '') {
                      escolhidas = $(this).val();
                  } else {                    
                    escolhidas += ',' + $(this).val();
                  }
              });

              primeiroLogin(user_id, user_name);

          });
      }}); 
  }

var bandasSpotify = [];
var bandas = [];
  function recomendar(user_id, user_name) {

{'fraction_non_alphanumeric': 0.17370276252151814, 'fraction_numerical': 0.011968194114271661, 'mean_word_length': 2.0792529025744573, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 101, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1041223', 'n_tokens_mistral': 3769, 'n_tokens_neox': 3615, 'n_words': 602}