PageSourceSearch

https://info.grillzjewelz.jp/js/jquery.flickr-1.0.js

js grillzjewelz.jp collected 2026-10-05 20:33:46 UTC 5,872 bytes, 107 lines download raw bytes

1/*
2 * jQuery Flickr - jQuery plug-in
3 * Version 1.0, Released 2008.04.17
4 *
5 * Copyright (c) 2008 Daniel MacDonald (www.projectatomic.com)
6 * Dual licensed GPL https://www.gnu.org/licenses/gpl.html 
7 * and MIT https://www.opensource.org/licenses/mit-license.php
8 */
9(function($) {
10$.fn.flickr = function(o){
11var s = {
12    api_key: null,              // [string]    required, see https://www.flickr.com/services/api/misc.api_keys.html
13    type: 'search',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
14    photoset_id: null,          // [string]    required, for type=='photoset'  
15    text: null,			            // [string]    for type=='search' free text search
16    user_id: '51941885@N06',              // [string]    for type=='search' search by user id
17    group_id: null,             // [string]    for type=='search' search by group id
18    tags: null,                 // [string]    for type=='search' comma separated list
19    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
20    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
21    thumb_size: 's',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
22    size: null,                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
23    per_page: 100,              // [integer]   allowed values: max of 500
24    page: 1,     	              // [integer]   see paging notes
25    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
26    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
27    params: '',                 // [string]    optional, custom arguments, see https://www.flickr.com/services/api/flickr.photos.search.html
28    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
29    callback: null              // [function]  optional, callback function applied to entire <ul>
30
31    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
32    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
33    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
34    
35    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
36    
37    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
38  };
39  if(o) $.extend(s, o);
40  return this.each(function(){
41    // create unordered list to contain flickr images
42		var list = $('<ul>').appendTo(this);
43    var url = $.flickr.format(s);
44		$.getJSON(url, function(r){
45      if (r.stat != "ok"){
46        for (i in r){
47	        $('<li>').text(i+': '+ r[i]).appendTo(list);
48        };
49      } else {
50        if (s.type == 'photoset') r.photos = r.photoset;
51        // add hooks to access paging data
52        list.append('<input type="hidden" value="'+r.photos.page+'" />');
53        list.append('<input type="hidden" value="'+r.photos.pages+'" />');
54        list.append('<input type="hidden" value="'+r.photos.perpage+'" />');
55        list.append('<input type="hidden" value="'+r.photos.total+'" />');
56        for (var i=0; i<r.photos.photo.length; i++){
57          var photo = r.photos.photo[i];
58          // format thumbnail url
59          var t = 'https://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
60          //format image url
61          var h = 'https://www.flickr.com/photos/51941885@N06/';
62          switch (s.size){
63            case 'm':
64              h += photo['secret'] + '_m.jpg';
65              break;
66            case 'b':
67              h += photo['secret'] + '_b.jpg';
68              break;
69            case 'o':
70              if (photo['originalsecret'] && photo['originalformat']) {
71                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
72                break;
73              };
74          };
75          list.append('<li><a href="'+h+'" '+s.attr+' title="'+photo['title']+'" target="_blank" class="gh"><img src="'+t+'" alt="'+photo['title']+'" /></a></li>');
76        };
77        if (s.callback) s.callback(list);
78      };
79		});
80  });
81};
82// static function to format the flickr API url according to the plug-in settings 
83$.flickr = {
84    format: function(s){
85        if (s.url) return s.url;
86        var url = 'https://api.flickr.com/services/rest/?format=json&jsoncallback='+s.api_callback+'&api_key='+s.api_key;
87        switch (s.type){
88            case 'photoset':
89                url += '&method=flickr.photosets.getPhotos&photoset_id=' + s.photoset_id;
90                break;
91            case 'search':
92                url += '&method=flickr.photos.search&sort=' + s.sort;
93                if (s.user_id) url += '&user_id=' + s.user_id;
94                if (s.group_id) url += '&group_id=' + s.group_id;
95                if (s.tags) url += '&tags=' + s.tags;
96                if (s.tag_mode) url += '&tag_mode=' + s.tag_mode;
97                if (s.text) url += '&text=' + s.text;
98                break;
99            default:
100                url += '&method=flickr.photos.getRecent';
101        };
102        if (s.size == 'o') url += '&extras=original_format';
103        url += '&per_page=' + s.per_page + '&page=' + s.page + s.params;
104        return url;
105    }
106};
107})(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.