1if (typeof Object.create !== 'function') { 2 Object.create = function(obj) { 3 function F() {} 4 F.prototype = obj; 5 return new F(); 6 }; 7} 8 9(function($, window, document, undefined) { 10 $.fn.socialfeed = function(_options) { 11 12 13 var defaults = { 14 plugin_folder: '_assets_/plugins/social-feed/', // a folder in which the plugin is located (with a slash in the end) 15 template: 'template.html', // a path to the template file 16 show_media: false, // show images of attachments if available 17 media_min_width: 300, 18 length: 500, // maximum length of post message shown 19 date_format: 'll' 20 }; 21 //--------------------------------------------------------------------------------- 22 var options = $.extend(defaults, _options), 23 container = $(this), 24 template, 25 social_networks = ['facebook', 'instagram', 'vk', 'google', 'blogspot', 'twitter', 'pinterest', 'rss'], 26 posts_to_load_count = 0, 27 loaded_post_count = 0; 28 // container.empty().css('display', 'block'); 29 //--------------------------------------------------------------------------------- 30 31 //--------------------------------------------------------------------------------- 32 // This function performs consequent data loading from all of the sources by calling corresponding functions 33 function calculatePostsToLoadCount() { 34 social_networks.forEach(function(network) { 35 if (options[network]) { 36 if (options[network].accounts) { 37 posts_to_load_count += options[network].limit * options[network].accounts.length; 38 } else { 39 posts_to_load_count += options[network].limit; 40 } 41 } 42 }); 43 } 44 45 calculatePostsToLoadCount(); 46 47 function fireCallback() { 48 var fire = true; 49 /*$.each(Object.keys(loaded), function() { 50 if (loaded[this] > 0) 51 fire = false; 52 });*/ 53 if (fire && options.callback) { 54 options.callback(); 55 } 56 } 57 58 var Utility = { 59 request: function(url, callback) { 60 $.ajax({ 61 url: url, 62 dataType: 'jsonp', 63 success: callback 64 }); 65 }, 66 get_request: function(url, callback) { 67 $.get(url, callback, 'json'); 68 }, 69 wrapLinks: function(string, social_network) { 70 var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; 71 if (social_network === 'google-plus') { 72 string = string.replace(/(@|#)([a-z0-9_]+['])/ig, Utility.wrapGoogleplusTagTemplate); 73 } else { 74 string = string.replace(exp, Utility.wrapLinkTemplate); 75 } 76 return string; 77 }, 78 wrapLinkTemplate: function(string) { 79 return '<a target="_blank" href="' + string + '">' + string + '<\/a>'; 80 }, 81 wrapGoogleplusTagTemplate: function(string) { 82 return '<a target="_blank" href="https://plus.google.com/s/' + string + '" >' + string + '<\/a>'; 83 }, 84 shorten: function(string) { 85 string = $.trim(string); 86 if (string.length > options.length) { 87 return jQuery.trim(string).substring(0, options.length).split(" ").slice(0, -1).join(" ") + "..."; 88 } else { 89 return string; 90 } 91 }, 92 stripHTML: function(string) { 93 if (typeof string === "undefined" || string === null) { 94 return ''; 95 } 96 return string.replace(/(<([^>]+)>)|nbsp;|\s{2,}|/ig, ""); 97 } 98 }; 99 100 function SocialFeedPost(social_network, data) { 101 this.content = data; 102 this.content.social_network = social_network; 103 this.content.attachment = (this.content.attachment === undefined) ? '' : this.content.attachment; 104 this.content.time_ago = data.dt_create.fromNow(); 105 this.content.date = data.dt_create.format(options.date_format); 106 this.content.dt_create = this.content.dt_create.valueOf(); 107 this.content.text = Utility.wrapLinks(Utility.shorten(data.message + ' ' + data.description), data.social_network); 108 this.content.moderation_passed = (options.moderation) ? options.moderation(this.content) : true; 109 110 Feed[social_network].posts.push(this); 111 } 112 SocialFeedPost.prototype = { 113 render: function() { 114 var rendered_html = Feed.template(this.content); 115 var data = this.content; 116 117 if ($(container).children('[social-feed-id=' + data.id + ']').length !== 0) { 118 return false;
119 } 120 if ($(container).children().length === 0) { 121 $(container).append(rendered_html); 122 } else { 123 var i = 0, 124 insert_index = -1; 125 $.each($(container).children(), function() { 126 if ($(this).attr('dt-create') < data.dt_create) { 127 insert_index = i; 128 return false; 129 } 130 i++; 131 }); 132 $(container).append(rendered_html); 133 if (insert_index >= 0) { 134 insert_index++; 135 var before = $(container).children('div:nth-child(' + insert_index + ')'), 136 current = $(container).children('div:last-child'); 137 $(current).insertBefore(before); 138 } 139 140 } 141 if (options.media_min_width) { 142 143 var query = '[social-feed-id=' + data.id + '] img.attachment'; 144 var image = $(query); 145 146 // preload the image 147 var height, width = ''; 148 var img = new Image(); 149 var imgSrc = image.attr("src"); 150 151 $(img).load(function() { 152 153 if (img.width < options.media_min_width) { 154 image.hide(); 155 } 156 // garbage collect img 157 delete img; 158 159 }).error(function() { 160 // image couldnt be loaded 161 image.hide(); 162 163 }).attr({ 164 src: imgSrc 165 }); 166 167 } 168 169 loaded_post_count++; 170 if (loaded_post_count == posts_to_load_count) { 171 fireCallback(); 172 } 173 174 } 175 176 }; 177 178 var Feed = { 179 template: false, 180 init: function() { 181 Feed.getTemplate(function() { 182 social_networks.forEach(function(network) { 183 if (options[network]) { 184 if ( options[network].accounts ) { 185 //loaded[network] = 0; 186 options[network].accounts.forEach(function(account) { 187 //loaded[network]++; 188 Feed[network].getData(account); 189 }); 190 } else if ( options[network].urls ) { 191 options[network].urls.forEach(function(url) { 192 Feed[network].getData(url); 193 }); 194 } else { 195 Feed[network].getData(); 196 } 197 } 198 }); 199 }); 200 }, 201 getTemplate: function(callback) { 202 if (Feed.template) 203 return callback(); 204 else { 205 if (options.template_html) { 206 Feed.template = doT.template(options.template_html); 207 return callback(); 208 } else { 209 $.get(options.template, function(template_html) { 210 Feed.template = doT.template(template_html); 211 return callback(); 212 }); 213 } 214 } 215 }, 216 twitter: { 217 posts: [], 218 loaded: false, 219 api: 'http://api.tweecool.com/', 220 221 getData: function(account) { 222 223 var cb = new Codebird(); 224 cb.setConsumerKey(options.twitter.consumer_key, options.twitter.consumer_secret); 225 226 // Allow setting your own proxy with Codebird 227 if (options.twitter.proxy !== undefined) { 228 cb.setProxy(options.twitter.proxy); 229 } 230 231 switch (account[0]) { 232 case '@': 233 var userid = account.substr(1); 234 cb.__call( 235 "statuses_userTimeline", 236 "id=" + userid + "&count=" + options.twitter.limit, 237 Feed.twitter.utility.getPosts, 238 true // this parameter required 239 ); 240 break; 241 case '#': 242 var hashtag = account.substr(1); 243 cb.__call( 244 "search_tweets", 245 "q=" + hashtag + "&count=" + options.twitter.limit, 246 function(reply) { 247 Feed.twitter.utility.getPosts(reply.statuses); 248 }, 249 true // this parameter required 250 ); 251 break; 252 default: 253 } 254 }, 255 utility: { 256 getPosts: function(json) { 257 if (json) { 258 $.each(json, function() { 259 var element = this; 260 var post = new SocialFeedPost('twitter', Feed.twitter.utility.unifyPostData(element)); 261 post.render(); 262 }); 263 } 264 }, 265 unifyPostData: function(element) { 266 var post = {};
267 if (element.id) { 268 post.id = element.id; 269 //prevent a moment.js console warning due to Twitter's poor date format. 270 post.dt_create = moment(new Date(element.created_at)); 271 post.author_link = 'http://twitter.com/' + element.user.screen_name; 272 post.author_picture = element.user.profile_image_url; 273 post.post_url = post.author_link + '/status/' + element.id_str; 274 post.author_name = element.user.name; 275 post.message = element.text; 276 post.description = ''; 277 post.link = 'http://twitter.com/' + element.user.screen_name + '/status/' + element.id_str; 278 279 if (options.show_media === true) { 280 if (element.entities.media && element.entities.media.length > 0) { 281 var image_url = element.entities.media[0].media_url; 282 if (image_url) { 283 post.attachment = '<img class="attachment" src="' + image_url + '" />'; 284 } 285 } 286 } 287 } 288 return post; 289 } 290 } 291 }, 292 // all facebook request are forwareded to self plugin caching at main.php in the plugin folder. 293 facebook: { 294 posts: [], 295 graph: 'https://graph.facebook.com/', 296 loaded: false, 297 getData: function(account) { 298 var proceed = function(request_url, callbackParam){ 299 Utility.request( 300 options.plugin_folder + "main.php?requestURI="+encodeURIComponent(request_url) + callbackParam, 301 Feed.facebook.utility.getPosts 302 ); 303 }; 304 var fields = '?fields=id,from,name,message,created_time,story,description,link'; 305 fields += (options.show_media === true)?',picture,object_id':''; 306 var request_url, limit = '&limit=' + options.facebook.limit,
307 query_extention = '&access_token=' + options.facebook.access_token, 308 callbackParam = '&callback=?'; 309 switch (account[0]) { 310 case '@': 311 var username = account.substr(1); 312 Feed.facebook.utility.getUserId(username, function(userdata) { 313 if (userdata.id !== '') { 314 request_url = Feed.facebook.graph + 'v2.4/' + userdata.id + '/posts'+ fields + limit + query_extention; 315 proceed(request_url, callbackParam); 316 } 317 }); 318 break; 319 case '!': 320 var page = account.substr(1); 321 request_url = Feed.facebook.graph + 'v2.4/' + page + '/feed'+ fields + limit + query_extention; 322 proceed(request_url, callbackParam); 323 break; 324 default: 325 proceed(request_url, callbackParam); 326 } 327 }, 328 utility: { 329 getUserId: function(username, callback) {
330 var query_extention = '&access_token=' + options.facebook.access_token; 331 var url = encodeURIComponent('https://graph.facebook.com/' + username + '?' + query_extention) + '&callback=?'; 332 var result = ''; 333 $.get(options.plugin_folder + "main.php?requestURI="+url, callback, 'json'); 334 }, 335 prepareAttachment: function(element) { 336 var image_url = element.picture; 337 if (image_url.indexOf('_b.') !== -1) { 338 //do nothing it is already big 339 } else if (image_url.indexOf('safe_image.php') !== -1) { 340 image_url = Feed.facebook.utility.getExternalImageURL(image_url, 'url'); 341 342 } else if (image_url.indexOf('app_full_proxy.php') !== -1) { 343 image_url = Feed.facebook.utility.getExternalImageURL(image_url, 'src'); 344 345 } else if (element.object_id) { 346 image_url = Feed.facebook.graph + element.object_id + '/picture/?type=normal'; 347 } 348 return '<img class="attachment" src="' + image_url + '" />'; 349 }, 350 getExternalImageURL: function(image_url, parameter) { 351 image_url = decodeURIComponent(image_url).split(parameter + '=')[1]; 352 if (image_url.indexOf('fbcdn-sphotos') === -1) { 353 return image_url.split('&')[0]; 354 } else { 355 return image_url; 356 } 357 358 }, 359 getPosts: function(json) { 360 if (json['data']) { 361 json['data'].forEach(function(element) { 362 var post = new SocialFeedPost('facebook', Feed.facebook.utility.unifyPostData(element)); 363 post.render(); 364 }); 365 } 366 }, 367 unifyPostData: function(element) { 368 var post = {}, 369 text = (element.message) ? element.message : element.story; 370 371 post.id = element.id; 372 post.dt_create = moment(element.created_time); 373 post.author_link = 'http://facebook.com/' + element.from.id; 374 post.author_picture = Feed.facebook.graph + element.from.id + '/picture'; 375 post.author_name = element.from.name; 376 post.name = element.name || ""; 377 post.message = (text) ? text : ''; 378 post.description = (element.description) ? element.description : ''; 379 post.link = (element.link) ? element.link : 'http://facebook.com/' + element.from.id; 380 381 if (options.show_media === true) { 382 if (element.picture) { 383 var attachment = Feed.facebook.utility.prepareAttachment(element); 384 if (attachment) { 385 post.attachment = attachment; 386 } 387 } 388 } 389 return post; 390 } 391 } 392 }, 393 google: { 394 posts: [], 395 loaded: false, 396 api: 'https://www.googleapis.com/plus/v1/', 397 getData: function(account) { 398 var request_url; 399 switch (account[0]) { 400 case '#': 401 var hashtag = account.substr(1); 402 request_url = Feed.google.api + 'activities?query=' + hashtag + '&key=' + options.google.access_token + '&maxResults=' + options.google.limit; 403 Utility.get_request(request_url, Feed.google.utility.getPosts); 404 break; 405 case '@': 406 var username = account.substr(1); 407 request_url = Feed.google.api + 'people/' + username + '/activities/public?key=' + options.google.access_token + '&maxResults=' + options.google.limit; 408 Utility.get_request(request_url, Feed.google.utility.getPosts); 409 break; 410 default: 411 } 412 }, 413 utility: { 414 getPosts: function(json) { 415 if (json.items) { 416 $.each(json.items, function(i) { 417 var post = new SocialFeedPost('google', Feed.google.utility.unifyPostData(json.items[i])); 418 post.render(); 419 }); 420 } 421 }, 422 unifyPostData: function(element) { 423 var post = {}; 424
425 post.id = element.id; 426 post.attachment = ''; 427 post.description = ''; 428 post.dt_create = moment(element.published); 429 post.author_link = element.actor.url; 430 post.author_picture = element.actor.image.url; 431 post.author_name = element.actor.displayName; 432 433 if (options.show_media === true) { 434 if (element.object.attachments) { 435 $.each(element.object.attachments, function() { 436 var image = ''; 437 if (this.fullImage) { 438 image = this.fullImage.url; 439 } else { 440 if (this.objectType === 'album') { 441 if (this.thumbnails && this.thumbnails.length > 0) { 442 if (this.thumbnails[0].image) { 443 image = this.thumbnails[0].image.url; 444 } 445 } 446 } 447 } 448 post.attachment = '<img class="attachment" src="' + image
448+ '"/>'; 449 }); 450 } 451 } 452 post.message = element.title; 453 post.link = element.url; 454 455 return post; 456 } 457 } 458 }, 459 instagram: { 460 posts: [], 461 api: 'https://api.instagram.com/v1/', 462 loaded: false, 463 accessType: function() { 464 // If we have both the client_id and access_token set in options, 465 // use access_token for authentication. If client_id is not set 466 // then use access_token. If neither are set, log an error to console. 467 if (typeof options.instagram.access_token === 'undefined' && typeof options.instagram.client_id === 'undefined') { 468 console.log('You need to define a client_id or access_token to authenticate with Instagram\'s API.'); 469 return undefined; 470 } 471 if (options.instagram.access_token) { options.instagram.client_id = undefined; } 472 options.instagram.access_type = (typeof options.instagram.client_id === 'undefined' ? 'access_token' : 'client_id'); 473 return options.instagram.access_type; 474 }, 475 getData: function(account) { 476 var url; 477 478 // API endpoint URL depends on which authentication type we're using. 479 if (this.accessType() !== 'undefined') { 480 var authTokenParams = options.instagram.access_type + '=' + options.instagram[options.instagram.access_type]; 481 } 482 483 switch (account[0]) { 484 case '@': 485 var username = account.substr(1); 486 url = Feed.instagram.api + 'users/search/?q=' + username + '&' + authTokenParams + '&count=1' + '&callback=?'; 487 Utility.request(url, Feed.instagram.utility.getUsers); 488 break; 489 case '#': 490 var hashtag = account.substr(1); 491 url = Feed.instagram.api + 'tags/' + hashtag + '/media/recent/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 492 Utility.request(url, Feed.instagram.utility.getImages); 493 break; 494 case '&': 495 var id = account.substr(1); 496 url = Feed.instagram.api + 'users/' + id + '/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 497 Utility.request(url, Feed.instagram.utility.getUsers); 498 default: 499 } 500 }, 501 utility: { 502 getImages: function(json) { 503 if (json.data) { 504 json.data.forEach(function(element) { 505 var post = new SocialFeedPost('instagram', Feed.instagram.utility.unifyPostData(element)); 506 post.render(); 507 }); 508 } 509 }, 510 getUsers: function(json) { 511 // API endpoint URL depends on which authentication type we're using. 512 if (options.instagram.access_type !== 'undefined') { 513 var authTokenParams = options.instagram.access_type + '=' + options.instagram[options.instagram.access_type]; 514 } 515 516 if (!jQuery.isArray(json.data)) { 517 if (json.data) { 518 json.data = [json.data]; 519 } else { 520 console.log(this.url.match(/(.+\.com)/)[0] + " : ", json.meta); 521 return; 522 } 523 } 524 525 json.data.forEach(function(user) { 526 var url = Feed.instagram.api + 'users/' + user.id + '/media/recent/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 527 Utility.request(url, Feed.instagram.utility.getImages); 528 }); 529 }, 530 unifyPostData: function(element) { 531 var post = {}; 532
533 post.id = element.id; 534 post.dt_create = moment(element.created_time * 1000); 535 post.author_link = 'http://instagram.com/' + element.user.username; 536 post.author_picture = element.user.profile_picture; 537 post.author_name = element.user.full_name || element.user.username; 538 post.message = (element.caption && element.caption) ? element.caption.text : ''; 539 post.description = ''; 540 post.link = element.link; 541 if (options.show_media) { 542 post.attachment = '<img class="attachment" src="' + element.images.standard_resolution.url + '' + '" />'; 543 } 544 return post; 545 } 546 } 547 }, 548 vk: { 549 posts: [], 550 loaded: false, 551 base: 'http://vk.com/', 552 api: 'https://api.vk.com/method/', 553 user_json_template: 'https://api.vk.com/method/' + 'users.get?fields=first_name,%20last_name,%20screen_name,%20photo&uid=', 554 group_json_template: 'https://api.vk.com/method/' + 'groups.getById?fields=first_name,%20last_name,%20screen_name,%20photo&gid=', 555 getData: function(account) { 556 var request_url; 557 558 switch (account[0]) { 559 case '@': 560 var username = account.substr(1); 561 request_url = Feed.vk.api + 'wall.get?owner_id=' + username + '&filter=' + options.vk.source + '&count=' + options.vk.limit + '&callback=?'; 562 Utility.get_request(request_url, Feed.vk.utility.getPosts); 563 break; 564 case '#': 565 var hashtag = account.substr(1); 566 request_url = Feed.vk.api + 'newsfeed.search?q=' + hashtag + '&count=' + options.vk.limit + '&callback=?'; 567 Utility.get_request(request_url, Feed.vk.utility.getPosts); 568 break; 569 default: 570 } 571 }, 572 utility: { 573 getPosts: function(json) { 574 if (json.response) { 575 $.each(json.response, function() { 576 if (this != parseInt(this) && this.post_type === 'post') { 577 var owner_id = (this.owner_id) ? this.owner_id : this.from_id, 578 vk_wall_owner_url = (owner_id > 0) ? (Feed.vk.user_json_template + owner_id + '&callback=?') : (Feed.vk.group_json_template + (-1) * owner_id + '&callback=?'), 579 element = this; 580 Utility.get_request(vk_wall_owner_url, function(wall_owner) { 581 Feed.vk.utility.unifyPostData(wall_owner, element, json); 582 }); 583 } 584 }); 585 } 586 }, 587 unifyPostData: function(wall_owner, element, json) { 588 var post = {}; 589 590 post.id = element.id; 591 post.dt_create = moment.unix(element.date); 592 post.description = ' '; 593 post.message = Utility.stripHTML(element.text); 594 if (options.show_media) { 595 if (element.attachment) { 596 if (element.attachment.type === 'link') 597 post.attachment = '<img class="attachment" src="' + element.attachment.link.image_src + '" />'; 598 if (element.attachment.type === 'video') 599 post.attachment = '<img class="attachment" src="' + element.attachment.video.image_big + '" />'; 600 if (element.attachment.type === 'photo') 601 post.attachment = '<img class="attachment" src="' + element.attachment.photo.src_big + '" />'; 602 } 603 } 604 605 if (element.from_id > 0) { 606 var vk_user_json = Feed.vk.user_json_template + element.from_id + '&callback=?'; 607 Utility.get_request(vk_user_json, function(user_json) { 608 var vk_post = new SocialFeedPost('vk', Feed.vk.utility.getUser(user_json, post, element, json)); 609 vk_post.render(); 610 }); 611 612 } else { 613 var vk_group_json = Feed.vk.group_json_template + (-1) * element.from_id + '&callback=?'; 614 Utility.get_request(vk_group_json, function(user_json) { 615 var vk_post = new SocialFeedPost('vk', Feed.vk.utility.getGroup(user_json, post, element, json)); 616 vk_post.render(); 617 }); 618 } 619 }, 620 getUser: function(user_json, post, element, json) { 621 post.author_name = user_json.response[0].first_name + ' ' + user_json.response[0].last_name; 622 post.author_picture = user_json.response[0].photo; 623 post.author_link = Feed.vk.base + user_json.response[0].screen_name; 624 post.link = Feed.vk.base + user_json.response[0].screen_name + '?w=wall' + element.from_id + '_' + element.i
624d; 625 626 return post; 627 }, 628 getGroup: function(user_json, post, element, json) { 629 post.author_name = user_json.response[0].name; 630 post.author_picture = user_json.response[0].photo; 631 post.author_link = Feed.vk.base + user_json.response[0].screen_name; 632 post.link = Feed.vk.base + user_json.response[0].screen_name + '?w=wall-' + user_json.response[0].gid + '_' + element.id; 633 634 return post; 635 } 636 } 637 }, 638 blogspot: { 639 loaded: false, 640 getData: function(account) { 641 var url; 642 643 switch (account[0]) { 644 case '@': 645 var username = account.substr(1); 646 url = 'http://' + username + '.blogspot.com/feeds/posts/default?alt=json-in-script&callback=?'; 647 request(url, getPosts); 648 break; 649 default: 650 } 651 }, 652 utility: { 653 getPosts: function(json) { 654 $.each(json.feed.entry, function() { 655 var post = {}, 656 element = this; 657 post.id = element.id['$t'].replace(/[^a-z0-9]/gi, ''); 658 post.dt_create = moment((element.published['$t'])); 659 post.author_link = element.author[0]['uri']['$t']; 660 post.author_picture = 'http:' + element.author[0]['gd$image']['src']; 661 post.author_name = element.author[0]['name']['$t']; 662 post.message = element.title['$t'] + '</br></br>' + stripHTML(element.content['$t']); 663 post.description = ''; 664 post.link = element.link.pop().href; 665 666 if (options.show_media) { 667 if (element['media$thumbnail']) { 668 post.attachment = '<img class="attachment" src="' + element['media$thumbnail']['url'] + '" />'; 669 } 670 } 671 672 post.render(); 673 674 }); 675 } 676 } 677 }, 678 pinterest: { 679 posts: [], 680 loaded: false, 681 apiv1: 'https://api.pinterest.com/v1/', 682 683 getData: function(account) { 684 var request_url, 685 limit = 'limit=' + options.pinterest.limit, 686 fields = 'fields=id,created_at,link,note,creator(url,first_name,last_name,image),image', 687 query_extention = fields + '&access_token='
687+ options.pinterest.access_token + '&' + limit + '&callback=?'; 688 switch (account[0]) { 689 case '@': 690 var username = account.substr(1); 691 if (username === 'me') { 692 request_url = Feed.pinterest.apiv1 + 'me/pins/?' + query_extention; 693 } else { 694 request_url = Feed.pinterest.apiv1 + 'boards/' + username + '/pins?' + query_extention; 695 } 696 break; 697 default: 698 } 699 Utility.request(request_url, Feed.pinterest.utility.getPosts); 700 }, 701 utility: { 702 703 getPosts: function(json) { 704 json.data.forEach(function(element) { 705 var post = new SocialFeedPost('pinterest', Feed.pinterest.utility.unifyPostData(element)); 706 post.render(); 707 }); 708 }, 709 710 unifyPostData: function(element){ 711 var post = {}; 712 713 post.id = element.id; 714 post.dt_create= moment(element.created_at); 715 post.author_link = element.creator.url; 716 post.author_picture = element.creator.image['60x60' ].url; 717 post.author_name = element.creator.first_name + element.creator.last_name; 718 post.message = element.note; 719 post.description = ''; 720 post.social_network = 'pinterest'; 721 post.link = element.link ? element.link : 'https://www.pinterest.com/pin/' + element.id; 722 if (options.show_media) { 723 post.attachment = '<img class="attachment" src="' + element.image['original'].url + '" />'; 724 } 725 return post; 726 } 727 } 728 }, 729 rss : { 730 posts: [], 731 loaded: false, 732 api : 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0', 733 734 getData: function(url) { 735 var limit = '&num='+ options.rss.limit, 736 request_url = Feed.rss.api + limit + '&q=' + encodeURIComponent(url); 737 738 Utility.request(request_url, Feed.rss.utility.getPosts); 739 }, 740 utility: { 741 742 getPosts: function(json) { 743 $.each(json.responseData.feed.entries, function(index, element) { 744 var post = new SocialFeedPost('rss', Feed.rss.utility.unifyPostData(index, element)); 745 post.render(); 746 }); 747 }, 748 749 unifyPostData: function(index, element){ 750 var post = {}; 751 752 post.id = index; 753 post.dt_create= moment(element.publishedDate, 'ddd, DD MMM YYYY HH:mm:ss ZZ', 'en'); 754 post.author_link = ''; 755 post.author_picture = ''; 756 post.author_name = element.author; 757 post.message = Utility.stripHTML(element.title); 758 post.description = Utility.stripHTML(element.content); 759 post.social_network = 'rss'; 760 post.link = element.link; 761 if (options.show_media && element.mediaGroups ) { 762 post.attachment = '<img class="attachment" src="' + element.mediaGroups[0].contents[0].url + '" />'; 763 } 764 return post; 765 } 766 } 767 } 768 }; 769 770 //make the plugin chainable 771 return this.each(function() { 772 // Initialization 773 Feed.init(); 774 if (options.update_period) { 775 setInterval(function() { 776 return Feed.init(); 777 }, options.update_period); 778 } 779 }) 780 }; 781 782})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.