tweetcast/nodejs/client/js/script.js
changeset 342 60b8281442b8
parent 341 cab5c9e10f90
--- a/tweetcast/nodejs/client/js/script.js	Fri Oct 28 18:48:14 2011 +0200
+++ b/tweetcast/nodejs/client/js/script.js	Wed Nov 02 17:13:23 2011 +0100
@@ -63,7 +63,7 @@
     if (!tweet) {
         return placeHolder(className);
     }
-	html = '<li class="tweet ' + className + '" id="tweet_' + tweet.pos + '" onclick="return clicTweet(' + tweet.pos + ')"';
+	var html = '<li class="tweet ' + className + '" id="tweet_' + tweet.pos + '" onclick="return clicTweet(' + tweet.pos + ')"';
 	if (tweetData.followLast && tweet.pos == tweetData.position) {
 	    html += ' style="display: none"';
 	}
@@ -76,15 +76,19 @@
     	html += '</div>';
 	}
 	html += '<div class="twmain">';
-	a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" target="_blank" title="' + tweet.user.name + '">';
+	a_user = '<a href="http://twitter.com/' + tweet.user.screen_name + '" var target="_blank" title="' + tweet.user.name + '">';
 	if (tweet.user.profile_image_url) {
 		html += a_user + '<img class="profile_image" src="' + tweet.user.profile_image_url + '" /></a>';
 	}
 	html += '<h4>' + a_user + '@' + tweet.user.screen_name + '</a></h4><p class="created_at">' + new Date(tweet.created_at).toLocaleTimeString() + '</p><p class="tweet_text">';
 	lastend = 0;
-	txt = tweet.text.replace(/(https?:[0-9a-zA-Z\/\-_\.~&?=]+)/g,'<a href="$1" target="_blank">$1</a>').replace(/@([0-9a-zA-Z_]+)/g,'<a href="http://twitter.com/$1" target="_blank">@$1</a>');
-/*	txt = '';
-	entities = [];
+	var tab = tweet.text.split(/\&\#|\;/);
+	var txta = '';
+	for (i = 0; i < tab.length; i++) {
+	    txta += (i % 2 && parseInt(tab[i]) != NaN) ? String.fromCharCode(tab[i]) : tab[i];
+	}
+	var txt = '',
+	    entities = [];
 	for (var i in tweet.entities.hashtags) {
 	    entities.push({
 	        "start" : tweet.entities.hashtags[i].indices[0],
@@ -96,7 +100,7 @@
 	    entities.push({
 	        "start" : tweet.entities.urls[i].indices[0],
 	        "end" : tweet.entities.urls[i].indices[1],
-	        "html" : '<a href="' + tweet.entities.urls[i].expanded_url + '" target="_blank">' + tweet.entities.urls[i].display_url + '</a>'
+	        "html" : '<a href="' + tweet.entities.urls[i].expanded_url + '" target="_blank">' + tweet.entities.urls[i].expanded_url + '</a>'
 	    });
 	}
 	for (var i in tweet.entities.user_mentions) {
@@ -108,10 +112,10 @@
 	}
  	entities.sort(function(a, b) { return a.start - b.start });
     for (var i in entities) {
- 		txt += tweet.text.substring(lastend, entities[i].start) + entities[i].html;
+ 		txt += txta.substring(lastend, entities[i].start) + entities[i].html;
         lastend = entities[i].end;
     }
-	txt += tweet.text.substring(lastend); */
+	txt += txta.substring(lastend);
 	html += txt + '</p></li></div>';
 	return html;
 }