Skip to content

Commit

Permalink
Merge pull request #2 from brasse/master
Browse files Browse the repository at this point in the history
Make creating the FB event optional
  • Loading branch information
blixt committed May 17, 2012
2 parents e1abae0 + 2f96d03 commit 95af152
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
13 changes: 8 additions & 5 deletions spotifyapp/index.html
Expand Up @@ -8,11 +8,14 @@
<body id="view-start">
<h1>Spartify</h1>
<section class="view-start">
<p>Enter your party details
<p><input id="title" placeholder="Party name">
<p><textarea id="description" placeholder="Description of the party"></textarea>
<p><input id="where" placeholder="Location">
<p><input id="when" placeholder="When?">
<p><input id="create-fb-event" type="checkbox" checked><label for="create-fb-event">Create Facebook event!</label>
<div id="fb-event-details">
<p>Enter your party details
<p><input id="title" placeholder="Party name">
<p><textarea id="description" placeholder="Description of the party"></textarea>
<p><input id="where" placeholder="Location">
<p><input id="when" placeholder="When?">
</div>
<button class="create nav" id="create-party">Create the party!</button>
</section>
<section class="view-party">
Expand Down
5 changes: 5 additions & 0 deletions spotifyapp/spartify.css
Expand Up @@ -104,6 +104,11 @@ input, textarea {
width: 100%;
}

input#create-fb-event {
width: 20px;
height: 20px;
}

textarea {
font-size: 15px;
}
Expand Down
49 changes: 33 additions & 16 deletions spotifyapp/spartify.js
Expand Up @@ -98,7 +98,9 @@ var el = {
searchResults: $('#search-results'),
title: $('#title'),
when: $('#when'),
where: $('#where')
where: $('#where'),
fbEventDetails: $('#fb-event-details'),
createFbEvent: $('#create-fb-event'),
};

var currentTrack, playlist, queue, queueVersion;
Expand Down Expand Up @@ -211,6 +213,10 @@ function enterParty(code) {
}

function init() {
el.createFbEvent.click(function(event) {
el.fbEventDetails.css('visibility', (event.target.checked ? 'visible' : 'hidden'))
});

el.createParty.click(function () {
el.queue.empty();
el.queue.css('height', 0);
Expand All @@ -220,21 +226,32 @@ function init() {
el.partyCode.text('...');
el.body.attr('id', 'view-party');

facebook.createEvent(el.title.val(), el.description.val(), el.where.val(), el.when.val(),
function(fbEvent) {
api.createParty(fbEvent.id,
function (party) {
facebook.updateEvent(fbEvent.id, {
description: el.description.val() + '\n\n' +
'Add songs you want to hear at the party here:\n' +
'http://www.spartify.com/' + party.id});
enterParty(party.id);
tracksCallback(party);
},
function () {
// TODO(blixt): Show an error.
});
});
if (el.createFbEvent.is(':checked')) {
facebook.createEvent(el.title.val(), el.description.val(), el.where.val(), el.when.val(),
function(fbEvent) {
api.createParty(fbEvent.id,
function (party) {
facebook.updateEvent(fbEvent.id, {
description: el.description.val() + '\n\n' +
'Add songs you want to hear at the party here:\n' +
'http://www.spartify.com/' + party.id});
enterParty(party.id);
tracksCallback(party);
},
function () {
// TODO(blixt): Show an error.
});
});
} else {
api.createParty(0,
function (party) {
enterParty(party.id);
tracksCallback(party);
},
function () {
// TODO(blixt): Show an error.
});
}
});

el.leaveParty.click(function () {
Expand Down

0 comments on commit 95af152

Please sign in to comment.