I am trying to build a rails app that's basically just a text-editor (with some additional features I can't find anywhere else - which is why I'm building it)

One of the core features is live concurrent editing, or real-time collaborative editing (whatever you want to call it).

So far I have set up the site with a plugin called Juggernaut. This gives me the ability to send, either from a client or the server, any Javascript I want to every other client. So when someone types something I can send what that person has typed to every other client, without the other clients having to poll the server.

The problem I have boils down to me not knowing what algorithm to use for solving conflicts and doing this the best way possible. I have read up a bit on Operational Transformation, but just simple don't know how to sensibly implement it with the Javascript/Rails-solution I have now.

I want something like OT, but don't know how to implement it and don't know where to start.
Any help on how to implement this would me very happy!