another twitter jquery

from http://www.thewebsqueeze.com/web-design-tutorials/displaying-your-tweets-on-your-website-with-jquery.html

by dirkk0

HTML

<div id="tweets">
    <h3 id="error">There was a problem fetching tweets</h3>
    <h3 id="preload">Currently loading your tweets...</h3>
</div>

JavaScript

var tweetArray = [""];

function showTweets(username, number) {
    var html = '<ul>';
    var elem = $('#tweets');
    var tweetFeed = 'http://twitter.com/status/user_timeline/' + username + '.json?count=' + number + '&callback=?';
    $.getJSON(tweetFeed, function(d) {
        $.each(d, function(i, item) {
            console.log(i + "i " + item.text.substr(0, 10));
            if (tweetArray.length > 0) {
                for (var j = 0; j < tweetArray.length; j++) {
                    var exists = false;
                    console.log(j + "j " + tweetArray[j].substr(0, 10));
                    if (item.text == tweetArray[j]) {
                        // element already exists.
                        html += '<li>' + item.text + ' (alt)</li>';
                        exists = true;
                        break;
                    }
                }
                if (exists == false) {
                    tweetArray.push(item.text);
                    html += '<li>' + item.text + ' (neu)</li>';
                }
            }
            else {
                // console.log("ddd" + item.text);
                tweetArray.push(item.text);
                html += '<li>' + item.text + ' (frisch)</li>';
            }
        })
        html += "</ul>";
        console.log("length " + tweetArray.length);

        elem.html(html);
/* elem.children().fadeOut('fast', function() {
            elem.html(html);
        }) */
    })
}

function doAll() {
    $('#error').remove();
    $('#preload').show();
    showTweets('dirkomud', 5)
    // console.log('test');
}

// window.setInterval(doAll, 5000);
// doAll();
doAll();