Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created April 10, 2011 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/912677 to your computer and use it in GitHub Desktop.
Save walterdavis/912677 to your computer and use it in GitHub Desktop.
var rightpanel = $('rightpanel');
var leftpanel = $('leftpanel');
var stories = rightpanel.select('h3').each(function(elm){
elm['link'] = elm.down('a').href;
elm['description'] = elm.next('p').insert(
' <a href="' + this.link + '">read more</a>'
).remove();
elm.update(elm.down('a').innerHTML).setStyle('cursor:pointer');;
elm.remove();
});
stories.each(function(story){
leftpanel.insert(story);
story.observe('click',function(evt){
rightpanel.update(this.clone(true)).insert(
this.description
);
stories.invoke('removeClassName','active');
story.addClassName('active');
});
});
//choose random story to feature first
var story = stories[Math.floor(Math.random() * stories.length)];
rightpanel.update(story.clone(true)).insert(
story.description
);
story.addClassName('active');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment