// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

$( document ).ready(function() {
    console.log( "ready!" );
    eventBindings()
});

function eventBindings(){
  upInRound();
  downInRound();
  addPlayer();
  changeScore();
  resetScore();
}

// ===================Bidding stop===================


var counter = 0


// Go up in round when clicked on add button.
function upInRound(){
  $('img#add-round.score-btn').click(function(){
    console.log('somthing');
    counter++;
    $('#round-num').text(counter);

  })
}
// Go down in round when clicking on minus button.
function downInRound(){
  $('img#minus-round.score-btn').click(function(){
    console.log('somthing');
    counter--;
    $('#round-num').text(counter);
  })
}

function addPlayer(){
  $('a.btn.btn-success').click(function(e){
    var playerName = $('#player-name')[0].value
    // debugger
    $('table').append("<tr><td>" + playerName + "</th><td>0</td><td class='btn-sm btn-success'>+1</td><td class='btn-sm btn-success'>+5</td><td class='btn-sm btn-success'>+10</td><td class='btn-sm btn-danger'>-10</td><td class='btn-sm btn-danger'>-1</td></tr>");
  $('#player-name')[0].value = "";
  });

}

function resetScore(){
  $('#resetScore').click(function(){
    $('#round-num').text(0);
  });
}

function changeScore(){
  $('#plus1').click(function(){
    console.log('add 1');
    var player = this.parentElement

    debugger
  })
}
@@ -853,22 +853,69 @@
 ;%0A  
-changeScore();
+addOne();%0A  addFive();%0A  addTen();%0A  minusOne();%0A  minusTen()
 %0A  r
@@ -1970,18 +1970,13 @@
 ion 
-changeScor
+addOn
 e()%7B
@@ -2070,20 +2070,1710 @@
 Element%0A
-%0A
    
+ var currentScoreString = this.parentNode.childNodes%5B2%5D.textContent%0A    var currentScore = parseInt(currentScoreString)%0A    var newScore = currentScore + 1%0A    this.parentNode.childNodes%5B2%5D.textContent = parseInt(newScore)%0A    // debugger%0A  %7D)%0A%7D%0A%0Afunction addFive()%7B%0A  $('#plus5').click(function()%7B%0A    console.log('add 1');%0A    var player = this.parentElement%0A    var currentScoreString = this.parentNode.childNodes%5B2%5D.textContent%0A    var currentScore = parseInt(currentScoreString)%0A    var newScore = currentScore + 5%0A    this.parentNode.childNodes%5B2%5D.textContent = parseInt(newScore)%0A    // debugger%0A  %7D)%0A%7D%0A%0Afunction addTen()%7B%0A  $('#plus10').click(function()%7B%0A    console.log('add 1');%0A    var player = this.parentElement%0A    var currentScoreString = this.parentNode.childNodes%5B2%5D.textContent%0A    var currentScore = parseInt(currentScoreString)%0A    var newScore = currentScore + 10%0A    this.parentNode.childNodes%5B2%5D.textContent = parseInt(newScore)%0A    // debugger%0A  %7D)%0A%7D%0A%0Afunction minusOne()%7B%0A  $('#plus10').click(function()%7B%0A    console.log('add 1');%0A    var player = this.parentElement%0A    var currentScoreString = this.parentNode.childNodes%5B2%5D.textContent%0A    var currentScore = parseInt(currentScoreString)%0A    var newScore = currentScore - 1%0A    this.parentNode.childNodes%5B2%5D.textContent = parseInt(newScore)%0A    // debugger%0A  %7D)%0A%7D%0A%0Afunction minusTen()%7B%0A  $('#plus10').click(function()%7B%0A    console.log('add 1');%0A    var player = this.parentElement%0A    var currentScoreString = this.parentNode.childNodes%5B2%5D.textContent%0A    var currentScore = parseInt(currentScoreString)%0A    var newScore = currentScore - 10%0A    this.parentNode.childNodes%5B2%5D.textContent = parseInt(newScore)%0A    //
  debugge

add function for adding 1, 5 ,10