forked from eb-gustavo/eb-gustavo.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gustavo Ingrassia
committed
Feb 9, 2017
1 parent
16571eb
commit 489db96
Showing
3 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Gustavo</title> | ||
</head> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Gustavo</title> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
<body> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Stingray Playground</title> | ||
<script src="index.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="checkout_widget" style="border-style:solid; border-color:#D3D3D3;"></div> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function showWidget(eventId) { | ||
EBWidgets.createWidget({ | ||
widgetType: 'checkout', | ||
eventId: +eventId, | ||
iframeContainerId: 'checkout_widget' | ||
}); | ||
} | ||
|
||
function parseUrlParams() { | ||
var match, | ||
pl = /\+/g, // Regex for replacing addition symbol with a space | ||
search = /([^&=]+)=?([^&]*)/g, | ||
decode = function(s) { | ||
return decodeURIComponent(s.replace(pl, " ")); | ||
}, | ||
query = window.location.search.substring(1); | ||
|
||
var urlParams = {}; | ||
while (match = search.exec(query)) { | ||
urlParams[decode(match[1])] = decode(match[2]); | ||
} | ||
return urlParams; | ||
} | ||
|
||
function downloadWidgetJs(urlParams) { | ||
var widgetUrlMap = { | ||
qa: 'https://www.evbqa.com/static/widgets/eb_widgets.js', | ||
prod: 'https://www.eventbrite.com/static/widgets/eb_widgets.js' | ||
}; | ||
var scriptElement = document.createElement('script'); | ||
scriptElement.type = 'text/javascript'; | ||
scriptElement.src = widgetUrlMap[urlParams.env]; | ||
scriptElement.addEventListener('load', showWidget.bind(null, urlParams.eid)) | ||
document.getElementsByTagName('head')[0].appendChild(scriptElement); | ||
} | ||
|
||
function initApp() { | ||
var urlParams = parseUrlParams(); | ||
downloadWidgetJs(urlParams); | ||
} | ||
|
||
if (window.addEventListener) { | ||
window.addEventListener('load', initApp, false); | ||
} else if (window.attachEvent) { | ||
window.attachEvent('onload', initApp); | ||
} else { | ||
window.onload = initApp; | ||
} |