////////////////////
//Social Stream Presence: Parser module
////////////////////
PRESENCE.PARSER = (function(P,$,undefined){
////////////////////
//Hash table
////////////////////
var chatIcons = new Array();
chatIcons[':)'] = "face-smile.png";
chatIcons[':('] = "face-sad.png";
chatIcons['(B)'] = "beer.png";
chatIcons['(C)'] = "clock.png";
chatIcons['(P)'] = "present.png";
chatIcons[':P']= "face-raspberry.png";
chatIcons[':Z']= "face-tired.png";
chatIcons['(R)']= "rain.png";
chatIcons['(S)']= "sun.png";
chatIcons[';)']= "face-wink.png";
var init = function(){ }
///////////////////////////////////////////////////////
// Parser functions
// Allow new features in chat msg like links, images, emoticons, ...
///////////////////////////////////////////////////////
//Patterns
var html_tag_pattern=/.*\<[^>]+>.*/g
var simple_word_pattern=/^[aA-zZ0-9]+$/g
var http_urls_pattern=/(http(s)?:\/\/)([aA-zZ0-9%=_&+?])+([./-][aA-zZ0-9%=_&+?]+)*[/]?/g
var www_urls_pattern = /(www[.])([aA-zZ0-9%=_&+?])+([./-][aA-zZ0-9%=_&+?]+)*[/]?/g
var icons_a_pattern=/\([A-Z]\)/g
var icons_b_pattern=/((:|;)([()A-Z]))/g
var youtube_video_pattern=/(http(s)?:\/\/)?(((youtu.be\/)([aA-zZ0-9]+))|((www.youtube.com\/watch\?v=)([aA-z0-9Z&=.])+))/g
function getParsedContent(content,fromUser){
if (fromUser){
var chatTextclass = "ownChatText"
} else {
var chatTextclass = "guestChatText"
}
return ("" + parseContent(content) + "");
}
function parseContent(content){
if (content.match(html_tag_pattern)!=null){
content = content.replace(/>/g, ">");
content = content.replace(/" + content + ""
}
var words = content.split(" ");
for(i=0; i" + "";
}
function buildYoutubeVideoLink(url){
//Get youtube video id
var youtube_video_id=url.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
var youtube_api_url = "http://gdata.youtube.com/feeds/api/videos/" + youtube_video_id
//Get info from the video
$.ajax({
type: "GET",
url: youtube_api_url,
cache: false,
dataType:'jsonp',
success: function(data){
var url_name = url;
var youtube_video_thumbnail = "";
//Video title
var video_title = $(data).find("media\\:title")
if (video_title.length > 0) {
//url_name = url + " (" + $(video_title).text() + ")";
url_name = $(video_title).text()
}
//Thumbnails
var thumbnails = $(data).find("media\\:thumbnail")
if (thumbnails.length>0){
var thumbnail_url = $(thumbnails[0]).attr("url")
if (thumbnail_url!=null){
youtube_video_thumbnail = "