Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
3.4 kB
1
Indexable
Never
//variables
var songs = getColumn("Top 50 Worldwide", "Track Name");
var songsArtists = getColumn("Top 50 Worldwide","Artist");
var num;
var playlist1 = [];
var playlist2 = [];
var playlist3 = [];
var index;
var song;
var name2 = getProperty("listDrop", "options");
var firstItem = name2[0];
var secondItem = name2[1];
var thirdItem = name2[2];
var input;

//main screen screen changes
onEvent("findButton", "click", function( ) {
  num = randomNumber(0, songs.length -1);
  setScreen("songFind");
  songChoice(songs[num], songsArtists[num]);
});

onEvent("renameButton", "click", function( ) {
  setScreen("renamePlaylist");
});

onEvent("playlistButton", "click", function( ) {
  setScreen("playlists");
  index = getProperty("playlistDropdown", "index");
  if(index == 0){
     playlist(playlist1);
  }else if(index == 1){
    playlist(playlist2);
  }else{
    playlist(playlist3);
  }
      
});

//events
onEvent("playlistDropdown", "input", function( ) {
  index = getProperty("playlistDropdown", "index");
  if(index == 0){
     playlist(playlist1);
  }else if(index == 1){
    playlist(playlist2);
  }else{
    playlist(playlist3);
  }
});

onEvent("rename", "click", function( ) {
  index = getProperty("listDrop", "index");
  input = getText("renameInput");
  if(index == 0){
    firstItem = input;
    setProperty("listDrop", "options", [firstItem, secondItem, thirdItem]);
  }else if(index == 1){
    secondItem = input;
    setProperty("listDrop", "options", [firstItem, secondItem, thirdItem]);
  }else{
    thirdItem = input;
    setProperty("listDrop", "options", [firstItem, secondItem, thirdItem]);
  }
  setProperty("playlistDropdown","options", [firstItem, secondItem, thirdItem]);
  setProperty("playlistDrop","options", [firstItem, secondItem, thirdItem]);
});

//button screen changes
onEvent("homeButton1", "click", function( ) {
  setScreen("main");
});

onEvent("homeButton2", "click", function( ) {
  setScreen("main");
});

onEvent("homeButton3", "click", function( ) {
  setScreen("main");
});

onEvent("backButton1", "click", function( ) {
  setScreen("songFind");
});

//more events
onEvent("likeButton", "click", function( ){
  setScreen("playlistSelection");
});

onEvent("addSongButton", "click", function( ) {
  index = getProperty("playlistDrop", "index");
  song = getText("songLabel");
  if(index == 0){
    appendItem(playlist1, song);
  }else if(index == 1){
    appendItem(playlist2, song);
  }else{
    appendItem(playlist3, song);
  }
  setScreen("songFind");
});

onEvent("dislikeButton", "click", function( ) {
  num = randomNumber(0, songs.length -1);
  songChoice(songs[num], songsArtists[num]);
});

//functions 
//gets the song and artist name of the song that the user likes
//input is the users song choice and the output is the artist and song name
function songChoice(song, artist) {
  setText("songLabel", song + " - " + artist);
  setText("songAdd", song + " - " + artist);
}

//gets the items in a playlists and displays them for the user to see
//input is the length of the playlist and its items and the output is the items of the playlists being displayed as text
function playlist(playlistNum){
  if(playlistNum.length == 0){
    setProperty("playlist","text", " ");
  }else{
  for(var i = 0; i < playlistNum.length; i++){
    setProperty("playlist","text", playlistNum.join("\n"));
    }
  }
}