Jul 31, 2010

Enabling Lightbox on Google's Blogger


It's fairly simple. Just add a simple JavaScript to the template next to the Lightbox import.
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#Blog1 a img[class!=icon-action]').parent().attr('rel','lightbox[imgs]');
jQuery('#Blog1 a img[class!=icon-action]').parent().attr('title','© ┼Żan Kafol');
});
</script>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen">

Jul 16, 2010

JavaScript: escape()

When you're sending a string through a GET request with javascript, you should obviously URL encode the string to ensure all characters get transmitted. The escape() function in javascript works fairly well, even when you're sending UTF-8 characters. But the + character is interpreted as a space in the GET request, so you need to handle it manually. Here's how I do it:
 msg = msg.replace(/\+/g,'%2B'); 
 geturl('ajax.get.php?msg='+escape(msg));
First, you do a global regex match for the plus character, replace it with it's url encoded equivalent, and then you url encode the string with escape().

Jul 12, 2010

Example usage of Facebook.streamPublish()

DUE TO FREQUENT FACEBOOK API CHANGES THIS ARTICLE IS OUTDATED.

You can force streamPublish dialog from within the href bar in the browser. Also note the application ID prefix in the functions. More detailed code description is superfluous. javascript:c=9999999;h='Click Challenge';l='http://apps.facebook.com/click-challenge-en/?ref_6w=f_clicks';a126752370697733_Facebook.streamPublish('',{'name':h,'href':l,'caption':'{*actor*} made '+(c/1)+' clicks in 10 seconds.','properties':{'Speed':{'text':(c/10)+' clicks/sec','href':l}},'media':[{'type':'image','src':'http://w6.6waves.com/my-app/data/126752370697733/logo.gif','href':l}]},[{'text':h,'href':l}]);