PageSourceSearch

https://corpmedia.ru/js/socialstream.jquery.js

js corpmedia.ru collected 2026-10-01 08:57:40 UTC 19,971 bytes, 392 lines download raw bytes

1/* 
2 * Widgets for Social Network photo stream.
3 * 
4 * Author: Pixel Industry
5 * Website: http://pixel-industry.com
6 * Version: 1.4
7 *
8 */
9
10
11(function ($) {
12    $.fn.socialstream = function (options) {
13        var defaults = {
14            socialnetwork: 'flickr',
15            username: 'pixel-industry',
16            limit: 6,
17            overlay: true,
18            apikey: false,
19            accessToken: '',
20            picasaAlbumId: ''
21        };
22        var options = $.extend(defaults, options);
23
24        return this.each(function () {
25            var object = $(this);
26            switch (options.socialnetwork) {
27
28                case 'flickr':
29                    object.append("<ul class=\"flickr-list\"></ul>")
30                    $.getJSON("https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&username=" + options.username + "&format=json&api_key=32ff8e5ef78ef2f44e6a1be3dbcf0617&jsoncallback=?", function (data) {
31                        var user_id = data.user.nsid;
32                        $.getJSON("https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=" + user_id + "&format=json&api_key=85145f20ba1864d8ff559a3971a0a033&per_page=" + options.limit + "&page=1&extras=url_sq&jsoncallback=?", function (data) {
33                            $.each(data.photos.photo, function (num, photo) {
34                                var photo_author = photo.owner;
35                                var photo_title = photo.title;
36                                var photo_src = photo.url_sq;
37                                var photo_id = photo.id;
38                                var photo_url = "https://www.flickr.com/photos/" + photo_author + "/" + photo_id;
39                                var photo_container = $('<img/>').attr({
40                                    src: photo_src,
41                                    alt: photo_title
42                                });
43                                var url_container = $('<a/>').attr({
44                                    href: photo_url,
45                                    target: '_blank',
46                                    title: photo_title
47                                });
48
49                                var tmp = $(url_container).append(photo_container);
50                                if (options.overlay) {
51                                    var overlay_div = $('<div/>').addClass('img-overlay');
52                                    $(url_container).append(overlay_div);
53                                }
54                                var li = $('<li/>').append(tmp);
55                                $("ul", object).append(li);
56                            })
57                        });
58                    });
59                    break;
60                case 'pinterest':
61                    var url = 'http://pinterest.com/' + options.username + '/feed.rss'
62                    var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url) + "&num=" + options.limit + "&output=json_xml";
63
64                    // Send request
65                    $.getJSON(api, function (data) {
66                        if (data.responseStatus == 200) {
67                            var photofeed = data.responseData.feed;
68                            var overlay_div = "";
69                            if (!photofeed) {
70                                return false;
71                            }
72                            var html_code = '<ul class=\"pinterest-list\">';
73
74                            for (var i = 0; i < photofeed.entries.length; i++) {
75                                var entry = photofeed.entries[i];
76                                var $container = $("<div></div>");
77                                $container.append(entry.content);
78                                var url = "http://www.pinterest.com" + $container.find('a').attr('href');
79                                var photo_url = $container.find('img').attr('src');
80                                var photo_title = $container.find('p:nth-child(2)').html();
81                                if (options.overlay) {
82                                    var overlay_div = '<div class="img-overlay"></div>';
83                                }
84
85                                html_code += '<li><a target="_blank" href="' + url + '" title="' + photo_title + '"><img src="' + photo_url + '"/>' + overlay_div + '</a></li>'
86                            }
87                            html_code += '</ul>';
88
89                            $(object).append(html_code);
90
91                        }
92                    });
93                    break;
94                case 'instagram':
95                    object.append("<ul class=\"instagram-list\"></ul>")
96
97                    // check if access token is set
98                    if ((typeof (options.accessToken) != "undefined") && options.accessToken != "") {
99                        var access_token = options.accessToken;
100                    } else {
101                        console.warn("Instagram Access Token is not set. Please enter it in plugin init call.");
102                        return;
103                    }
104
105                    url = "https://api.instagram.com/v1/users/search?q=" + options.username + "&access_token=" + access_token + "&count=1&callback=?";
106                    $.getJSON(url, function (data) {
107
108                        $.each(data.data, function (i, shot) {
109                            var instagram_username = shot.username;
110                            if (instagram_username == options.username) {
111                                var user_id = shot.id;
112
113                                if (user_id != "") {
114                                    url = "https://api.instagram.com/v1/users/" + user_id + "/media/recent/?access_token=" + access_token + "&count=" + options.limit + "&callback=?";
115                                    $.getJSON(url, function (data) {
116                                        $.each(data.data, function (i, shot) {
117                                            var photo_src = shot.images.thumbnail.url;
118                                            var photo_url = shot.link;
119
120                                            var photo_title = "";
121                                            if (shot.caption != null) {
122                                                photo_title = shot.caption.text;
123                                            }
124
125                                            var photo_container = $('<img/>').attr({
126                                                src: photo_src,
127                                                alt: photo_title
128                                            });
129                                            var url_container = $('<a/>').attr({
130                                                href: photo_url,
131                                                target: '_blank',
132                                                title: photo_title
133                                            });
134                                            var tmp = $(url_container).append(photo_container);
135                                            if (options.overlay) {
136                                                var overlay_div = $('<
136div/>').addClass('img-overlay');
137                                                $(url_container).append(overlay_div);
138                                            }
139                                            var li = $('<li/>').append(tmp);
140                                            $("ul", object).append(li);
141
142                                        });
143                                    });
144                                }
145                            }
146                        });
147                    });
148                    break;
149                case 'dribbble':
150                    object.append("<ul class=\"dribbble-list\"></ul>")
151
152                    // check if access token is set
153                    if ((typeof (options.accessToken) != "undefined") && options.accessToken != "") {
154                        var access_token = options.accessToken;
155                    } else {
156                        console.warn("Dribbble Access Token is not set. Please enter it in plugin init call.");
157                        return;
158                    }
159
160                    $.getJSON("https://api.dribbble.com/v1/users/" + options.username + "/shots?access_token=" + access_token + "&callback=?", function (data) {
161                        $.each(data.data, function (num, shot) {
162                            if (num < options.limit) {
163                                var photo_title = shot.title;
164                                var photo_container = $('<img/>').attr({
165                                    src: shot.images.teaser,
166                                    alt: photo_title
167                                });
168                                var url_container = $('<a/>').attr({
169                                    href: shot.html_url,
170                                    target: '_blank',
171                                    title: photo_title
172                                });
173                                var tmp = $(url_container).append(photo_container);
174                                if (options.overlay) {
175                                    var overlay_div = $('<div/>').addClass('img-overlay');
176                                    $(url_container).append(overlay_div);
177                                }
178                                var li = $('<li/>').append(tmp);
179                                $("ul", object).append(li);
180                            }
181                        });
182
183                    });
184                    break;
185                case 'deviantart':
186                    var url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=by%3A' + options.username + '+sort%3Atime+meta%3Aall';
187                    var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url) + "&num=" + options.limit + "&output=json_xml";
188
189                    $.getJSON(api, function (data) {
190                        if (data.responseStatus == 200) {
191                            var photofeed = data.responseData.feed;
192                            var overlay_div = "";
193                            if (!photofeed) {
194                                return false;
195
196                            }
197                            var html_code = '<ul class=\"deviantart-list\">';
198
199                            for (var i = 0; i < photofeed.entries.length; i++) {
200                                var entry = photofeed.entries[i];
201                                var $container = $("<div></div>");
202                                $container.append(entry.content);
203                                var url = entry.link;
204                                var photo_url = $container.find('img').attr('src');
205
206                                // ignore smiley images
207                                if (photo_url.indexOf("smile.gif") >= 0) {
208                                    continue;
209                                }
210
211                                var photo_title = entry.title.replace(/.jpg/g, "").replace(/-/g, " ").replace(/_/g, " ");
212                                if (options.overlay) {
213                                    var overlay_div = '<div class="img-overlay"></div>';
214                                }
215
216                                html_code += '<li><a target="_blank" href="' + url + '" title="' + photo_title + '"><img src="' + photo_url + '"/>' + overlay_div + '</a></li>'
217                            }
218                            html_code += '</ul>';
219
220                            $(object).append(html_code);
221
222                        }
223                    });
224
225                    break;
226                case 'picasa':
227                    var url = 'https://picasaweb.google.com/data/feed/base/user/' + options.username + '/album/' + options.picasaAlbumId + '?kind=photo&access=public&alt=json-in-script&imgmax=' + options.limit + '&callback=?';
228
229                    $.getJSON(url, function (data) {
230                        if (data.feed.entry.length > 0) {
231
232                            var photofeed = data.feed.entry;
233                            var overlay_div = "";
234
235                            var html_code = '<ul class=\"picasa-list\">';
236
237                            $.each(photofeed, function (i, pic) {
238                                var thumb = pic.media$group.media$thumbnail[2].url;
239                                var desc = pic.media$group.media$description.$t;
240                                var title = pic.media$group.media$title.$t;
241
242                                var url = pic.link[1].href;
243                                var photo_title = title.replace(/.jpg/g, "").replace(/.JPG/g, "").replace(/-/g, " ").replace(/_/g, " ");
244                                if (options.overlay) {
245                                    var overlay_div = '<div class="img-overlay"></div>';
246                                }
247
248                                html_code += '<li><a target="_blank" href="' + url + '" title="' + photo_title + '"><img src="' + thumb + '"/>' + overlay_div + '</a></li>'
249                            });
250
251                            for (var i = 0; i < photofeed; i++) {
252                                var entry = photofeed[i];
253                                var $container = $("<div></div>");
254                                $container.append(entry.content);
255                                var url = entry.link;
256                                var photo_url = $container.find('img').attr('src');
257                                var photo_title = entry.title.replace(/.jpg/g, "").replace(/-/g, " ").replace(/_/g, " ");
258                                if (options.overlay) {
259                                    var overlay_div = '<div class="img-overlay"></div>';
260                                }
261
262                                html_code += '<li><a target="_blank" href="' + url + '" title="' + photo_title + '"><img src="' + photo_url + '"/>' + overlay_div + '</a></li>'
263                            }
264                            html_code += '</ul>';
265
266                            $(object).append(html_code);
267                        }
268                    });
269                    break;
270                case 'youtube':
271                    var pid;
272                    if (options.apikey) {
273
274                        $(object).append('<div class="loading"></div>');
275                        // Get Uploads Playlist
276                        $.get(
277                                "https://www.googleapis.com/youtube/v3/ch
277annels", {
278                                    part: 'contentDetails',
279                                    id: options.username,
280                                    key: options.apikey
281                                },
282                        function (data) {
283
284                            $.each(data.items, function (i, item) {
285                                //playlist id
286                                pid = item.contentDetails.relatedPlaylists.uploads;
287                                youtubeGetVids(pid);
288                            });
289
290                        }
291                        );
292
293                    }
294
295                    //Get Videos
296                    function youtubeGetVids(pid) {
297                        $.get(
298                                "https://www.googleapis.com/youtube/v3/playlistItems", {
299                                    part: 'snippet',
300                                    maxResults: options.limit,
301                                    playlistId: pid,
302                                    key: options.apikey
303                                },
304                        function (data) {
305                            var results;
306
307                            var html_code = '<ul class=\"youtube-list\">';
308
309                            // loop through videos
310                            $.each(data.items, function (i, item) {
311
312                                //var photofeed = item.snippet.thumbnails.default.url;
313                                var photofeed = item.snippet.thumbnails.high.url;
314                                //'?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=Lmqp3EyHkaL5aVXnAJrH6uiJ4ig';
315                                var overlay_div = "";
316                                if (!photofeed) {
317                                    return false;
318                                }
319
320                                // create container
321                                var $container = $("<div></div>");
322
323                                // get image url
324                                var url = 'https://www.youtube.com/watch?v=' + item.snippet.resourceId.videoId;
325
326                                // video title
327                                var photo_title = item.snippet.title;
328                                if (options.overlay) {
329                                    var overlay_div = '<div class="img-overlay"></div>';
330                                }
331
332                                // create html
333                                html_code += '<li class="item_'+i+' '+(i%2?'even':'odd')+'"><a href="' + url + '" title="' + photo_title + '"><img src="' + photofeed + '"/>' + overlay_div + '</a></li>'; // target="_blank"
334
335                            });
336
337                            html_code += '</ul>';
338
339                            // append html
340                            $(object).children('.loading').remove();
341                            $(object).append(html_code);
342                            // fancyBox
343                            if($.fancybox!==undefined && GData.fancybox!==undefined) {
344	                            if(GData.fancybox.video!==undefined) {
345		                            //console.log($(object).find('a'));
346		                            $(object).find('a').fancybox(GData.fancybox.video);
347								}
348                            }
349                        }
350                        );
351                    }
352
353
354
355
356                    break;
357
358                case 'newsfeed':
359                    var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(options.username) + "&num=" + options.limit + "&output=json_xml";
360
361                    $.getJSON(api, function (data) {
362                        if (data.responseStatus == 200) {
363                            var photofeed = data.responseData.feed;
364                            var overlay_div = "";
365                            if (!photofeed) {
366                                return false;
367                            }
368                            var html_code = '<ul class=\"social-feed\">';
369
370                            for (var i = 0; i < photofeed.entries.length; i++) {
371                                var entry = photofeed.entries[i];
372                                var $container = $("<div></div>");
373                                $container.append(entry.content);
374                                var url = entry.link;
375                                var photo_url = $container.find('img').attr('src');
376                                var photo_title = entry.title.replace(/.jpg/g, "").replace(/-/g, " ").replace(/_/g, " ");
377                                if (options.overlay) {
378                                    var overlay_div = '<div class="img-overlay"></div>';
379                                }
380
381                                html_code += '<li><a target="_blank" href="' + url + '" title="' + photo_title + '"><img src="' + photo_url + '"/>' + overlay_div + '</a></li>'
382                            }
383                            html_code += '</ul>';
384
385                            $(object).append(html_code);
386                        }
387                    });
388                    break;
389            }
390        });
391    };
392})(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.