﻿function loadTweets() {
    $.ajax({
        type: "POST",
        url: "http://respeak.net/TwitterService.asmx/GetLatestTweets",
        data: "{}",
        contentType: "application/json; charset=8",
        dataType: "json",
        success: function (result) {
            if (result.d != null && result.d != undefined) {
                var tweets = $(result.d);
                if (tweets.length > 0) {
                    // get the first tweet
                    //alert(tweets[0].Source);
                    var words = tweets[0].Text.split(" ");
                    var txt = "";
                    $(words).each(function (i, w) {
                        if (w.startsWith("http://") || w.startsWith("https://")) {
                            words[i] = '<a href="' + words[i] + '">' + words[i] + '</a>';
                        }
                        txt = txt + words[i] + " ";
                    });

                    $('#divTweet').html(txt);
                }
            }

        },
        error: function (xhreq, status, err) {
            alert(xhreq.responseText);
        },
        complete: function (xrq, status) {
        }
    });
    //ReSpeak.Services.TwitterService.GetLatestTweets(GetTweetSuccess, GetTweetFailure, '');
}


function GetTweetFailure(result) {

}