/*
* DC jQuery Social Stream
* Copyright (c) 2013 Design Chemical
* http://www.designchemical.com/blog/index.php/premium-jquery-plugins/jquery-social-stream-plugin/
* Version 1.5.12 (28-05-2015)
*
*/
(function($){
SocialStreamObject = function(el, options) {
this.create(el, options);
};
$.extend(SocialStreamObject.prototype, {
version : '1.5.12',
create: function(el, options) {
this.defaults = {
feeds: {
facebook: {
id: '',
intro: 'Posted',
out: 'intro,thumb,title,text,user,share',
text: 'content',
comments: 3,
image_width: 4, //3 = 600 4 = 480 5 = 320 6 = 180,
url: '/scripts/jquery-social-stream/facebook.php',
feed: 'feed', // feed, posts
icon: 'facebook.png'
},
twitter: {
id: '',
intro: 'Tweeted',
search: 'Tweeted',
out: 'intro,thumb,text,share',
retweets: false,
replies: false,
images: '', // large w: 786 h: 346, thumb w: 150 h: 150, medium w: 600 h: 264, small w: 340 h 150
url: 'twitter.php?sectionid=270',
icon: 'twitter.png'
},
google: {
id: '',
intro: 'Shared',
out: 'intro,thumb,title,text,share',
api_key: 'AIzaSyAWNgUpUj_W26tP3yev5Ysr4Zb53OIPgR4',
image_height: 75,
image_width: 75,
shares: true,
icon: 'google.png'
},
youtube: {
id: '',
intro: 'Uploaded',
search: 'Search',
out: 'intro,thumb,title,text,user,share',
text: 0,
api_key: 'AIzaSyB1zptnRspzltRVLGQJMBCH2yYujYp7ytI',
thumb: 'medium', //default 120 x 90, medium 320 x 180, high 480 x 360, standard 640 x 480
icon: 'youtube.png'
},
flickr: {
id: '',
intro: 'Uploaded',
out: 'intro,thumb,title,text,share',
lang: 'en-us',
icon: 'flickr.png'
},
delicious: {
id: '',
intro: 'Bookmarked',
out: 'intro,thumb,title,text,user,share',
icon: 'delicious.png'
},
pinterest: {
id: '',
intro: 'Pinned',
out: 'intro,thumb,text,user,share',
icon: 'pinterest.png'
},
rss: {
id: '',
intro: 'Posted',
out: 'intro,title,text,user,share',
text: 'contentSnippet',
icon: 'rss.png'
},
lastfm: {
id: '',
intro: 'Listened to,Loved,Replied',
out: 'intro,thumb,title,text,user,share',
feed: 'recenttracks,lovedtracks,replytracker',
icon: 'lastfm.png'
},
dribbble: {
id: '',
intro: 'Posted,Liked',
out: 'intro,thumb,title,text,user,share',
feed: 'shots,likes',
icon: 'dribbble.png'
},
vimeo: {
id: '',
intro: 'Liked,Video,Appeared In,Video,Album,Channel,Group',
out: 'intro,thumb,title,text,user,share',
feed: 'likes,videos,appears_in,all_videos,albums,channels,groups',
thumb: 'medium',
stats: true,
icon: 'vimeo.png'
},
stumbleupon: {
id: '',
intro: 'Shared,Reviewed',
out: 'intro,thumb,title,text,user,share',
feed: 'favorites,reviews',
icon: 'stumbleupon.png'
},
deviantart: {
id: '',
intro: 'Deviation',
out: 'intro,thumb,title,text,user,share',
icon: 'deviantart.png'
},
tumblr: {
id: '',
intro: 'Posted',
out: 'intro,title,text,user,share',
thumb: 100,
video: 250,
icon: 'tumblr.png'
},
instagram: {
id: '',
intro: 'Posted',
search: 'Search',
out: 'intro,thumb,text,user,share,meta',
accessToken: '',
redirectUrl: '',
clientId: '',
thumb: 'low_resolution',
comments: 3,
likes: 8,
icon: 'instagram.png'
}
},
remove: '',
twitterId: '',
days: 5,
limit: 10,
max: 'days',
external: true,
speed: 600,
height: 550,
wall: false,
centre: false,
order: 'date',
filter: true,
controls: true,
rotate: {
direction: 'up',
delay: 8000
},
transition: '0.8s',
cache: true,
container: 'dcsns',
cstream: 'stream',
content: 'dcsns-content',
iconPath: 'images/dcsns-dark/',
imagePath: 'images/dcsns-dark/',
debug: false
};
this.o = {}, this.timer_on = 0, this.id = 'dcsns-'+$(el).index(), this.timerId = '', this.o = $.extend(true,this.defaults,options), opt = this.o, $load = $('
creating stream ...
');
$(el).addClass(this.o.container).append('');
var $c = $('.'+this.o.content,el), $a = $('.'+this.o.cstream,el), $l = $('li',$a);
if(opt.height > 0 && opt.wall == false){
$c.css({height:opt.height+'px'});
}
if(this.o.filter == true || this.o.controls == true){
var x = '';
if(opt.wall == false){
$(el).append(x);
} else {
$(el).before(x);
}
}
if(this.o.wall == true){
$('.dcsns-toolbar').append($load);
var w = $("#dcsns-filter.dc-center").width()/2;
$("#dcsns-filter.dc-center").css({'margin-left': -w + "px"}).fadeIn();
this.createwall($a);
} else {
$c.append($load);
}
this.createstream(el,$a,0,opt.days);
this.addevents(el,$a);
if(this.o.rotate.delay > 0){
this.rotate(el);
}
$load.remove();
},
createstream: function(obj,s,f1,f2){
$.each(opt.feeds, function(k,v){
if(opt.feeds[k].id != ''){
var txt = [];
$.each(opt.feeds[k].intro.split(','), function(i,v){
v = $.trim(v);
txt.push(v);
});
$.each(opt.feeds[k].id.split(','), function(i,v){
v = $.trim(v);
if(opt.feeds[k].feed && v.split('#').length < 2){
if(k == 'youtube' && v.split('/').length > 1) {
getFeed(k,v,opt.iconPath,opt.feeds[k],obj,opt,f1,f2,'posted','',i);
} else {
$.each(opt.feeds[k].feed.split(','), function(i,feed){
getFeed(k,v,opt.iconPath,opt.feeds[k],obj,opt,f1,f2,txt[i],feed,i);
});
}
} else {
intro = v.split('#').length < 2 ? opt.feeds[k].intro : opt.feeds[k].search ;
getFeed(k,v,opt.iconPath,opt.feeds[k],obj,opt,f1,f2,intro,'',i);
}
});
}
});
},
createwall: function(obj){
obj.isotope({
itemSelector : 'li.dcsns-li',
transitionDuration: opt.transition,
getSortData : {
postDate : function( itemElem ){
return parseInt($(itemElem).attr('rel'),10);
}
},
sortBy : 'postDate',
masonry: {
isFitWidth: opt.center
}
});
},
addevents: function(obj,$a){
var self = this, speed = this.o.speed;
var $container = $('.stream',obj), filters = {}
$('.controls',obj).delegate('a','click',function(){
var x = $(this).attr('class');
switch(x)
{
case 'prev':
self.pauseTimer();
ticker($a,'prev',speed);
break;
case 'next':
self.pauseTimer();
ticker($a,'next',speed);
break;
case 'play':
self.rotate(obj);
$('.controls .play').removeClass('play').addClass('pause');
break;
case 'pause':
self.pauseTimer();
break;
}
return false;
});
$('.filter',obj).delegate('a','click',function(){
if(opt.wall == false){
var rel = $(this).attr('rel');
if($(this).parent().hasClass('active')){
$('.dcsns-'+rel,$a).slideUp().addClass('inactive');
$(this).parent().animate({opacity: 0.3},400);
} else {
$('.dcsns-'+rel,$a).slideDown().removeClass('inactive');
$(this).parent().animate({opacity: 1},400);
}
$(this).parent().toggleClass('active');
}
return false;
});
if(this.o.external){
$a.delegate('a','click',function(){
if(!$(this).parent().hasClass('section-share')){
this.target = '_blank';
}
});
}
},
rotate: function(a){
var self = this, stream = $('.'+this.o.cstream,a), speed = this.o.speed, delay = this.o.rotate.delay, r = this.o.rotate.direction == 'up' ? 'prev' : 'next' ;
this.timer_on = 1;
$('.controls .play').removeClass('play').addClass('pause');
this.timerId = setTimeout(function(){
ticker(stream,r,speed);
self.rotate(a);
}, delay);
},
pauseTimer: function(){
clearTimeout(this.timerId);
this.timer_on = 0;
$('.controls .pause').removeClass('pause').addClass('play');
}
});
$.fn.dcSocialStream = function(options, callback){
var d = {};
this.each(function(){
var s = $(this);
d = s.data("socialtabs");
if (!d){
d = new SocialStreamObject(this, options, callback);
s.data("socialtabs", d);
}
});
return d;
};
function getFeed(type,id,path,o,obj,opt,f1,f2,intro,feed,fn){
var stream = $('.stream',obj), list = [],d = '', px = 300, c = [],data, href, url, n = opt.limit, txt = [], src;
frl = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+n+'&callback=?&q=';
switch (type) {
case 'facebook':
var cp = id.split('/');
var curl = o.url.replace(/\&/gi, "&");
url = url = cp.length > 1 ? 'https://graph.facebook.com/'+cp[1]+'/photos?fields=id,link,from,name,picture,images,comments&limit='+n : curl + '?id='+id+'&limit='+n+'&feed='+o.feed;
break;
case 'twitter':
var curl = o.url.replace(/\&/gi, "&");
var cp = id.split('/'), cq = id.split('#'), cu = o.url.split('?'), replies = o.replies == true ? '&exclude_replies=false' : '&exclude_replies=true' ;
var param = '&include_entities=true&include_rts='+o.retweets+replies;
url1 = cu.length > 1 ? curl + '&' : curl + '?';
url = cp.length > 1 ? url1 + 'url=list&list_id='+cp[1]+'&per_page='+n+param : url1 + 'url=timeline&screen_name='+id+'&count='+n+param;
if(cq.length > 1){
var rts = o.retweets == false ? '+exclude:retweets' : '' ;
url = url1 + 'url=search&q='+cq[1]+'&count='+n;
}
break;
case 'google':
n = n > 100 ? 100 : n ;
href = 'https://plus.google.com/'+id;
url = 'https://www.googleapis.com/plus/v1/people/'+id+'/activities/public';
data = {key: o.api_key, maxResults: n, prettyprint: false, fields: "items(id,kind,object(attachments(displayName,fullImage,id,image,objectType,url),id,objectType,plusoners,replies,resharers,url),published,title,url,verb)"};
break;
case 'youtube':
n = n > 50 ? 50 : n ;
var cp = id.split('/'), cq = decodeURIComponent(id).split('#'), cc = id.split('!');
if(cq.length > 1){
url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&key=' + o.api_key + '&pageToken=&order=date&maxResults=' + n + '&q=' + cq[1];
href = 'https://www.youtube.com/results?search_query=' + cq[1];
} else {
if(cc.length > 1){
id = cc[1];
id = 'UU' + cc[1].substring(2);
href = 'https://www.youtube.com/channel/UC' + id.substring(2);
} else {
id = cp.length > 1 ? cp[1] : id ;
if(id.substr(0,2) != 'UU'){
// is channel ID
href = 'https://www.youtube.com/channel/' + id;
id = 'UU' + id.substring(2);
} else {
// is list ID
href = 'https://www.youtube.com/channel/UC' + id.substring(2);
}
}
url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=' + id + '&key=' + o.api_key + '&pageToken=&maxResults=' + n;
}
break;
case 'flickr':
var cq = id.split('/'), fd = cq.length > 1 ? 'groups_pool' : 'photos_public' ;
id = cq.length > 1 ? cq[1] : id ;
href = 'https://www.flickr.com/photos/'+id;
url = 'https://api.flickr.com/services/feeds/'+fd+'.gne?id='+id+'&lang='+o.lang+'&format=json&jsoncallback=?';
break;
case 'delicious':
href = 'https://www.delicious.com/'+id;
url = 'http://feeds.delicious.com/v2/json/'+id;
break;
case 'pinterest':
var cp = id.split('/');
url = 'https://www.pinterest.com/'+id+'/';
url += cp.length > 1 ? 'rss' : 'feed.rss';
href = 'http://www.pinterest.com/'+id;
url = frl + encodeURIComponent(url);
break;
case 'rss':
href = id;
url = frl + encodeURIComponent(id);
break;
case 'lastfm':
href = 'https://www.last.fm/user/'+id;
var ver = feed == 'lovedtracks' ? '2.0' : '1.0' ;
url = frl + encodeURIComponent('https://ws.audioscrobbler.com/'+ver+'/user/'+id+'/'+feed+'.rss');
break;
case 'dribbble':
href = 'https://www.dribbble.com/'+id;
url = feed == 'likes' ? 'http://api.dribbble.com/players/'+id+'/shots/likes' : 'http://api.dribbble.com/players/'+id+'/shots' ;
break;
case 'vimeo':
href = 'https://www.vimeo.com/'+id;
url = 'https://vimeo.com/api/v2/'+id+'/'+feed+'.json';
break;
case 'stumbleupon':
href = 'https://www.stumbleupon.com/stumbler/'+id;
url = frl + encodeURIComponent('http://rss.stumbleupon.com/user/'+id+'/'+feed);
break;
case 'deviantart':
href = 'https://'+id+'.deviantart.com';
url = frl + encodeURIComponent('https://backend.deviantart.com/rss.xml?type=deviation&q=by%3A'+id+'+sort%3Atime+meta%3Aall');
break;
case 'tumblr':
href = 'http://'+id+'.tumblr.com';
url = 'http://'+id+'.tumblr.com/api/read/json?callback=?&num='+n;
break;
case 'instagram':
href = '#';
url = 'https://api.instagram.com/v1';
var cp = id.substr(0,1), cq = id.split(cp), url1 = cq[1], qs = '', ts = 0;
switch(cp)
{
case '?':
var p = cq[1].split('/');
qs = '&lat='+p[0]+'&lng='+p[1]+'&distance='+p[2];
url += '/media/search';
break;
case '#':
url += '/tags/'+url1+'/media/recent';
ts = 1;
break;
case '!':
url += '/users/'+url1+'/media/recent';
break;
case '@':
url += '/locations/'+url1+'/media/recent';
break;
}
if(o.accessToken == '' && ts == 0){
if (location.hash) {
o.accessToken = location.hash.split('=')[1] ;
} else {
}
}
url += '?access_token='+o.accessToken+'&client_id='+o.clientId+'&count='+n+qs;
break;
}
var dataType = type == 'twitter' || type == 'facebook' ? 'json' : 'jsonp';
jQuery.ajax({
url: url,
data: data,
cache: opt.cache,
dataType: dataType,
success: function(a){
var error = '';
switch(type)
{
case 'facebook':
if(cp.length > 1){
a = a.data;
} else {
a = a.responseData.feed.entries;
}
break;
case 'google':
error = a.error ? a.error : '' ;
a = a.items;
break;
case 'flickr':
a = a.items;
break;
case 'instagram':
a = a.data;
break;
case 'twitter':
error = a.errors ? a.errors : '' ;
if(cq.length > 1){a = a.statuses} ;
break;
case 'youtube':
a = a.items;
break;
case 'dribbble':
a = a.shots;
break;
case 'tumblr':
a = a.posts;
break;
case 'delicious':
break;
case 'vimeo':
break;
case 'rss':
if(a.responseStatus == 200){
id = a.responseData.feed.title ? a.responseData.feed.title : id ;
a = a.responseData.feed.entries;
} else {
error = a.responseDetails;
}
break;
default:
if(a.responseStatus == 200){
a = a.responseData.feed.entries;
} else {
error = a.responseDetails;
}
break;
}
if(error == ''){
$.each(a, function(i,item){
if(i < n){
var html = [], q = item.link, u=''+id+'', w='', x = ''+item.title+'', y='', z='', zz='', m='', d = item.publishedDate, sq = q, st = item.title, s = '';
switch(type)
{
case 'facebook':
if(cp.length > 1){
id = item.from.id;
var d = new Date();
d = d.setFbAlbum(item.created_time);
var set = parseQ(item.link);
st = cp[0] != '' ? cp[0] : item.from.name ;
u = ''+st+'';
x = '';
if(item.images[o.image_width] == undefined){o.image_width = 0;}
z = '';
if(item.name){
z +=''+item.name+'
';
}
if(o.comments > 0 && item.comments){
i = 0;
m += '';
$.each(item.comments.data, function(i,cmt){
if(o.comments > i){
m += '';
i++;
} else {
return false;
}
});
}
z += m;
} else {
x = '';
thumb = item.thumb;
if(thumb != null)
{
if(thumb.indexOf('safe_image.php') != -1) {
thumb = unescape(thumb.match(/url=([^&]+)/)[1]);
}
y = '';
}
z = linkify(item.content);
}
break;
case 'twitter':
d = parseTwitterDate(item.created_at);
var un = item.user.screen_name, ua = item.user.profile_image_url_https ;
href = 'https://www.twitter.com/'+un;
q = href;
y = '' ;
z = '';
z += linkify(item.text);
if(o.images != '' && item.entities.media){
$.each(item.entities.media, function(i,media){
z += '';
});
}
sq = item.id_str;
break;
case 'delicious':
var d = new Date();
d = d.setRFC3339(item.dt);
x = ''+item.d+'';
q = item.u;
z = item.n;
sq = item.u;
st = item.d;
break;
case 'rss':
z = item[o.text];
break;
case 'pinterest':
var src = $('img',item.content).attr('src');
y = src ? '' : '' ;
z = item.contentSnippet;
st = z;
break;
case 'youtube':
x = item.snippet.title;
var vidId = cq.length > 1 ? item.id.videoId : item.snippet.resourceId.videoId ;
var ytthumb = o.thumb == '0' ? 'medium' : o.thumb ;
q = 'https://www.youtube.com/watch?v='+vidId+'&feature=youtube_gdata';
sq = q;
y = '';
z = o.text > 0 ? cut(item.snippet.description,o.text) : item.snippet.description ;
d = item.snippet.publishedAt;
var profile = 'Youtube';
if(cq.length > 1){
profile = decodeURIComponent(id);
} else if(cp.length > 1){
profile = cp[0];
} else if(cc.length > 1){
profile = cc[0];
}
u=''+profile+'';
break;
case 'flickr':
d = parseTwitterDate(item.published);
x = item.title;
y = '';
break;
case 'lastfm':
q = item.content;
break;
case 'dribbble':
q = item.url;
d = item.created_at;
x = ''+item.title+'';
y = '';
z = ''+num(item.views_count)+''+num(item.likes_count)+'';
sq = item.url;
break;
case 'instagram':
d = parseInt(item.created_time * 1000,10);
x = '';
y = '';
z = item.caption !=null ? htmlEncode(item.caption.text) : '' ;
if(item.comments.count > 0 && o.comments > 0){
i = 0;
m += '';
$.each(item.comments.data, function(i,cmt){
if(o.comments > i){
m += '';
i++;
} else {
return false;
}
});
}
if(item.likes.count > 0 && o.likes > 0){
i = 0;
m += ''+num(item.likes.count)+' likes';
m += '';
$.each(item.likes.data, function(i,lk){
if(o.likes > i){
m += '';
i++;
} else {
return false;
}
});
m += '';
}
u = ''+item.user.username+'';
href = 'https://instagram.com/'+item.user.username;
st = item.caption !=null ? item.caption.text : '' ;
break;
case 'vimeo':
f = feed, at = item.name, tx = item.description, q = item.url;
if(f == 'channels'){
y = item.logo != '' ? '' : '' ;
} else if(f == 'groups'){
y = '';
} else {
var thumb = 'thumbnail_'+o.thumb, at = item.title, tx = f != 'albums' ? item.duration+' secs' : item.description ;
y = '';
}
x = ''+at+'';
z = tx;
if(o.stats == true){
var m = '';
m += f == 'albums' || f == 'channels' || f == 'groups' ? ''+num(item.total_videos)+'' : '' ;
if(f == 'channels'){
m += ''+num(item.total_subscribers)+'';
} else if(f == 'groups'){
m += ''+num(item.total_members)+'';
} else if(f != 'albums'){
m += ''+num(item.stats_number_of_likes)+''+num(item.stats_number_of_plays)+'';
}
z += ''+m+'';
}
var dt = item.upload_date;
if(f == 'likes'){
dt = item.liked_on;
} else if(f == 'albums' || f == 'channels' || f == 'groups'){
dt = item.created_on;
}
var d = new Date();
d = d.setVimeo(dt);
sq = q;
st = at;
break;
case 'stumbleupon':
var src = $('img',item.content).attr('src');
y = src != '' && feed == 'favorites' ? '' : '' ;
z = item.contentSnippet;
break;
case 'deviantart':
var src = $('img',item.content).attr('src');
y = src ? '' : '' ;
z = item.contentSnippet;
break;
case 'tumblr':
q = item['url-with-slug'];
d = item.date;
x = '';
switch(item.type)
{
case 'photo':
x = item['photo-caption'];
z = '';
st = x;
break;
case 'video':
x += item['video-caption'];
z = o.video != '400' ? item['video-player-'+o.video] : item['video-player'] ;
st = x;
break;
case 'regular':
x += item['regular-title'];
z = item['regular-body'];
st = x;
break;
case 'quote':
x += item['quote-source'];
z = item['quote-text'];
st = x;
break;
case 'audio':
x = item['id3-artist'] ? ''+item['id3-artist']+' - '+item['id3-album']+'' : '' ;
x += item['id3-title'] ? ''+item['id3-title']+'' : '' ;
z = item['audio-caption'];
z += item['audio-player'];
st = item['id3-artist']+' - '+item['id3-album']+' - '+item['id3-title'];
break;
case 'conversation':
x += item['conversation-title'];
z = item['conversation-text'];
st = x;
break;
case 'link':
var ltxt = item['link-text'].replace(/:/g, '').replace(/\?/g, '').replace(/\!/g, '').replace(/\./g, '').replace(/\'/g, '').replace(/\(/g, '').replace(/\)/g, '').replace(/\@/g, '').replace(/\#/g, '').replace(/\|/g, '').replace(/\&/g, '');
x = ''+ltxt+'';
z = item['link-description'];
st = ltxt;
break;
}
x += item.type != 'photo' || item.type != 'audio' ? '' : '' ;
st = stripHtml(st);
sq = q;
break;
case 'google':
var g = item.object.replies ? num(item.object.replies.totalItems) : 0, m = item.object.plusoners ? num(item.object.plusoners.totalItems) : 0, p = item.object.resharers ? num(item.object.resharers.totalItems) : 0, dl;
var d = new Date();
d = d.setRFC3339(item.published);
dl = {src: "",imgLink: "",useLink: "",useTitle: ""};
var k = item.object.attachments;
if (k) if (k.length){
for (var l = 0; l < k.length; l++) {
var h = k[l];
if (h.image) {
dl.src = h.image.url;
dl.imgLink = h.url;
if (h.fullImage) {
dl.w = h.fullImage.width || 0;
dl.h = h.fullImage.height || 0
}
}
if (h.objectType == "article") dl.useLink = h.url;
if (h.displayName) dl.useTitle = h.displayName
}
if (!dl.useLink) dl.useLink = dl.imgLink;
var img_h = o.image_height ? o.image_height : 75 ;
var img_w = o.image_width ? o.image_width : 75 ;
if (dl.src.indexOf("resize_h") >= 0) dl.src = dl.w >= dl.h ? dl.src.replace(/resize_h=\d+/i, "resize_h=" + img_h) : dl.src.replace(/resize_h=\d+/i, "resize_w=" + img_w)
}
dl = dl;
q = dl.useLink;
y = (dl.src ? (dl.useLink ? '' : '')+''+(dl.useLink ? '' : '') : '');
var t1 = px/(dl.w/dl.h) < px/3 ? ' class="clear"' : '' ;
x = (dl.useLink ? '' : '')+(item.title ? item.title : dl.useTitle)+(dl.useLink ? '' : '');
if(o.shares){
z = '+1s '+m+''+p+'';
}
sq = q;
st = dl.useTitle;
break;
}
icon = '';
if(type == 'twitter'){
var intent = 'https://twitter.com/intent/';
s = '';
s += '';
s += '';
s += share('','https://twitter.com/'+un+'/status/'+sq,opt.twitterId);
} else {
s = share(st,sq,opt.twitterId);
}
$.each(o.out.split(','), function(i,v){
zz += v != 'intro' ? '' : '' ;
switch(v)
{
case 'intro':
if(type == 'twitter'){
zintro = ''+decodeURIComponent(intro)+' '+nicetime(new Date(d).getTime(),0)+'';
} else {
zintro = ''+decodeURIComponent(intro)+' '+nicetime(new Date(d).getTime(),0)+'';
}
break;
case 'title':
zz += x;
break;
case 'thumb':
if(type == 'rss'){
var src = item.content.indexOf("img") >= 0 ? $('img',item.content).attr('src') : '' ;
y = src ? '' : '' ;
}
zz += y;
break;
case 'text':
zz += z;
break;
case 'user':
zz += u;
break;
case 'meta':
zz += m;
break;
case 'share':
zz += s;
break;
}
zz += v != 'intro' ? '' : '' ;
});
var df = type == 'instagram' ? nicetime(d,1) : nicetime(new Date(d).getTime(),1);
var ob = df;
switch(opt.order)
{
case 'random':
ob = randomish(6);
break;
case 'none':
ob = 1;
break;
}
var out = ''+w+''+zz+'
'+zintro+icon+'', str = decodeURIComponent(opt.remove), rem = q;
if(type == 'twitter'){
rem = 'https://twitter.com/'+un+'/status/'+item.id_str;
}
if( str.indexOf( rem ) !== -1 && rem != '' ){
n = n + 1;
} else {
if(opt.max == 'days'){
if(df <= f2 * 86400 && df >= f1 * 86400){
list.push(out);
} else if(df > f2 * 86400) {
return false;
}
} else {
list.push(out);
}
}
}
});
} else if(opt.debug == true){
list.push('Error. '+error+'');
}
},
complete: function(){
var $newItems = $(list.join(''));
if(opt.wall == true){
stream.isotope( 'insert', $newItems );
if(type == 'facebook' && cp.length < 2){
setTimeout(function(){
stream.isotope('layout');
},1000);
$('img',stream).on('load', function(){ stream.isotope('layout'); });
}
if(type == 'twitter'){
setTimeout(function(){
stream.isotope('layout');
},1000);
$('img',stream).on('load', function(){ stream.isotope('layout'); });
}
} else {
stream.append($newItems);
sortstream(stream,'asc');
}
if(type == 'facebook' && cp.length < 2){
fbHrefLink(id,$newItems);
} else if(type == 'flickr' && cq.length > 1){
flickrHrefLink(cq[1],$newItems);
}
}
});
return;
}
function linkify(text){
text = text.replace(
/((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,
function(url){
var full_url = !url.match('^https?:\/\/') ? 'http://' + url : url ;
return '' + url + '';
}
);
text = text.replace(/(^|\s)@(\w+)/g, '$1@">$2');
text = text.replace(/(^|\s)#(\w+)/g, '$1#">$2');
return text;
}
function cut(text,n){
var short = text.substr(0, n);
if (/^\S/.test(text.substr(n)))
short = short.replace(/\s+\S*$/, "");
return short;
}
function htmlEncode(v){
return $('').text(v)();
}
function stripHtml(v){
var $html = $(v);
return $html.text();
}
Date.prototype.setRFC3339 = function(dString){
var utcOffset, offsetSplitChar;
var offsetMultiplier = 1;
var dateTime = dString.split('T');
var date = dateTime[0].split('-');
var time = dateTime[1].split(':');
var offsetField = time[time.length - 1];
var offsetString;
offsetFieldIdentifier = offsetField.charAt(offsetField.length - 1);
if (offsetFieldIdentifier == 'Z') {
utcOffset = 0;
time[time.length - 1] = offsetField.substr(0, offsetField.length - 2);
} else {
if (offsetField[offsetField.length - 1].indexOf('+') != -1) {
offsetSplitChar = '+';
offsetMultiplier = 1;
} else {
offsetSplitChar = '-';
offsetMultiplier = -1;
}
offsetString = offsetField.split(offsetSplitChar);
time[time.length - 1] == offsetString[0];
offsetString = offsetString[1].split(':');
utcOffset = (offsetString[0] * 60) + offsetString[1];
utcOffset = utcOffset * 60 * 1000;
}
this.setTime(Date.UTC(date[0], date[1] - 1, date[2], time[0], time[1], time[2]) + (utcOffset * offsetMultiplier ));
return this;
};
Date.prototype.setFbAlbum = function(dString){
var utcOffset, offsetSplitChar = '+', offsetMultiplier = 1, dateTime = dString.split('T'), date = dateTime[0].split('-'), time = dateTime[1].split(':'), offsetField = time[time.length - 1], offsetString;
if (offsetField[offsetField.length - 1].indexOf('+') != -1) {
offsetSplitChar = '-';
offsetMultiplier = -1;
}
offsetTime = offsetField.split(offsetSplitChar);
utcOffset = parseInt((offsetTime[1]/100),10) * 60 * 1000;
this.setTime(Date.UTC(date[0], date[1] - 1, date[2], time[0], time[1], offsetTime[0]) + (utcOffset * offsetMultiplier ));
return this;
};
Date.prototype.setVimeo = function(dString){
var utcOffset = 0, offsetSplitChar, offsetMultiplier = 1;
var dateTime = dString.split(' ');
var date = dateTime[0].split('-');
var time = dateTime[1].split(':');
this.setTime(Date.UTC(date[0], date[1] - 1, date[2], time[0], time[1], time[2]) + (utcOffset * offsetMultiplier ));
return this;
};
function parseTwitterDate(a){
var out = !!navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.indexOf("MSIE")>= 0 ? a.replace(/(\+\S+) (.*)/, '$2 $1') : a ;
return out;
}
function nicetime(a,out){
var d = Math.round((+new Date - a) / 1000), fuzzy = '', n = 'mins';
if(out == 1) {
return d;
} else if(out == 0) {
var chunks = new Array();
chunks[0] = [60 * 60 * 24 * 365 , 'year', 'years'];
chunks[1] = [60 * 60 * 24 * 30 , 'month', 'months'];
chunks[2] = [60 * 60 * 24 * 7, 'week', 'weeks'];
chunks[3] = [60 * 60 * 24 , 'day', 'days'];
chunks[4] = [60 * 60 , 'hr', 'hrs'];
chunks[5] = [60 , 'min', 'mins'];
var i = 0, j = chunks.length;
for (i = 0; i < j; i++) {
s = chunks[i][0];
if ((xj = Math.floor(d / s)) != 0)
{
n = xj == 1 ? chunks[i][1] : chunks[i][2] ;
break;
}
}
fuzzy += xj == 1 ? '1 '+n : xj+' '+n ;
if (i + 1 < j) {
s2 = chunks[i + 1][0];
if ( ((xj2 = Math.floor((d - (s * xj)) / s2)) != 0) )
{
n2 = (xj2 == 1) ? chunks[i + 1][1] : chunks[i + 1][2] ;
fuzzy += (xj2 == 1) ? ' + 1 '+n2 : ' + '+xj2+' '+n2 ;
}
}
fuzzy += ' ago';
return fuzzy;
}
}
function num(a){
var b = a;
if (a > 999999) b = Math.floor(a / 1E6) + "M";
else if (a > 9999) b = Math.floor(a / 1E3) + "K";
else if (a > 999) b = Math.floor(a / 1E3) + "," + a % 1E3;
return b
}
function parseQ(url){
var v = [], hash, q = url.split('?')[1];
if(q != undefined){
q = q.split('&');
for(var i = 0; i < q.length; i++){
hash = q[i].split('=');
v.push(hash[1]);
v[hash[0]] = hash[1];
}
}
return v;
}
function getImg(content){
var imgArr = new Array(), reg = / 0 && imgArr[0].indexOf('sndcdn.com') === -1){
var image = imgArr[0];
if(image.indexOf('instagram.com/profiles') !== -1) { image = imgArr[1]; }
image = image.replace("_m.jpg", ".jpg");
if(image.indexOf('fbcdn') == -1) {
image = image.replace("_b.jpg", "_f.jpg");
image = image.replace("_b.png", "_f.png");
} else {
if(image.indexOf('safe_image.php') == -1) {
var id = image.split("_"), object_id = id[1];
image = 'http://graph.facebook.com/'+object_id+'/picture?type=normal';
}
}
image = image.replace("_s.jpg", "_b.jpg");
image = image.replace("_m.png", ".png");
image = image.replace("_s.png", "_b.png");
image = image.replace(/\&/g,'&');
if(image.indexOf('safe_image.php') != -1){
image = unescape(image.match(/url=([^&]+)/)[1]);
}
if(image.indexOf('app_full_proxy.php') != -1){
image = unescape(image.match(/src=([^&]+)/)[1]);
}
if(this.prefix == 'https://'){
var image_tmp = image.replace('http://', 'https://');
image = image_tmp;
}
} else {
return false
}
return image;
}
function sortstream(obj,d){
var $l = $('li',obj);
$l.sort(function(a, b){
var keyA = parseInt($(a).attr('rel'),10), keyB = parseInt($(b).attr('rel'),10);
if(d == 'asc'){
return (keyA > keyB) ? 1 : -1;
} else {
return (keyA < keyB) ? 1 : -1;
}
return 0;
});
$.each($l, function(index, row){
obj.append(row);
});
$('.dcsns-loading').slideUp().remove();
return;
}
function randomish(l){
var i = 0, out = '';
while(i < l){
out += Math.floor((Math.random()*10)+1)+'';
i++;
}
return out;
}
function ticker(s,b,speed){
var $a = $('li:last',s),$b = $('li:first',s),$gx,bh = $b.outerHeight(true);
if($('li',s).not('.inactive').length > 2){
if(b == 'next'){
$gx = $a.clone().hide();
$b.before($gx);
$a.remove();
if($a.hasClass('inactive')){
ticker(s,b,speed);
} else {
$('.inner',$gx).css({opacity: 0});
$gx.slideDown(speed,'linear',function(){
$('.inner',this).animate({opacity: 1},speed);
});
return;
}
} else {
$gx = $b.clone();
if($b.hasClass('inactive')){
$a.after($gx);
$b.remove();
ticker(s,b,speed);
} else {
$b.animate({marginTop: -bh+'px'},speed,'linear',function(){
$a.after($gx);
$b.remove();
});
$('.inner',$b).animate({opacity: 0},speed);
}
}
}
}
function fbHrefLink(id,obj){
jQuery.ajax({
url: 'https://graph.facebook.com/'+id,
dataType: 'jsonp',
success: function(a){
$('.icon',obj).each(function(){
$(this).parent().attr('href',a.link);
});
$('.section-user a',obj).each(function(){
$(this).attr('href',a.link);
$(this).text(a.name);
});
}
});
}
function flickrHrefLink(id,obj){
jQuery.ajax({
url: 'http://api.flickr.com/services/feeds/groups_pool.gne?id='+id+'&format=json&jsoncallback=?',
dataType: 'jsonp',
success: function(a){
$('.icon',obj).each(function(){
$(this).parent().attr('href',a.link);
});
}
});
}
function share(st,sq,twitterId){
var s = '', sq = encodeURIComponent(sq), st = encodeURIComponent(st);
s = '';
s += '';
s += '';
s += '';
return s;
}
})(jQuery);
jQuery(window).load(function(){
jQuery.getScript("//platform.twitter.com/widgets.js", function(){});
jQuery('.section-share a').click(function(){
var u = jQuery(this).attr('href');
window.open(u,'sharer','toolbar=0,status=0,width=626,height=436');
return false;
});
});