JSFiddle - React, Tailwind, and code Playground

by markrummel

HTML

<input type="text" id="movie-id" value="44444" /><br />
<button id="set">Set</button>
<button id="why">Why</button>
<button id="exist">Exist?</button>

JavaScript

var movieID = $('#movie-id').val();

//alert(movieID);

//retrievedVotes = JSON.parse(localStorage.votes);

//alert(retrievedVotes);

$('#set').click(function() {
  alert('Set Movie ' + movieID);
  if (localStorage.votes == null) {
    retrievedVotes = {};
  }
  else {
    retrievedVotes = JSON.parse(localStorage.votes);
    if (retrievedVotes['movie' + movieID] == null) {
      retrievedVotes['movie' + movieID] = {};
    }
    retrievedVotes['movie' + movieID]['yes'] = 1;
    localStorage.votes = JSON.stringify(retrievedVotes);
  }

});

$('#why').click(function() {

});

$('#exist').click(function() {
    if (localStorage.votes == null) {
      alert('Does Not Exist');
    }
    else {alert('Exists');}
});