Uncategorized


The typical Ruby on Rails flash area is only drawn when there is a message to flash. I think something like this is fairly common (this example is haml, but that’s not the point) usually done in a partial, something like app/views/shared/_flash.html.haml:

- %w(info notice error).each do |type|
  - if flash[type.to_sym]
    .warning.flash_message{:class => “#{type.to_s}”}
      %span= h(flash[type.to_sym])
      %small
        %a{:href=>”#”, :onclick=>”$$(’div.flash_message’)[0].hide();return false”} Close this message
 

The problem with this is that if you are Ajaxing a bunch of stuff you could use the flash area for user interaction and highlighting messages, but if it isn’t there, that could be a problem. So how about doing this instead so that the flash area is always drawn, just not displayed:

- %w(info notice error).each do |type|
  .warning.flash_message{ :class => "#{type}", :id => "flash_#{type}", :style => "display: #{flash[type.to_sym] ? ‘block’ : ‘none’}” }
    %span
      - if flash[type.to_sym]
        = h(flash[type.to_sym])
    %small
      %a{:href=>”#”, :onclick=>”$$(’div.#{type.to_s}’)[0].hide();return false”} Close this message

The flash closer is still in there so we don’t have to worry about the complexity of building that again every time, and the message is in a separate span element so it is easy to fill in. So then we can add a little bitty application helper (app/helpers/application_helper.rb)

  def flashnow(page,msg)
    page.select("#flash_notice span").first.replace("#{msg}“)
    page.select(”#flash_notice”).first.show
  end

You might need to change the replace method for replaceHtml
depending on the version of prototype you are working with.
and call it from any view that is building an rjs response:

  flashnow(page,'Yeeha, cowboy, it worked!')


Want Biscuit with that Cornus Kousa?

Mr. Ryrie’s notes have it that when Jacob deceived Isaac, Isaac being old and thinking that he was preparing to die, that Isaac went on to live another 43 years. It’s not obvious how he gets this and so here is how it’s done, first in text, then with a picture.

  1. Joseph was 39 when Jacob came to Egypt. Jacob was 130 (45:11 + 47:9)
  2. Jacob was 91 when Joseph was born (subtract 39 from both sides)
  3. Jacob had been in Padan Aram 14 years when Joseph was born (30:25 + 31:41)
  4. Jacob was 77 when he stole the blessing and left home (subtract 14 from 91)
  5. Isaac was 60 years old when Jacob was born (25:26)
  6. Isaac was 137 when Jacob stole the blessing (60 + 77)
  7. Isaac lived 43 more years to 180 (35:28)

In the picture, (click to see a larger view) just use the red horizontal arrows to align the columns and work forward from Jacob’s birth and backwards from Joseph in Egypt. Simple.

Colleagues say departure of former speechwriter, who wrote most of president’s public words over last 7 years, will leave huge hole in White House.

washingtonpost.com - nation, world, technology and Washington area news and headlines

This is very cool. Check out www.flock.com and join the browser revolution.
Right in the flock browser, you can just highlight some text and choose
“Blog this” from the right-click context menu. Flock has a lot of other cool
features including del.icio.us integration, imported bookmarks and cookies from FIrefox, RSS aggregator and “Super star”.

Blogged with Flock

So I had this domain name and thought I better put some content on it before it started looking too suspicious. I’ll be using this to experiment with DHTML/CSS/Javascript/Ajax and all sorts of cool web technologies. I’ll probably also put up some of my Bible charts and tools.

Thanks, ssf, for the nice image in the header. It’s Lake Powell, Arizona with the water level 80 to 90 feet down from when I visited there as a teenager in 1978.