Monday, August 29, 2011

How to have great wait cursor animations for free


While searching for a "trivial" wait animation for one of my AJAX projects I've found a great online solution for the problem. It has been around for years now, but it's new for me and I decided to share it.

Introducing http://ajaxload.info/ a free AJAX load animation generator. It's great to have it around.

Here are some images I've created briefly as a showcase ..... well I guess they already have your attention :)







Thursday, August 25, 2011

Linking to Android Market applications on the web

While working on web version of Da Dictionary I've decided to add link to Android version. Web links to Android Market looks like this http://market.android.com/details?id=com.demosten.android.dadict where 'com.demosten.android.dadict' is the package name which is unique for Android Market. This seams to work well when opened from PC browser. However opening this link from Android is a different story. The best way to open it is directly in Android Market application which works with different URI scheme. It looks like market://details?id=com.demosten.android.dadict where again we see the same package name mentioned. While built-in Android browser plays it smart and open the link in directly in Market Application alternative browsers like Firefox does not do so and viewing web version of Android Market on an Android phone is far form what users expected to see.

My solution
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
  updateAndroidMarketLinks();
  // some more core here ... 
 
  function updateAndroidMarketLinks()
  {
    var ua = navigator.userAgent.toLowerCase();
    if (0 <= ua.indexOf("android")) {
      // we have android
      $("a[href^='http://market.android.com/']").each(function() {
        this.href = this.href.replace(/^http:\/\/market\.android\.com\//,
          "market://");
      });
    }
  }
});
</script>
</head>

<body>
<a href="http://market.android.com/details?id=com.demosten.android.dadict" target="_blank">Download for Android</a>
</body>

</html>
As you can see my solution is based on JavaScript and jQuery. The idea is to search for 'android' sub-string inside browser's UserAgent and if that is the case - replace HTTP URI part with Android Market URI part, inside all links.

I believe a JavaScript only version is not hard to do, but I prefer to use jQuery.