Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var dmp = new diff_match_patch();
- function myDiff(doc1, doc2) {
- return dmp.diff_main(doc1, doc2);
- }
- function myPatch(doc, diffs) {
- return dmp.patch_make(doc, diffs);
- }
- function myApplyPatchToDoc(doc, patches) {
- return dmp.patch_apply(patches, doc)[0];
- }
- function launch() {
- var text1 = document.getElementById('text1').value;
- var text2 = document.getElementById('text2').value;
- var diffs = myDiff(text1, text2);
- /*
- * Add diffs (Edit obj) to the Edits stack here...
- */
- //console.log(diffs);
- var str = "I am the very model of a modern Major-General,\nI've information vegetable, animal, and mineral,\nI know the kings of England, and I quote the fights historical,\nFrom Marathon to Waterloo, in order categorical.";
- // calculate patches
- var patches = myPatch(str, diffs);
- // results
- console.log(myApplyPatchToDoc(str, patches));
- var ds = dmp.diff_prettyHtml(diffs);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement