Sha256: 29809c6665d638d164c3b7e5480ba8deaa068940a6148bc6034154ed0af9a8cc

Contents?: true

Size: 1.84 KB

Versions: 4

Compression:

Stored size: 1.84 KB

Contents

<script type="text/javascript">
  function addTheCover(booksInfo){
    jQuery(function(){
      var link = '';
      for (i in booksInfo.items) {
        var book = booksInfo.items[i]
        var image = book.volumeInfo.imageLinks;
        if (image && image.thumbnail != undefined) {
          var thumbnail = image.thumbnail.replace('zoom=5', 'zoom=1');
          if ( document.location.protocol == 'https:' ) {
            var parser = document.createElement('a');
            parser.href = thumbnail;
            parser.protocol = 'https:';
            parser.hostname = 'encrypted.google.com';
            thumbnail = parser.href;
          }
          if (thumbnail) {
            var link = '<img src="' + thumbnail + '" alt="' + book.volumeInfo.title + '" />';
            if (book.accessInfo && book.accessInfo.viewability != "NO_PAGES") {
              var preview = book.volumeInfo.previewLink;
              link += '<br /><a href="' + preview + '" target="_blank"><img border=0 src="//www.google.com/googlebooks/images/gbs_preview_button1.gif" title="Google Preview" alt="Google Preview" /></a>';
            }
          }
        }
      }
      if (link === '') {
        <% if Setting.book_jacket.unknown_resource.blank? %>
          var link = '<%= image_tag("unknown_resource.png", :size => "150x150", :alt => "*") %>';
        <% else %>
          var link = '<%= Setting.book_jacket.unknown_resource %>';
        <% end %>
      }

      var thumb_element = document.getElementById('gbsthumbnail');
      if (thumb_element) {
        thumb_element.innerHTML = link;
      }
    });
  }
</script>
<% if @manifestation %>
  <% if @manifestation.identifier_contents(:isbn).first %>
    <script src="https://www.googleapis.com/books/v1/volumes?q=isbn:<%= @manifestation.identifier_contents(:isbn).first %>&amp;callback=addTheCover"></script>
  <% end %>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enju_manifestation_viewer-0.1.0.pre13 app/views/manifestations/_google_book_thumbnail_header.html.erb
enju_manifestation_viewer-0.1.0.pre12 app/views/manifestations/_google_book_thumbnail_header.html.erb
enju_manifestation_viewer-0.1.0.pre11 app/views/manifestations/_google_book_thumbnail_header.html.erb
enju_manifestation_viewer-0.1.0.pre10 app/views/manifestations/_google_book_thumbnail_header.html.erb