Thursday, July 15, 2010

New version of Subversion binaries

WANDisco, one of the Subversion project's earliest contributors, hosts the latest client and server binaries.

For a great Subversion client, visit the TortoiseSVN site

ps: Comments and/or links to this article are most welcome!
Enhanced by Zemanta

javascript dates, table sorting and jQuery

If you need to display date data in an HTML table and you want to use a nice display format yet still be able to sort correctly (i.e. as a date and not as text), here is how to do it.

Firstly, you need jQuery.
Then, one of the nicer jQuery table plugins, tableSorter.
And, finally, one of the coolest js date handlers, dateJS.

HTML:
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>

<script src="date.js.min.js" type="text/javascript"></script>

<script src="tableSorter/jquery.tablesorter.min.js" 
type="text/javascript"></script>

...
...
...
             <table id="dataTable" class="tablesorter">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Login name</th>
                        <th>Active till</th>
                        <th>Last logged in</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </tbody>
            </table>

Javascript:
// at start of js file
// -----------------------------------------------


// add a custom column sorter

  $.tablesorter.addParser(
  {
    // set a unique id
    id: 'nixDates',
    is: function(s)
    {
      // return false so this parser is not auto detected 
      return false;
    },
    format: function(s)
    {
      var dat = Date.parse(s);


      // format data for sorting. The following date format provides for meaningful sorting.
      var s = dat == null ? '' : dat.toString('yyyy-MM-dd');
      return s;
    },
    // set type, either numeric or text
    type: 'text'
  });
         

// now init the table-handler
  $('table#dataTable').tablesorter(
  {
    headers:
    { 
     // 3rd and 4th columns need special sorting
     2:    {sorter:'
nixDates'}
     ,3:   {sorter:'
nixDates'}
    }
  });

// -----------------------------------------------


// and later on, at the point where you want to populate the grid
// -----------------------------------------------
  var newRow;
  var fmtDat;
  var idx;
  var numberOfRows;  // this is set by earlier code not shown here
           
  for (idx = 0; idx < numberOfRows; idx++)
  {
     //gDataTable contains a jQuery object pointing to our 'table tbody'
     newRow = $('<tr></tr>').appendTo(gDataTable);
     $(newRow)
       .append('<td class="rowKey">' + data[idx].id + '</td>'
       +    '<td>' + data[idx].loginName + '</td>'
       );
               
       // Any fancy date format can be used here (thanks to dateJS).
       // Also, the sorting issue is taken care of by a custom sort handler on tablesorter. See top of this file.
       fmtDat = data[idx].activeTill == null ? '' : Date.parse(data[idx].activeTill).toString('ddd, dd MMM yyyy');
       $(newRow).append('<td fieldname="activeTill">' + fmtDat + '</td>');
               
       fmtDat = data[idx].lastLoggedIn == null ? '' : Date.parse(data[idx].lastLoggedIn).toString('ddd, dd MMM yyyy');
       $(newRow).append('<td fieldname="lastLoggedIn">' + fmtDat + '</td>');
       }
  }
// -----------------------------------------------

Note that a lot of code has been left out; the above is simply there to demonstrate the code specific to formatting the dates, as well as setting up and loading the grid.


ps: Comments and/or links to this article are most welcome!



Related articles by Zemanta
Enhanced by Zemanta

Bulletproof HTML5
fallback using jQuery

HTML5 will be with us very soon, so long as Microstuff doesn't mess anything up.

But just in case you wanted to start now, here is an article that shows you how you can do just that, even on that thing called Internet Exploder 6!

The article explains how you can use CSS, jQuery and HTML5 and have it behave correctly in all browsers.


ps: Comments and/or links to this article are most welcome!
Enhanced by Zemanta

Tuesday, July 6, 2010

Blistering fast filename search

Have a look at this web site. It contains a search utility that is the fastest I have ever seen.
It will scan all NTFS filesystems and return a list of all the matching files... very quickly!

Here is how the author describes it


"Everything" is an administrative tool that locates files and folders by filename instantly for Windows.
Unlike Windows search, "Everything" initially displays every file and folder on your computer (hence the name "Everything").
You type in a search filter to limit what files and folders are displayed.

ps: Comments and/or links to this article are most welcome!

Monday, June 28, 2010

Tracking outbound links (and downloads) in Google Analytics

The question came up recently on how to track outbound links and downloads in Google Analytics.

A quick search revealed quite a bit of info.

I combined ideas and suggestions from a number of places and came up with some jQuery-based code that suits our requirements.

Please note that the following code was extensively based on code/comments from the following:

Many thanks to the authors of the above blogs for their great work!
Please do visit their sites and check out their work.

So, without further delay, here is the code.

$(document).ready(function()
{
   
trackOutboundLinks();
});

function trackOutboundLinks()
{

    // Only hook  'a' tags that do not have a class of 'noLinkTracking'.
    // This allows us to optionally exclude links from tracking
    $('a').not('noLinkTracking').bind('click keypress', function(event)
    {
        // If GA is not initialised, don't bother going any further
        // UPDATE 31oct2009:

        // instead of 'if (pageTracker)', use this instead
        // as it will also work when pageTracker is not defined

        if (typeof(pageTracker) != undefined)
        {
            var href = $(this).attr('href');

            // only do this for external links
            if (this.hostname &amp;&amp; this.hostname !== location.hostname)
            {
                // Register an event and give it some meaningful values 
                //for our GA reports
                pageTracker._trackEvent('extenal', 'link', href);
            }
            // Track downloads of specified filetypes
            var fileTypes = ['doc','xls','pdf'];
           
            // Split the filename into period-separated parts
            var hrefArray = href.split('.');
           
            // look at the last one only
            var extension = hrefArray[hrefArray.length - 1];
            // one of those we want to track?
            if ($.inArray(extension,fileTypes) != -1)
            {
                pageTracker._trackEvent('download', extension, href);
            }
        }
    });
}


ps: Comments and/or links to this article are most welcome!

Monday, June 7, 2010

Lots of free PDF tools

This article has a great list of free PDF tools, that include editors, converters and many other PDF goodies.

There is also PDFCreator, which installs itself as a printer driver, so that any application can have its output sent to a PDF.


ps: Comments and/or links to this article are most welcome!

Wednesday, May 19, 2010

A picture to strike fear in your heart!!!




There are *no* words that could do this image justice!

Watch it and let your imagination run wild...or run for the hills!

Enjoy!


If you like this image, please leave a comment or rate it.



ps: Comments and/or links to this article are most welcome