开发者

Javascript Textarea Monitoring / Ruby Delta Calculation

开发者 https://www.devze.com 2022-12-12 10:33 出处:网络
I am working on a system which needs to keep constant (and I mean constant) track of browser side changes to a textarea via AJAX requests to the server. Ideally, every character would be stored as a r

I am working on a system which needs to keep constant (and I mean constant) track of browser side changes to a textarea via AJAX requests to the server. Ideally, every character would be stored as a row in the database, along with the position it was inserted and a timestamp.

I am hoping that there is either a good Javascript library that I have somehow missed which will make it trivial to do this all in the browser, but I think that inconsistencies in the DOM prevents one from doing so in any way which will be resource-reasonable. I'm a jQuery user, if that makes a difference.

The documents being created can get very large, so it is inefficient to send the entire document back and perform a diff on the server, but I think that I can work out a way to only send back the lines which are affected by an edit. Unfortunately, I do need a way to get per-character as opposed to per-line diffs calculated once it reaches the server.

I would like to use Ruby, so if there is a Ruby library that can do that, awesome. If not, is ther开发者_如何学编程e a generic algorithm to calculating actual deltas between two strings that someone can suggest?

Summary:

Javascript Library for very tightly monitored textarea OR

Ruby library for calculating deltas OR

Generic delta calculation algorithm

In that order. Thank you in advance.


I think you can try having Ruby to call diff via the command line, then return those diff back to user ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消