Back to Parent

var intro = ['I\'m your music friend. I think you should listen to','Life is too short to listen to the same music all the time. Try listening to','If you love someone, give them good music. Like','I like you. Here is some music I think is good.','We should get together and listen to','You have great taste. That\'s why you will enjoy','Listen to whoever you want. But also listen to','You should cook a fine Italian dinner while listening to','Why don\'t you listen to','Hey, I think you should listen to','You know what artist you should check out?','Go ahead and listen to this artist.','Need new music? Why not','Psst! Check the following band out','I\'really been digging','I think you might enjoy','I think you might enjoy listening to','I have a hunch that you should listen to','The stars are telling me you should listen to','I head about this band from a friend of a friend.','You probably have not heard of','I demand that you listen to','Steve told me about this band, but who trusts Steve?','I like this artist','I used to own this record on cassete.','Want to come over and listen to the records of','I once fell in love while listening to','This band was playing during my first kiss.','Listen to','Check out the this artist. Or don\'t. I won\'t judge you either way.'];
var randomIntro = Math.floor(intro.length * Math.random()); 
var songs = new Miso.Dataset({
  importer : Miso.Dataset.Importers.GoogleSpreadsheet,
  parser : Miso.Dataset.Parsers.GoogleSpreadsheet,
  key : "1z3cDIY4ED3M-oZG8PNEG--867oJqCtMe1M0YRgfzx5M", 
  worksheet : "1"
});
var totalSongs = 0;

songs.fetch({ 
  success : function() {
      songs.each(function(row, rowIndex) {
      totalSongs++;
        //any other parsing goes here, will probably need to parse the weight of each item here. Currently, I don't have a script that changes the weight of the items.
        //All of the weight is 1 - that is, the same. Eventually I will make it so it distrubutes, favoring the more recently added items.
    });//end each 

    var Song = songs.rowByPosition(Math.floor((Math.random() * totalSongs -1)+1));//Just straight random for now.
    var latestSong = songs.rowByPosition(totalSongs -1);
      var songId = Song.link.replace("https://open.spotify.com/track/","");
      $("#listentothis").append('<h1>'+Song.artist.toString()+'</h1><br /><h5><a href='+Song.link.toString()+'>'+Song.title.toString()+'</a></h5></div><hr />');
      $("#listentothis").append('<iframe src="https://embed.spotify.com/?uri=spotify%3Atrack%3A'+songId+'&theme=white&view=coverart" width="500" height="580" frameborder="0" allowtransparency="true"></iframe>')
      $("#intro").text(intro[randomIntro]);
      $("#stats").text("Database last updated "+latestSong.date_added);
  },//end success if
  error : function() {
    console.log("Well, it's all over now. Give up. Cry.");
  }//end error if
});
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0