JSFiddle - React, Tailwind, and code Playground

by markrummel

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css">
<input type="text" id="movie-id" value="55555" /><br /><br />
<button id="yes" class="btn">Stay</button>
<button id="no" class="btn">Don't Stay</button><br /><br />
<button id="scenes" class="btn">Extra Scenes</button>
<button id="outtatkes" class="btn">Outtakes</button>
<button id="enhanced" class="btn">Enhanced</button>
<button id="teaser" class="btn">Sequel Teaser</button><br /><br />

<h1>Votes</h1>
<div id="results"></div>

JavaScript

$('button').click(function() {
  var type = $(this).attr('id');
  var movieID = $('#movie-id').val();
    
  //alert(movieID);
  
  if (type == 'yes') {}
    
  else if (type == 'no') {}
           
  else {
    //alert('Step 2 Vote');       
    insertVote(type, movieID);
    
    function insertVote(type, movieID) {
      alert('Function Started');
      retrievedVotes = JSON.parse(localStorage.votes);
      alert(retrievedVotes);
      retrievedVote = retrievedVotes[movieID][type];
      if (retrievedVote != 1) {
        retrievedVotes[movieID][type] = 1;
        localStorage.votes = JSON.stringify(retrievedVotes);
      }
    }
  }
});