Skip to content

Commit

Permalink
Return active song index in song metadata. References #318
Browse files Browse the repository at this point in the history
  • Loading branch information
danpastori committed Mar 8, 2019
1 parent 86eea63 commit 6245c16
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 3 deletions.
28 changes: 27 additions & 1 deletion dist/amplitude.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/amplitude.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/amplitude.min.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ let Initializer = (function() {
*/
initializeDefaultLiveSettings();

/*
Initialize default song indexes
*/
initializeDefaultSongIndexes();

/*
When the preliminary config is ready, we are ready to proceed.
*/
Expand Down Expand Up @@ -690,6 +695,19 @@ let Initializer = (function() {
}
}

/**
* Initializes the index of the song in the songs array so
* we can reference it if needed
*
* @access private
*/
function initializeDefaultSongIndexes(){
for (let i = 0; i < config.songs.length; i++) {
config.songs[i].index = i;
}
}


/*
Returns the publicly accessible methods
*/
Expand Down
9 changes: 9 additions & 0 deletions src/init/playlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ let PlaylistsInitializer = (function() {
if (Checks.isInt(config.playlists[key].songs[i])) {
config.playlists[key].songs[i] =
config.songs[config.playlists[key].songs[i]];

config.playlists[key].songs[i].index = i;
}
/*
Check to see if the index for the song in the playlist
Expand All @@ -140,6 +142,13 @@ let PlaylistsInitializer = (function() {
" is not defined in your songs array!"
);
}

/*
If not an int, then is a dedicated song, just set the index.
*/
if (!Checks.isInt(config.playlists[key].songs[i]) ){
config.playlists[key].songs[i].index = i;
}
}
}
}
Expand Down

0 comments on commit 6245c16

Please sign in to comment.