Created
February 26, 2012 05:27
-
-
Save sekimura/1913461 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div class="other-entries" style="display:none"> | |
<div class="other-entries-header"></div> | |
<ul class="other-entries-links"></ul> | |
</div> |
This file contains hidden or 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="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var blogId = '6a00d8341d3fee53ef0168e7ff9ed6970c'; | |
var assetId = TPToolbar.asset_xid; // haha. found it. | |
assetId = assetId || $('.entry').prop('id').replace('entry-', ''); | |
var url = 'http://api.typepad.com/assets/' + assetId + '/categories.json?max-results=1'; | |
$.ajax({ | |
url: url, | |
success: function(data) { | |
if (!data.entries || data.entries.length < 1) return; | |
var categoryLabel = data.entries[0]; | |
var url = 'http://api.typepad.com/blogs/' + blogId + '/post-assets/@published/@by-category/' + encodeURIComponent(categoryLabel) + '.json?max-results=4'; | |
$.ajax({ | |
url: url, | |
success: function(data) { | |
$(data.entries).each(function(i, entry) { | |
if (entry.urlId === assetId) return; | |
$('<li/>') | |
.append( | |
$('<a/>') | |
.prop('href', entry.permalinkUrl) | |
.text(entry.title) | |
) | |
.appendTo('.other-entries-links'); | |
if ($('.other-entries').is(':hidden')) { | |
$('.other-entries-header').text('other posts categorized "' + categoryLabel + '"'); | |
$('.other-entries').show(); | |
} | |
}); | |
} | |
}); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment