diff --git a/src/js/facebook-stream.js b/src/js/facebook-stream.js new file mode 100644 index 0000000..545d1c9 --- /dev/null +++ b/src/js/facebook-stream.js @@ -0,0 +1,362 @@ +/*********************************************************** +* #### jQuery-Facebook-Streaming v4.0 #### +* Coded by Ican Bachors 2014. +* https://github.com/bachors/jQuery-Facebook-Stream +* Updates will be posted to this site. +***********************************************************/ + +$.fn.facebook_stream = function(n, o, p) { + var j = '
Image
'; + j += ' ';
+ j += '' + h.data[i].from.name + '
';
+ var b = '';
+ if (h.data[i].comments == null || h.data[i].comments == undefined) {
+ b += '0'
+ } else {
+ if (h.data[i].comments.data.length == 25) {
+ b += h.data[i].comments.data.length + '+'
+ } else {
+ b += h.data[i].comments.data.length
+ }
+ }
+ var c = '';
+ if (h.data[i].likes == null || h.data[i].likes == undefined) {
+ c += '0'
+ } else {
+ if (h.data[i].likes.data.length == 25) {
+ c += h.data[i].likes.data.length + '+'
+ } else {
+ c += h.data[i].likes.data.length
+ }
+ }
+ j += ' ' + relative_time(h.data[i].created_time) + '
' + htmlEntities(h.data[i].message) + '' + } + if (h.data[i].story != null || h.data[i].story != undefined) { + j += h.data[i].story + '
' + htmlEntities(c.data[i].message) + '' + } else { + d += '
View more comments
' + } + } + if (h == 'html') { + $('.FS_blscm' + e).html(d) + } else { + $('.FS_blscm' + e).append(d) + } + $('.fcm_more' + e).click(function() { + var a = c.paging.cursors.after; + if (a != null || a != undefined) { + FS_morekomen(e, a, 'append'); + $('.FS_blscm' + e + ' .load_more_komen').remove(); + return false + } + }) + }) + } + + function FS_subkomen(e, g) { + $.ajax({ + url: 'https://graph.facebook.com/v2.9/' + e + '/comments?fields=created_time,from,message,id,like_count&access_token=' + p + '&after=' + g, + crossDomain: true, + dataType: 'json' + }).done(function(c) { + var d = ''; + $.each(c.data, function(i, a) { + d += '' + htmlEntities(c.data[i].message) + '' + } else { + d += '
View more comments
' + } + } + $('#komen_sub_' + e).append(d); + $('.fcm_moresub').click(function() { + var a = c.paging.cursors.after; + if (a != null || a != undefined) { + FS_subkomen(e, a); + $('#komen_sub_' + e + ' .load_more_komen_sub').remove(); + return false + } + }); + }) + } + + function FS_gambarg(c) { + $.ajax({ + url: 'https://graph.facebook.com/v2.9/' + c + '?fields=attachment&access_token=' + p, + crossDomain: true, + dataType: 'json' + }).done(function(a) { + var b = ''; + if (a.attachment != null || a.attachment != undefined) { + b += '' + } + $('.FS_comg' + c).html(b); + $('.FS_popup').click(function() { + $("html, body").animate({ + scrollTop: 0 + }, 0); + $(id + ' .modalDialog p').html(''); + $(id + ' .modalDialog').css("opacity", "1"); + $(id + ' .modalDialog').css("pointer-events", "auto"); + return false + }); + $(id + ' .modalDialog .close').click(function() { + $(id + ' .modalDialog').css("opacity", "0"); + $(id + ' .modalDialog').css("pointer-events", "none"); + return false + }) + }) + } + + function htmlEntities(a) { + return FS_urltag(String(a).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"')) + } + + function relative_time(a) { + if (!a) { + return + } + a = $.trim(a); + a = a.replace(/\.\d\d\d+/, ""); + a = a.replace(/-/, "/").replace(/-/, "/"); + a = a.replace(/T/, " ").replace(/Z/, " UTC"); + a = a.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"); + var b = new Date(a); + var c = (arguments.length > 1) ? arguments[1] : new Date(); + var d = parseInt((c.getTime() - b) / 1000); + d = (d < 2) ? 2 : d; + var r = ''; + if (d < 60) { + r = 'Just now' + } else if (d < 120) { + r = 'a min' + } else if (d < (45 * 60)) { + r = (parseInt(d / 60, 10)).toString() + ' mins ago' + } else if (d < (2 * 60 * 60)) { + r = 'an hr' + } else if (d < (24 * 60 * 60)) { + r = '' + (parseInt(d / 3600, 10)).toString() + ' hrs ago' + } else if (d < (48 * 60 * 60)) { + r = 'a day' + } else { + r = (parseInt(d / 86400, 10)).toString() + ' days ago' + } + return r + } + + function FS_urltag(c, d) { + var e = { + lt: { + regex: /(<)/g, + template: '<' + }, + gt: { + regex: /(>)/g, + template: '>' + }, + dq: { + regex: /(")/g, + template: '"' + }, + sq: { + regex: /(')/g, + template: ''' + }, + link: { + regex: /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, + template: "$1" + }, + hash: { + regex: /(^|\s)#(\w+)/g, + template: '$1#$2' + }, + email: { + regex: /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi, + template: '$1' + } + }; + var f = $.extend(e, d); + $.each(f, function(a, b) { + c = c.replace(b.regex, b.template) + }); + return c + } +}