Tag Cloud Sample Integration

A Tag Cloud may be displayed, for example, using an AJAX script on the appropriate pages. The code example requires the JavaScript “jQuery” library. If the URL points to an external address, security constraints will make it necessary to use a proxy script.

$(document).ready(
  function(){
    var minFontSize = 10;
    var maxFontSize = 30;
    var randomClasses = 4;
    $.ajax({
      type: 'GET',
      url: 'http://search.fact-finder.de/Company/TagCloud.ff?do=getTagCloud',
      data: {},
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      success:
        function (xml, textStatus) {
          var outputHtml = '';
          $.each( $('tagCloud entry', xml), function(i, n){
            var random = Math.floor(Math.random() * randomClasses);
            var weight = Number($(n).attr('weight'));
            var fontSize = minFontSize + Math.round((maxFontSize - minFontSize) * weight);
            var entry = '<span class="tagCloud'+random+'"'
                        +' style="font-size: '+fontSize+'px;">'
                        + '<a href="#">'+$(n).text()+'</a>'
                        + '</span>';
            outputHtml += entry;
          });
          $('#tagCloud').html(outputHtml);
        }
    });
});

You may also, for example, read the returned data and display it with a PHP function. This method has the advantage that users who have deactivated JavaScript will also be able to see the Tag Cloud.