Permalink
Browse files

Merge pull request #3 from ao5357/master

Bugfixes for flickr
  • Loading branch information...
2 parents 1d89e14 + d782305 commit b9e2cc9f95196e5a6bf48bd7fcb4972cb1f30d22 @djcp committed Apr 5, 2012
Showing with 15 additions and 10 deletions.
  1. +15 −10 javascripts/covered.js
View
25 javascripts/covered.js
@@ -39,7 +39,7 @@ $.extend({
nodeContent += '<img src="http://covers.openlibrary.org/b/isbn/' + isbn + '-S.jpg" class="cover" />';
});
}
- if(d.content_link){nodeContent += '<a href="' + d.content_link[0] + '">';}
+ if(d.content_link){nodeContent += '<a target="_blank" href="' + d.content_link[0] + '">';}
nodeContent += (d.title) ? $.ellipsisSubstr(d.title) : 'Untitled Work';
if(d.content_link){nodeContent += '</a>';}
nodeContent += '<span class="data_source">' + d.data_source + '</span>';
@@ -64,14 +64,16 @@ $.extend({
var subj = encodeURIComponent(subject);
$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ea0707dc3f4b4b3346806560845986c9&license=1,2,3,4,5,6,7&sort=relevance&format=json&text=' + subj + '&jsoncallback=?')
.done(function(data){
- var output = '<br /><strong><a href="http://www.flickr.com/search/?l=deriv&q=' + subj + '">Flickr results</a> for "' + subject + '"</strong>:<br />';
- $.each(data.photos.photo,function(i,photo){
- if(i <= 3){
- output += $.flickrImage(photo);
- }
- });
- doc.append(output);
- $('.isotope').isotope('reLayout');
+ if(data.photos.photo){
+ var output = '<br /><strong><a target="_blank" href="http://www.flickr.com/search/?l=deriv&q=' + subj + '">Flickr results</a> for "' + subject + '"</strong>:<br />';
+ $.each(data.photos.photo,function(i,photo){
+ if(i <= 3){
+ output += $.flickrImage(photo);
+ }
+ });
+ doc.append(output);
+ $('.isotope').isotope('reLayout');
+ }
});
return false;
},
@@ -158,7 +160,10 @@ $(document).ready(function(){
$doc.record = $doc.data('d');
if($doc.record.subject){
var singleTerm = $.trim($doc.record.subject[0].split(',')[0]);
- $.subjectFlickr($doc,singleTerm);
+ if($doc.data('flickrd') !== true){
+ $.subjectFlickr($doc,singleTerm);
+ $doc.data('flickrd',true);
+ }
}
});

0 comments on commit b9e2cc9

Please sign in to comment.