0% found this document useful (0 votes)
23 views

Code

The document contains code for a Spotify data visualization project. It defines variables to store track names, positions, artists, and images from a Spotify dataset. It includes functions to randomly select and display an album cover, choose a new top track, and update the display. It also includes event handlers for buttons to navigate between screens and a dropdown to select and display a song's artist and image.

Uploaded by

hitoshi222222
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Code

The document contains code for a Spotify data visualization project. It defines variables to store track names, positions, artists, and images from a Spotify dataset. It includes functions to randomly select and display an album cover, choose a new top track, and update the display. It also includes event handlers for buttons to navigate between screens and a dropdown to select and display a song's artist and image.

Uploaded by

hitoshi222222
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

//Variable list for the Spotify Dataset

var tracks = getColumn("Top 50 Worldwide", "Track Name");


var positions = getColumn("Top 50 Worldwide", "Position");
var artists = getColumn("Top 50 Worldwide", "Artist");
var images = getColumn("Top 50 Worldwide 1", "Images");
var songChoice = "21 savage";
//Filtered List
var nextTracks = [];
var nextPositions = [];
var nextArtists = [];
var nextImages = [];

//Brandley and Ethan worked on the on event buttons


//Will bring user from screen 1 to screen 2
onEvent("nextButton", "click", function( ) {
setScreen("screen2");
});

//Will bring user from screen 2 to screen2


onEvent("nextButton2", "click", function( ) {
setScreen("screen3");
});

//Will randomize the songs and choose one to display


onEvent("randomizeButton", "click", function( ) {
updateScreen();
getNextAlbum();
});

//Will take user from screen 3 to screen 2


onEvent("backButton", "click", function( ) {
setScreen("screen2");
});

//Will take the user from the third screen to the home screen
onEvent("homeButton", "click", function() {
setScreen("screen1");
});

//Will take user from screen 2 to the home screen


onEvent("homeButton2", "click", function() {
setScreen("screen1");
});
//Brandley and Diego worked on the updateScreen function
//Function for the filtering and randomizing of the data
function updateScreen() {
var index = randomNumber(0, tracks.length - 1);
setText("text_input1", tracks[index]);
setText("text_input2", positions[index]);
setText("text_input3", artists[index]);
setProperty("imageOutput", "image", images[index]);
}

//Khoa and Ethan worked on the getNextAlbum function


//Will choose a new album cover and display it
function getNextAlbum() {
for (var i = 0; i < tracks.length; i++) {
//List of the cities, temps, and condition/icons.
if (positions[i] == 1) {
appendItem(nextTracks, tracks[i]);
appendItem(nextPositions, positions[i]);
appendItem(nextArtists, artists[i]);
appendItem(nextImages, images[i]);
}
}
}

//Ethan, Diego and Brandley worked on the dropdown


//Khoa worked on getting the images into the data set
//The dropdown will allow the user to choose a song title and then display the
//image and display the artists name who made the track
onEvent("dropdown1", "click", function( ) {
var index = 0;
songChoice = getText("dropdown1");
for (var i = 0; i < tracks.length; i++) {
if (songChoice == tracks[i]) {
index = i;
setText("artistNameOutput", artists[i]);
setProperty("image7", "image", images[i]);
}
}
});

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy