<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdn.rawgit.com/doubledutch/sdk/master/DDEventsSDK.js"></script>
<script src="https://eventualize.herokuapp.com/DDEventsSDKEmulator.js"></script>
</head>
<body>
<body>
<div>Current Attendee JSON:</div>
<textarea id="user-json"></textarea>
<div>Current Attendee JSON from API:</div>
<textarea id="user-api-json"></textarea>
<div>Current Event JSON:</div>
<textarea id="event-json"></textarea>
<div>Current attendee token (<a href="https://github.com/doubledutch/verify-user-token" target="_blank">How to decode and verify</a>):</div>
<textarea id="token"></textarea>
<div id="user">
<div class="head">Current Attendee:</div>
<span id="user-identifier"></span>
<div class="content">
<img class="image" />
<div class="text">
<div> <span id="user-firstName"></span>
<span id="user-lastName"></span>
</div>
<div id="user-work"> <span id="user-title"></span> @
<span id="user-company"></span>
</div>
</div>
</div>
</div>
<div id="event">
<div class="head">Current Event:</div>
<div class="content">
<img class="image" />
<div class="text">
<div id="event-name"></div>
<div id="event-desc"></div>
<div id="event-dates"> <span id="event-start"></span> - <span id="event-end"></span>
</div>
</div>
</div>
</div>
</body>
</body>
</html>
$(function () {
DD.Events.onReady(function () {
// Get Posts from the app.
DD.Events.getCurrentUserAsync(function (user) {
$("#user-json").val(JSON.stringify(user));
$("#user .image").attr("src", user.ImageUrl);
$("#user-firstName").text(user.FirstName);
$("#user-lastName").text(user.LastName);
$("#user-company").text(user.Company);
$("#user-title").text(user.Title);
$("#user-identifier").text(user.UserIdentifierId);
});
// Get the current event in the app.
DD.Events.getCurrentEventAsync(function (event) {
$("#event-json").val(JSON.stringify(event));
$("#event .image").attr("src", event.Icon);
$("#event-name").text(event.Name);
$("#event-desc").text(event.Description);
$("#event-start").text(new Date(event.StartDate).toDateString());
$("#event-end").text(new Date(event.EndDate).toDateString());
});
var ddApiHeaders = function(authHeader) {
var headers = {
'X-DDAPI-Version': '5.12.0.0'
};
if (authHeader) {
headers.Authorization = authHeader;
}
return headers;
};
DD.Events.getSignedAPIAsync("users/me", "", function (signedUrl, authHeader) {
$.ajax(signedUrl, {
headers: ddApiHeaders(authHeader),
success: function(data) {
var users = data.Value;
if (users && users.length) {
$("#user-api-json").val(JSON.stringify(users[0]));
}
}
});
});
DD.Events.getSignedAPIAsync("images/users?count=10", "", function (signedUrl, authHeader) {
$.ajax(signedUrl, {
headers: ddApiHeaders(authHeader),
success: function(data) {
var users = data.Value;
$.each(users, function (index, user) {
var image = $("<img src='" + user.ImageUrl + "' />");
image.appendTo("body");
});
}
});
});
DD.Events.getSignedAPIAsync("users/me/token", "", function (signedUrl, authHeader) {
$.ajax(signedUrl, {
headers: ddApiHeaders(authHeader),
success: function (data) {
var token = data.Value;
$("#token").text(token);
}
});
});
});
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |