Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
walter-0 committed Sep 14, 2015
0 parents commit cc2dc19
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1 change: 1 addition & 0 deletions .meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions .meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

15t0uap9rqet5v0vxpk
10 changes: 10 additions & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-platform
autopublish
insecure
http
2 changes: 2 additions & 0 deletions .meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions .meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
1 change: 1 addition & 0 deletions the_spotify_game_meteor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* CSS declarations go here */
18 changes: 18 additions & 0 deletions the_spotify_game_meteor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<head>
<title>The Spotify Game - Meteor Version</title>
</head>

<body>

{{> hello}}
</body>

<template name='hello'>
<h1>The Spotify Game</h1>
<h2 class='start'>Click Here to return 8 similar artists</h2>
<h2 class='currentArtist'></h2>
<input type='text' placeholder='Enter an artist name' class='inputArtist'>
<ul class='artists'>

</ul>
</template>
68 changes: 68 additions & 0 deletions the_spotify_game_meteor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
if (Meteor.isClient) {


Template.hello.helpers({
});

Template.hello.events({
'click h2.start': function () {
// when h2 is clicked
inputArtist = $('input.inputArtist').val();
HTTP.get('http://developer.echonest.com/api/v4/artist/profile?api_key=X2VQTSJP3SIFYYMVT&id=7digital-US:artist:' + inputArtist + '&format=json',
{},
function (error, result) {
if (result.statusCode === 200) {
$('h2.currentArtist').empty().append(result.data.response.artist.name);

}
});

HTTP.get('http://developer.echonest.com/api/v4/artist/similar?api_key=X2VQTSJP3SIFYYMVT&id=7digital-US:artist:' + inputArtist + '&format=json&results=8&start=0',
{},
function (error, result) {
if (result.statusCode === 200) {
$('ul.artists').empty();
//clear the list each click
for (var i = 0; i < result.data.response.artists.length; i++) {
//append artists to unordered list
$('ul.artists').append('<li>' + result.data.response.artists[i].name + '</li>')
}
}
}
);
},
'click li': function (event) {
event.preventDefault();
///get the text of the clicked artist
nextArtist = $(event.target).text();

HTTP.get('http://developer.echonest.com/api/v4/artist/similar?api_key=X2VQTSJP3SIFYYMVT&id=7digital-US:artist:' + nextArtist + '&format=json&results=8&start=0',
{},
function (error, result) {
if (result.statusCode === 200) {
$('ul.artists').empty();
//clear the list each click
for (var i = 0; i < result.data.response.artists.length; i++) {
//append 8 artists to the unordered list
$('ul.artists').append('<li>' + result.data.response.artists[i].name + '</li>')
}
}
}
);
$('h2.currentArtist').empty().append(nextArtist);
var currentArtist = $('h2.currentArtist').html();
console.log('current artist is: ' + currentArtist);
var targetArtist = Math.floor((Math.random() * 100) + 1);
console.log('target artist is: ' + targetArtist);
if (currentArtist == targetArtist) {
alert("ZOMG YOU WIN!!!")
}
}
});
}

if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}

0 comments on commit cc2dc19

Please sign in to comment.