markdown Spotify克隆从2017-11-15互动谈话:“数据和流程建模”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Spotify克隆从2017-11-15互动谈话:“数据和流程建模”相关的知识,希望对你有一定的参考价值。

var songs = {
  '1234': {
    id: 1234,
    title: 'Purple Heart Highway',
    duration: 215, // seconds
  },
  '1235': {
    id: 1235,
    title: 'Pink Celica',
    duration: 203
  },
  '1236': {
    id: 1236,
    title: 'Chillesque',
    duration: 156
  },
  '1237': {
    id: 1237,
    title: 'Time to Try',
    duration: 300,
  }
};

var getSongById = function(songId) {
  return songs[songId] || null;
};

// search or browse filter
// given an album i want only the songs
// that are less than some max # of seconds

/**
  Input: an Album instance and a max length per song
  Output: an array of song ids that meet criteria
 */
var filterToMaxSongLength = function(album, maxSongLength) {
  return album.songs.filter(function(songId) {
    var song = getSongById(songId);
    return song.duration < maxSongLength;
  });
};
<html>

  <head>
    <link href="styles.css" rel="stylesheet">

    <script>
      var album458674857 = {
        id: 458674857,
        title: 'The Good Fortunes',
        songs: [
          1234,
          1235,
          1236,
          1237,
        ],
      };
    </script>
  </head>

  <body>
    <script src="song-store.js"></script>
    <script src="song-filters.js"></script>
    <script src="app.js"></script>
  </body>

</html>
// render the filtered songs
for (var i = 0; i < filteredSongs.length; i++) {
  var songId = filteredSongs[i];
  var songData = getSongById(songId);
  var element = document.createElement('H1');

  element.innerText = songData.title;
  document.body.appendChild(element);
}
h1 {
  color: red;
}
This was a group exercise in making a tiny clone of functionality of some well-known app.

We chose Spotify.

Here are the data models of key nouns in the app.

```
var Song = {
  id: '', // 1232387
  artist: null, // points at an Artist
  title: '', // Purple Heart Highway
  year: null, // 2014
  genre: null, // 'gospel', 'triphop', 'grunge'
  duration: null, // 194 (seconds)
  thumbnailURL: null, // 
  fileURL: null,
};

// Album
var Album = {
  title: null,
  releaseYear: null,
  genre: null,
  publisher: null,
  thumbnail: null,
  songs: [
    1234,
    1235,
    1236,
    1237,
  ],
};
```

以上是关于markdown Spotify克隆从2017-11-15互动谈话:“数据和流程建模”的主要内容,如果未能解决你的问题,请参考以下文章

markdown 从Git克隆

无法在 vercel 生产中验证 spotify

markdown Git浅克隆和克隆深度

markdown 克隆远程分支

markdown 使用supmodules的Git克隆

markdown 将远程克隆到现有本地