Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Beefed up RSS2 template for consumption with the Google Feed API Slide Show Control

// description of your code here

xml.instruct!

# RSS2 rxml template based on: http://snippets.dzone.com/posts/show/558
xml.rss "version" => "2.0", \
        "xmlns:dc" => "http://purl.org/dc/elements/1.1/", \
        "xmlns:media" => "http://search.yahoo.com/mrss/" do

    xml.channel do

        xml.title       "foto-foo :: public timeline"
        xml.link        url_for :only_path => false, :controller => 'feeds'
        xml.pubDate     CGI.rfc1123_date(@images.first.updated_at) if @images.any?
        xml.description "foto-foo :: public timeline image feed"

        host = "AWS.S3.storage.host"
        @images.each do |img|
            img.url = "http://#{host}/#{img.name}"
            xml.item do
                xml.title       img.name
                xml.link        url_for :only_path => false, :controller => 'feeds', :action => 'show', :id => img.id
                xml.description "<a href='#{img.url}'><img src='#{img.url}'/></a>"
                xml.enclosure :url => "#{img.url}", :type => "image/jpg"

                xml.pubDate     CGI.rfc1123_date img.updated_at
                xml.guid        url_for :only_path => false, :controller => 'posts', :action => 'show', :id => img.id
                xml.author      "\"user-#{img.user_id}\" (#{img.user_id}@foto-foo.com)"

                xml.media :group do
                    xml.media :title, img.name
                    xml.media \
                        :content, :type => "#{img.mime}", :medium => "image", \
                        :url => "#{img.url}"
                        xml.media :credit, "#{img.credit.txt}", \
                                :role => "#{img.credit.role}" 
                    xml.media :description, "#{img.desc}", :type => 'plain'
                    xml.media :keywords, "#{img.tags}"
                    xml.media :thumbnail, \
                        :width => "#{img.thumbnail.widh}", \
                        :height => "#{img.thumbnail.height}", \
                        :url => "#{img.thumbnail.url}"
                end
            end
        end

    end
end

Scriptaculous JavaScript slideshow

Found this amazing code by obie at http://blog.caboo.se/articles/2006/01/19/easy-scriptaculous-slideshow:

var album = { 
  startup: function() { 
    new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
  }, 
  cycle: function() { 
    new Effect.Fade('image', { // the id of the <DIV> containing the photos 
      duration: 1, 
      fps: 50, 
      afterFinish: function() { 
        new Ajax.Updater('image','/album/next', { // URL for next <IMG> tag 
          asynchronous: true, 
          onSuccess: function() { 
            new Effect.Appear('image', {
              duration: 1,
              fps: 50,
              queue:'end'
            })
          } 
        }) 
      } 
    }) 
  } 
} 
 
window.onload = album.startup


I want to tweak it so that an earlier event precaches the next image instead.

Miniature slideshow for DIVs using Scriptaculous

<div id="slideshow1" class="slide"><div>frame 1</div></div>
<div id="slideshow2" class="slide" style="display: none"><div>frame 2</div></div>
<div id="slideshow3" class="slide" style="display: none"><div>frame 3</div></div>
<div id="slideshow4" class="slide" style="display: none"><div>frame 4</div></div>

<script type="text/javascript">
    
    start_slideshow(1, 4, 2000);
    
    function start_slideshow(start_frame, end_frame, delay) {
        setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
    }
                            
    function switch_slides(frame, start_frame, end_frame, delay) {
        return (function() {
            Effect.Fade('slideshow' + frame);
            if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
            setTimeout("Effect.Appear('slideshow" + frame + "');", 850);
            setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
        })
    }

</script>
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS