1/* 2 * Flickrush 1.0 - jQuery flickr plugin 3 * 4 * Copyright (c) 2010 Philip Beel (http://www.theodin.co.uk/) 5 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 6 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. 7 * 8 * Revision: $Id: jquery.flickrush.js 2010-02-17 $ 9 * 10 */ 11(function($){ 12 $.fn.flickrush=function(options){ 13 var defaults={ 14 limit:3, 15 random:true, 16 id:'44499772@N06' 17 }; 18 var options=$.extend(defaults,options); 19 return this.each(function(options){ 20 var act=$(this); 21 $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?format=json&size=s&id="+defaults.id+"&jsoncallback=?", 22 function(data){ 23 var num = 0; //get a random integer 24 var imageArray = new Array(); //store used images in here 25 while( num <= defaults.limit-1) { 26 if(defaults.random == true) { 27 var randomiser = Math.floor(Math.random()*20); 28 } 29 $.each(data.items, function(i,item){ 30 if(defaults.random == true) { 31 var imgheigth = $(this).parents().width(); 32 if( ( i == randomiser ) && (!imageArray.in_array(randomiser) ) ) { 33 //var link = '<a href="'+item.media.m+'">'; 34 var newLink = $("<a/>").attr({ 35 href: item.link, 36 target : '_bank' 37 }); 38 var newImage = $("<img/>").attr({ 39 src: (item.media.m).replace('_m','_s'), 40 alt: item.tags, 41 width: defaults.width, 42 height: imgheigth 43 }); 44 45 $(act).append(newLink.append(newImage)); 46 } 47 } else { 48 if( ( i <= defaults.limit-1 ) && (!imageArray.in_array(defaults.limit-1) ) ) { 49 var newLink = $("<a/>").attr({ 50 href: item.link, 51 target : _bank 52 }); 53 var newImage = $("<img/>").attr({ 54 src: item.media.m, 55 alt: item.tags 56 }); 57 $(act).append(newLink.append(newImage)); 58 } 59 } 60 }); 61 if(defaults.random == true) { 62 if ( imageArray.in_array(randomiser) ) { 63 defaults.limit++; 64 } 65 //strore our image number 66 imageArray.push(randomiser); 67 } else { 68 imageArray.push(defaults.limit-1); 69 } 70 num++; 71 } 72 }); 73 74 //function to check in an array 75 Array.prototype.in_array = function(p_val) { 76 for(var i = 0, l = this.length; i < l; i++) { 77 if(this[i] == p_val) { 78 return true; 79 } 80 } 81 return false; 82 } 83 }); 84 } 85})(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.