remaining tickets count from Eventbrite, without API key
Last active
October 7, 2015 18:21
-
-
Save anapsix/9761705e868c38a905c8 to your computer and use it in GitHub Desktop.
eventbrite tickets count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span style="text-align:center"> | |
<h4 id="premsg">checking available tickets..</h4> | |
<p><a href="#" type="button" id="event" class="btn btn-success">get your tickets!</a></p> | |
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// eventPage | |
var eventPage = 'https://www.eventbrite.com/e/extreme-beer-fest-2016-tickets-17643961564'; | |
// set button link URL to eventPage | |
$("#event")[0].href = eventPage; | |
// regex to grab tickets remaining element | |
var reg = /(\d+)(\sTickets)/; | |
// default to this ticket amount, when event is doesn't report ticket counts | |
var tr = 'no'; | |
// do the thing | |
$.get('http://crossorigin.me/' + eventPage, function(data) { | |
text = $('td[itemprop="inventoryLevel"]', data).text(); | |
waitList = /Add to Waitlist/.exec(data); | |
console.log('Waitlist: ' + waitList); | |
try { | |
tr = reg.exec(text)[1]; | |
$("#event").html(tr + ' tickets remaining'); | |
$("#premsg").html('hooray!'); | |
} catch (err) { | |
if (waitList) { | |
$("#premsg").html('no tickets available :`('); | |
$("#event").html('get on waiting list'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment