Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may be able to achieve this using the <a href="https://code.google.com/p/google-diff-match-patch" rel="nofollow">Google Diff/Match/Patch library</a>. It has bindings for Python, C++, Java, LUA, Objective C, and Javascript. You would download the original to the client, generate a list of patches on the server-side (you'd want to keep track of which client had which version to know what your starting point is; this can be done on the client or the server), pull the patches for the client's local revision to the latest down to the client, and use the client-side library to apply the patches. Once you get the changes in, you'd want to update that client revision tracking number.</p> <p>I've included an implementation sample for completeness' sake. I'm pretty impressed with how well this library works and intend to keep it in my toolbelt.</p> <pre><code>// C# server-side code DiffMatchPatch.diff_match_patch differ = new DiffMatchPatch.diff_match_patch(); // I'm using literals, you'd pull these from a DB, etc. var results = differ.patch_make("ABCDEFG", "ABCDEFQ"); var serializedResults = differ.patch_toText(results); // Send serializedResults to client... </code></pre> <p>On the client-side:</p> <pre><code>// Javascript client-side code var patcher = new diff_match_patch(); // The below literal is what *would* be sent var patches = patcher.patch_fromText("@@ -3,5 +3,5 @@\n CDEF\n-G\n+Q\n"); var results = patcher.patch_apply(patches, 'ABCDEFG'); alert(results); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload