1/* 2Flickr API key: http://www.flickr.com/services/apps/create/noncommercial/ 3*/ 4var flickr_api_key = "40877bb0e10edad168a2ccee1f176fb7"; 5/* 6Instagam token: http://www.brankic1979.com/instagram/ 7*/ 8var instagram_token = "338517687.1912c81.b47c05c499c1401d90d7afcfc2bb7def"; 9 10(function($){ 11 $.fn.extend({ 12 bra_photostream: function(options) { 13 14 var defaults = { 15 user: 'brankic1979', 16 limit: 10, 17 social_network: 'dribbble', 18 api_token: '' 19 20 }; 21 22 23 function create_html(data, container) { 24 var feeds = data.feed; 25 if (!feeds) { 26 return false; 27 } 28 var html = ''; 29 html += '<ul>'; 30 31 for (var i = 0; i < feeds.entries.length; i++) { 32 var entry = feeds.entries[i]; 33 var content = entry.content; 34 html += '<li>'+ content +'</li>' 35 } 36 37 html += '</ul>'; 38 39 $(container).html(html); 40 41 $(container).find("li").each(function(){ 42 pin_img_src = $(this).find("img").attr("src"); 43 pin_url = "http://www.pinterest.com" + $(this).find("a").attr("href"); 44 pin_desc = $(this).find("p:nth-child(2)").html(); 45 pin_desc = pin_desc.replace("'", "`"); 46 $(this).empty(); 47 $(this).append("<a target='_blank' href='" + pin_url + "' title='" + pin_desc + "'><img src='" + pin_img_src + "' alt=''></a>"); 48 var img_w = $(this).find("img").width(); 49 var img_h = $(this).find("img").height(); 50 if (img_w < img_h){ 51 $(this).find("img").addClass("portrait") 52 } 53 else { 54 $(this).find("img").addClass("landscape") 55 } 56 }); 57 }; 58 59 var options = $.extend(defaults, options); 60 61 return this.each(function() { 62 var o = options; 63 var obj = $(this); 64 65 if (o.social_network == "dribbble") { 66 obj.append("<ul></ul>") 67 $.getJSON("http://dribbble.com/" + o.user + "/shots.json?callback=?", function(data){ 68 $.each(data.shots, function(i,shot){ 69 if (i < o.limit) { 70 var img_title = shot.title; 71 img_title = img_title.replace("'", "`") 72 var image = $('<img/>').attr({src: shot.image_teaser_url, alt: img_title}); 73 var url = $('<a/>').attr({href: shot.url, target: '_blank', title: img_title}); 74 var url2 = $(url).append(image); 75 var li = $('<li/>').append(url2); 76 $("ul", obj).append(li); 77 } 78 }); 79 $("li img", obj).each(function(){ 80 var img_w = $(this).width(); 81 var img_h = $(this).height(); 82 if (img_w < img_h){ 83 $(this).addClass("portrait") 84 } 85 else { 86 $(this).addClass("landscape") 87 } 88 }); 89 }); 90 } 91 if (o.social_network == "pinterest") { 92 var url = 'http://pinterest.com/' + o.user + '/feed.rss' 93 var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url); 94 api += "&num=" + o.limit; 95 api += "&output=json_xml" 96 97 //alert(api); 98 99 // Send request 100 $.getJSON(api, function(data){ 101 // Check for error 102 if (data.responseStatus == 200) { 103 // Process the feeds 104 create_html(data.responseData, obj); 105 106 // Optional user callback function 107 if ($.isFunction(fn)) fn.call(this,$e); 108 109 } else { 110 alert("wrong user for pinterest"); 111 112 }; 113 }); 114 } 115 if (o.social_network == "flickr") { 116 117 if (o.api_token == "") o.api_token = flickr_api_key; 118 obj.append("<ul></ul>") 119 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&username=" + o.user + "&format=json&api_key=" + o.api_token + "&jsoncallback=?", function(data){ 120 var flickr_status = data.stat; 121 if (flickr_status == "ok") { 122 var nsid = data.user.nsid; 123 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=" + nsid + "&format=json&api_key=" + o.api_token + "&per_page=" + o.limit + "&page=1&extras=url_sq&jsoncallback=?", function(data){ 124 $.each(data.photos.photo, function(i,img){
125 var img_owner = img.owner; 126 var img_title = img.title; 127 var img_src = img.url_sq; 128 var img_id = img.id; 129 var img_url = "http://www.flickr.com/photos/" + img_owner + "/" + img_id; 130 var image = $('<img/>').attr({src: img_src, alt: img_title}); 131 var url = $('<a/>').attr({href: img_url, target: '_blank', title: img_title}); 132 var url2 = $(url).append(image); 133 var li = $('<li/>').append(url2); 134 $("ul", obj).append(li); 135 }) 136 }) 137 } 138 139 140 if (flickr_status == "fail") { 141 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.people.findByEmail&find_email=" + o.user+ "&format=json&api_key=" + o.api_token + "&jsoncallback=?", function(data){ 142 var nsid = data.user.nsid; 143 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=" + nsid + "&format=json&api_key=" + o.api_token + "&per_page=" + o.limit + "&page=1&extras=url_sq&jsoncallback=?", function(data){ 144 $.each(data.photos.photo, function(i,img){ 145 var img_owner = img.owner; 146 var img_title = img.title; 147 var img_src = img.url_sq; 148 var img_id = img.id; 149 var img_url = "http://www.flickr.com/photos/" + img_owner + "/" + img_id; 150 var image = $('<img/>').attr({src: img_src, alt: img_title}); 151 var url = $('<a/>').attr({href: img_url, target: '_blank', title: img_title}); 152 var url2 = $(url).append(image); 153 var li = $('<li/>').append(url2); 154 $("ul", obj).append(li); 155 }) 156 }) 157 }) 158 159 } 160 161 ; 162 163 164 }); 165 166 167 168 169 170 } 171 172 if (o.social_network == "instagram") { 173 if (o.api_token == "") o.api_token = instagram_token; 174 obj.append("<ul></ul>") 175 url = "https://api.instagram.com/v1/users/search?q=" + o.user + "&access_token=" + o.api_token + "&count=10&callback=?"; 176 $.getJSON(url, function(data){ 177 $.each(data.data, function(i,shot){ 178 var instagram_username = shot.username; 179 180 if (instagram_username == o.user){ 181 182 var user_id = shot.id; 183 184 if (user_id != ""){ 185 url = "https://api.instagram.com/v1/users/" + user_id + "/media/recent/?access_token=" + o.api_token + "&count=" + o.limit + "&callback=?"; 186 $.getJSON(url, function(data){ 187 188 $.each(data.data, function(i,shot){ 189 190 var img_src = shot.images.thumbnail.url; 191 192 var img_url = shot.link; 193 var img_title = ""; 194 if (shot.caption != null){ 195 img_title = shot.caption.text; 196 } 197 var image = $('<img/>').attr({src: img_src, alt: img_title}); 198 var url = $('<a/>').attr({href: img_url, target: '_blank', title: img_title}); 199 var url2 = $(url).append(image); 200 var li = $('<li/>').append(url2); 201 $("ul", obj).append(li); 202 203 }); 204 }); 205 } 206 } 207 }); 208 }); 209 210 211 212 213 214 215 } 216 217 218 }); // return this.each 219 } 220 }); 221})(jQuery); 222////////////////////////////////////////////////////////////////////////////////////////////////////// 223/////////////////////////////////////////////////////////////////////////////////////////////////////// 224////////////////////////////////////////////////////////////////////////////////////////////////////// 225(function($){ 226 $.fn.extend({ 227 bra_photostream_large: function(options) { 228 229 var defaults = { 230 user: 'brankic1979', 231 limit: 12, 232 social_network: 'dribbble', 233 columns: 4, // 4, 3, 2 columns 234 shape: 'none', 235 api_token: '' 236 237 }; 238 239 240 function create_html(data, container, columns, shape) { 241 var feeds = data.feed; 242 if (!feeds) { 243 return false; 244 } 245 var html = ''; 246 247 if (shape == "none") {
248 html += '<div class="portfolio-grid"><ul id="thumbs">' 249 } else { 250 html += '<div class="portfolio-grid"><ul id="thumbs" class="shaped ' + shape + '">' 251 } 252 253 for (var i = 0; i < feeds.entries.length; i++) { 254 var entry = feeds.entries[i]; 255 var content = entry.content; 256 if (shape == "none") { 257 html += '<li class="item col' + columns + '">'+ content +'</li>' 258 } else { 259 html += '<li class="item">'+ content +'</li>' 260 } 261 262 } 263 264 html += '</ul></div>'; 265 container.removeClass("photostream"); 266 container.html(html); 267 268 container.find("li").each(function(){ 269 pin_img_src = $(this).find("img").attr("src"); 270 pin_img_src = pin_img_src.replace("_b.jpg", "_c.jpg") 271 pin_url = "http://www.pinterest.com" + $(this).find("a").attr("href"); 272 pin_desc = $(this).find("p:nth-child(2)").html(); 273 274 pin_desc = pin_desc.replace("'", "`"); 275 $(this).empty(); 276 if (shape == "none") { 277 $(this).append("<img src='" + pin_img_src + "' alt=''><div class='item-info col" + columns + "'><h3 class='title'><a target='_blank' href='" + pin_url + "' title='" + pin_desc + "'>"+ pin_desc + "</a></h3></div>"); 278 $(this).append('<div class="item-info-overlay"><div><a href="' + pin_url + '" class="view">details</a><a href="' + pin_img_src + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'); 279 } else { 280 $(this).append("<div class='item-container'><img src='" + pin_img_src + "' alt='' style='width:100%; height:auto'></div>"); 281 $(this).append('<div class="item-info-overlay"><div><h3 class="title"><a target="_blank" href="' + pin_url + '" title="' + pin_desc + '">'+ pin_desc + '</a></h3><a href="' + pin_url + '" class="view">details</a><a href="' + pin_img_src + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'); 282 } 283 284 }); 285 }; 286 287 var options = $.extend(defaults, options); 288 289 return this.each(function() { 290 var o = options; 291 var obj = $(this); 292 293 if (o.social_network == "dribbble") { 294 html = ""; 295 if (o.shape == "none") { 296 html += '<div class="portfolio-grid"><ul id="thumbs">' 297 } else { 298 html += '<div class="portfolio-grid"><ul id="thumbs" class="shaped ' + o.shape + '">' 299 } 300 301 $.getJSON("http://dribbble.com/" + o.user + "/shots.json?callback=?", function(data){ 302 $.each(data.shots, function(i,shot){ 303 304 if (i < o.limit) { 305 306 if (o.shape == "none") { 307 html += '<li class="item col' + o.columns + '">'; 308 } else { 309 html += '<li class="item">'; 310 } 311 var img_title = shot.title; 312 img_title = img_title.replace("'", "`") 313 314 if (o.shape == "none") { 315 html += "<img width='100%' src='" + shot.image_url + "' alt=''><div class='item-info col" + o.columns + "'><h3 class='title'><a target='_blank' href='" + shot.url + "' title='" + img_title + "'>"+ img_title + "</a></h3></div>"; 316 html += '<div class="item-info-overlay"><div><a href="' + shot.url + '" class="view">details</a><a title="' + img_title + '" href="' + shot.image_url + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 317 } else { 318 html += "<div class='item-container'><img src='" + shot.image_url + "' alt='' style=''></div>"; 319 html += '<div class="item-info-overlay"><div><h3 class="title"><a target="_blank" href="' + shot.url + '" title="' + img_title + '">'+ img_title + '</a></h3><a href="' + shot.url + '" class="view">details</a><a title="' + img_title + '" href="' + shot.image_url + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 320 } 321 html += "</li>"; 322 323 } 324 }); 325 326 html += "</ul></div>"; 327 328 obj.append(html); 329 obj.removeClass("photostream"); 330 $("li img", obj).each(function(){ 331 var img_w = $(this).width(); 332 var img_h = $(this).height(); 333 if (img_w < img_h){ 334 $(this).addClass("portrait") 335 } 336 else { 337 $(this).addClass("landscape") 338 } 339 }); 340 }); 341 } 342 if (o.social_network == "pinterest") { 343 var url = 'http://pinterest.com/' + o.user + '/feed.rss' 344 var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url); 345 api += "&num=" + o.limit; 346 api += "&output=json_xml" 347 348 //alert(api); 349 350 // Send request 351 $.getJSON(api, function(data){ 352 // Check for error 353 if (data.responseStatus == 200) { 354 // Process the feeds 355 create_html(data.responseData, obj, o.columns, o.shape); 356 357 // Optional user callback function
358 if ($.isFunction(fn)) fn.call(this,$e); 359 360 } else { 361 alert("wrong user for pinterest"); 362 363 }; 364 }); 365 } 366 if (o.social_network == "flickr") { 367 if (o.api_token == "") o.api_token = flickr_api_key; 368 html = ""; 369 if (o.shape == "none") { 370 html += '<div class="portfolio-grid"><ul id="thumbs">' 371 } else { 372 html += '<div class="portfolio-grid"><ul id="thumbs" class="shaped ' + o.shape + '">' 373 } 374 375 376 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&username=" + o.user + "&format=json&api_key=" + o.api_token + "&jsoncallback=?", function(data){ 377 var flickr_status = data.stat; 378 if (flickr_status == "ok") { 379 var nsid = data.user.nsid; 380 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=" + nsid + "&format=json&api_key=" + o.api_token + "&per_page=" + o.limit + "&page=1&extras=url_z,url_o,url_m&jsoncallback=?", function(data){ 381 $.each(data.photos.photo, function(i,img){ 382 var img_owner = img.owner; 383 var img_title = img.title; 384 var img_src = img.url_z; 385 var img_src_o = img.url_o; 386 var img_src_m = img.url_m; 387 388 if (img_src_o == undefined) img_src_o = img_src_m; 389 var img_id = img.id; 390 var img_url = "http://www.flickr.com/photos/" + img_owner + "/" + img_id; 391 if (img_src == undefined) img_src = img_src_o; 392 //if (img_src == undefined) img_src = img_src_b; 393 if (o.shape == "none") { 394 html += '<li class="item col' + o.columns + '">'; 395 } else { 396 html += '<li class="item">'; 397 } 398 //alert(img_title) 399 400 if (o.shape == "none") { 401 html += "<img width='100%' src='" + img_src + "' alt=''><div class='item-info col" + o.columns + "'><h3 class='title'><a target='_blank' href='" + img_url + "' title='" + img_title + "'>"+ img_title + "</a></h3></div>"; 402 html += '<div class="item-info-overlay"><div><a href="' + img_url + '" class="view">details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 403 } else { 404 html += "<div class='item-container'><img src='" + img_src + "' alt='' style='height:auto'></div>"; 405 html += '<div class="item-info-overlay"><div><h3 class="title"><a target="_blank" href="' + img_url + '" title="' + img_title + '">'+ img_title + '</a></h3><a href="' + img_url + '" class="view">details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 406 } 407 html += "</li>"; 408 //alert(html) 409 }) 410 html += "</ul></div>"; 411 obj.append(html); 412 obj.removeClass("photostream"); 413 }) 414 415 } 416 417 418 if (flickr_status == "fail") { 419 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.people.findByEmail&find_email=" + o.user+ "&format=json&api_key=" + o.api_token + "&jsoncallback=?", function(data){ 420 var nsid = data.user.nsid; 421 $.getJSON("https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=" + nsid + "&format=json&api_key=" + o.api_token + "&per_page=" + o.limit + "&page=1&extras=url_z,url_o,url_m&jsoncallback=?", function(data){ 422 $.each(data.photos.photo, function(i,img){ 423 var img_owner = img.owner; 424 var img_title = img.title; 425 var img_src = img.url_z; 426 var img_src_o = img.url_o; 427 var img_src_m = img.url_m; 428 if (img_src_o == undefined) img_src_o = img_src_m; 429 var img_id = img.id; 430 var img_url = "http://www.flickr.com/photos/" + img_owner + "/" + img_id; 431 if (img_src == undefined) img_src = img_src_o; 432 //if (img_src == undefined) img_src = img_src_b; 433 if (o.shape == "none") { 434 html += '<li class="item col' + o.columns + '">'; 435 } else { 436 html += '<li class="item">'; 437 } 438 439 if (o.shape == "none") { 440 html += "<img width='100%' src='" + img_src + "' alt=''><div class='item-info col" + o.columns + "'><h3 class='title'><a target='_blank' href='" + img_url + "' title='" + img_title + "'>"+ img_title + "</a></h3></div>"; 441 html += '<div class="item-info-overlay"><div><a href="' + img_url + '" class="view">
441details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 442 } else { 443 html += "<div class='item-container'><img src='" + img_src + "' alt='' style='height:auto'></div>"; 444 html += '<div class="item-info-overlay"><div><h3 class="title"><a target="_blank" href="' + img_url + '" title="' + img_title + '">'+ img_title + '</a></h3><a href="' + img_url + '" class="view">details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 445 } 446 html += "</li>"; 447 }) 448 obj.append(html); 449 obj.removeClass("photostream"); 450 }) 451 }) 452 453 }; 454 455 //obj.append(html); 456 457 458 459 }); 460 461 462 463 } 464 465 if (o.social_network == "instagram") { 466 if (o.api_token == "") o.api_token = instagram_token; 467 html = ""; 468 if (o.shape == "none") { 469 html += '<div class="portfolio-grid"><ul id="thumbs">' 470 } else { 471 html += '<div class="portfolio-grid"><ul id="thumbs" class="shaped ' + o.shape + '">' 472 } 473 474 url = "https://api.instagram.com/v1/users/search?q=" + o.user + "&access_token=" + o.api_token + "&count=10&callback=?"; 475 $.getJSON(url, function(data){ 476 $.each(data.data, function(i,shot){ 477 var instagram_username = shot.username; 478 479 if (instagram_username == o.user){ 480 481 var user_id = shot.id; 482 483 if (user_id != ""){ 484 url = "https://api.instagram.com/v1/users/" + user_id + "/media/recent/?access_token=" + o.api_token + "&count=" + o.limit + "&callback=?"; 485 $.getJSON(url, function(data){ 486 487 $.each(data.data, function(i,shot){ 488 if (o.shape == "none") { 489 html += '<li class="item col' + o.columns + '">'; 490 } else { 491 html += '<li class="item">'; 492 } 493 494 var img_src = shot.images.standard_resolution.url; 495 var img_src_o = shot.images.standard_resolution.url; 496 var img_url = shot.link; 497 var img_title = ""; 498 if (shot.caption != null){ 499 img_title = shot.caption.text; 500 } 501 502 if (o.shape == "none") { 503 html += "<img width='100%' src='" + img_src + "' alt=''><div class='item-info col" + o.columns + "'><h3 class='title'><a target='_blank' href='" + img_url + "' title='" + img_title + "'>"+ img_title + "</a></h3></div>"; 504 html += '<div class="item-info-overlay"><div><a href="' + img_url + '" class="view">details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 505 } else { 506 html += "<div class='item-container'><img src='" + img_src + "' alt='' style='height:auto'></div>"; 507 html += '<div class="item-info-overlay"><div><h3 class="title"><a target="_blank" href="' + img_url + '" title="' + img_title + '">'+ img_title + '</a></h3><a href="' + img_url + '" class="view">details</a><a title="' + img_title + '" href="' + img_src_o + '" class="preview" data-rel="prettyPhoto[]">preview</a></div> </div><!--END ITEM-INFO-OVERLAY-->'; 508 } 509 html += "</li>"; 510 511 }); 512 html += "</ul></div>"; 513 obj.append(html); 514 obj.removeClass("photostream"); 515 }); 516 } 517 } 518 }); 519 }); 520 521 522 523 524 525 526 } 527 528 529 }); // return this.each 530 } 531 }); 532})(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.