Skip to content

Instantly share code, notes, and snippets.

@simondahla
Last active December 18, 2015 09:49
Show Gist options
  • Save simondahla/5764262 to your computer and use it in GitHub Desktop.
Save simondahla/5764262 to your computer and use it in GitHub Desktop.
discount code parser for eventbee widget
// Get discount code in Eventbee widget
var eventID = ''; //Set your event ID here
//Function to get the code from the browser url
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
jQuery(document).ready(function($) {
//If there is a code, then change the iframe src
if (getParameterByName('code').length > 0) {
var promoURL = 'http://www.eventbee.com/eregister?eid=' + eventID + '&code=' + getParameterByName('code') + '&viewType=iframe;resizeIFrame=true&context=web';
var widgetID = '#_EbeeIFrame_ticketwidget_' + eventID;
$(widgetID).attr('src', promoURL);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment