PageSourceSearch

https://cn.mnchip.com/wp-content/plugins/essential-addons-elemento…/social-feeds/jquery.socialfeed.js?ver=1.0

js mnchip.com collected 2026-10-04 11:05:20 UTC 40,761 bytes, 803 lines download raw bytes

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