Quoting using JS in Rails 2

Hello all, I'm looking for a good solution to provide "smart quoting" for an app I'm making. The end-user workflow I'm hoping to accomplish is this:

* User reads entry, ie a blog post or a news article

* User highlights a passage in the entry in his browser

* User clicks a link in the page and a form appears. The form's text area should contain the highlighted text. (This is one step I'm unsure of how to accomplish. So far all I've found is JS to copy a pre- selected passage that is already wrapped in a DIV.)

* The user submits the form, eventually via AJAX, and is returned to the entry. The entry model would has_many :quotes, or :comments, or whatever fits the context naming-wise. That form would add a new one to the entry. The quote model would validate against the parent entry to ensure that the content of the quote is actually contained within the body of the entry.

* Additionally, I'm hoping to make a link next to each quote clickable that will then use JS to find the passage within the entry's body, and wrap it in a DIV to highlight the text in a new color, background, and space it off from the rest of the entry. (This is something else I'm unsure of, but I think I'll find it easy enough to figure out on my own.)

Any thoughts? Again, I've looked briefly for javascript to interact with copying/pasting, but the main point I'm stuck on is just getting what the user has highlighted.

Thanks for your time, Shane Sveller

Any thoughts? Again, I've looked briefly for javascript to interact with copying/pasting, but the main point I'm stuck on is just getting what the user has highlighted.

any help? http://www.google.com/search?hl=en&q=javascript+highlighted+text&btnG=Search

Thanks, that's a great start. I guess my google-fu is weak today.