jump to source
Full Source
<cfif structKeyExists(attributes, "expand")>
<!--- this is the magic stuff --->
<cfhttp method="get"
url="#attributes.expand#"
redirect="false"
result="cfhttp" />
<cfoutput>#cfhttp.responseHeader["Location"]#</cfoutput>
<cfelse>
<!--- render the UI --->
<cfoutput>
<a href="##source">jump to source</a><hr />
<style type="text/css">
pre { padding:10px;background-color:##eee;border:1px dashed ##ccc; }
ul { margin: 0px; padding: 0px; list-style: none; }
li { margin: 0px; padding: 5px; clear: left; }
li img { float: left; margin-right: 8px; }
hr { clear: left; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript">
function processSearchResult(data) {
var $listing = jQuery("##listing");
// write out the results, wrapping any shortened URLs
for (var i = 0; i < data.results.length; i++) {
var item = data.results[i];
// wrap urls with A tags
item.html = item.text.replace(/(http:\/\/((preview\.)?tinyurl\.com|is\.gd|bit\.ly|snurl\.com)\/[a-zA-Z0-9.\/]+)/g, '<a href="$1" class="short">$1</a>')
$listing.append('<li><img src="' + item.profile_image_url + '" />' + item.html + '</li>');
}
// set up the url expansion event listener
jQuery("a.short").mouseover(function(e) {
jQuery.get("?",
{
// convert preview.tinyurl.com to just tinyurl.com
expand: e.target.href.replace(/preview\.tinyurl\.com/, "tinyurl.com")
},
function(data) {
jQuery(e.target).html(data).unbind("mouseover")
}
);
});
}
// load the Twitter Search result via JSON/P
jQuery(function() {
jQuery("head").append('<script type="text/javascript" src="http://search.twitter.com/search.json?callback=processSearchResult&q=is.gd+OR+tinyurl.com+OR+snurl.com+OR+bit.ly"><\/script>');
})
</script>
<ul id="listing">
</ul>
<hr />
<a name="source"></a>
<h3>Full Source</h3>
<pre>#htmlEditFormat(replace(fileRead(getCurrentTemplatePath()), chr(9), " ", "all"))#</pre>
</cfoutput>
</cfif>