<commit_before>require([
  '$api/models',
  'scripts/albumshuffle',
  '$views/list#List',
  '$views/buttons'
], function(models, albumShuffle, List, buttons) {
  'use strict';

  var button = buttons.Button.withLabel('Shuffle albums');
  var buttonElement = document.getElementById('buttonContainer');
  buttonElement.appendChild(button.node);
  buttonElement.addEventListener('click', handleClick);

  function handleClick() {
    var sourcePlaylistURI = document.getElementById('SOURCE_URI_ID').value;
    var destinationPlaylistURI = document.getElementById('DESTINATION_URI_ID').value;

    albumShuffle.shuffleAlbums(sourcePlaylistURI, destinationPlaylistURI);

    models.Playlist.fromURI(destinationPlaylistURI).load('tracks').done(function(destinationPlaylist){
      var list = List.forPlaylist(destinationPlaylist);
      var playlistElement = document.getElementById('playlistContainer');
      if (playlistElement.childNodes.length != 0)
      {
        playlistElement.childNodes.removeChild(childNodes[0]);
      }
      playlistElement.appendChild(list.node);
      list.init();
    });
  } 
});<commit_msg>Input handling improved<commit_after>require([
  '$api/models',
  'scripts/albumshuffle',
  '$views/list#List',
  '$views/buttons'
], function(models, albumShuffle, List, buttons) {
  'use strict';

  var sourcePlaylistURI = "", destinationPlaylistURI = "";

  var button = buttons.Button.withLabel('Shuffle albums');
  var buttonElement = document.getElementById('buttonContainer');
  buttonElement.appendChild(button.node);
  buttonElement.addEventListener('click', handleClick);

  var sourceInputElement = document.getElementById('SOURCE_URI_ID');
  sourceInputElement.addEventListener('input', readSource);

  var destinationInputElement = document.getElementById('DESTINATION_URI_ID');
  destinationInputElement.addEventListener('input', readDestination);

  function readSource() {
    sourcePlaylistURI = sourceInputElement.value;
    if (sourcePlaylistURI != "") {
      models.Playlist.fromURI(sourcePlaylistURI).load('name').done(function(sourcePlaylist) {
        sourceInputElement.value = sourcePlaylist.name;
      });
    }
  }

  function readDestination() {
    destinationPlaylistURI = destinationInputElement.value;
    if (destinationPlaylistURI != "") {
      models.Playlist.fromURI(destinationPlaylistURI).load('name').done(function(sourcePlaylist) {
        destinationInputElement.value = sourcePlaylist.name;
      });
    }
  }

  function handleClick() {
    if (sourcePlaylistURI != "" && destinationPlaylistURI != "") {
      albumShuffle.shuffleAlbums(sourcePlaylistURI, destinationPlaylistURI);
      models.Playlist.fromURI(destinationPlaylistURI).load('tracks').done(function(destinationPlaylist) {
        var list = List.forPlaylist(destinationPlaylist);
        var playlistElement = document.getElementById('playlistContainer');
        if (playlistElement.childNodes.length != 0)
        {
          playlistElement.removeChild(playlistElement.childNodes[0]);
        }
        playlistElement.appendChild(list.node);
        list.init();
      });
    }
  } 
});
{'fraction_non_alphanumeric': 0.12544, 'fraction_numerical': 0.00128, 'mean_word_length': 4.683636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1496034', 'n_tokens_mistral': 858, 'n_tokens_neox': 844, 'n_words': 118}