diff --git a/README.md b/README.md index 7272d78..e54c0a4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This [blog post](http://arnab-deka.com/posts/2013/02/hello-jquery-prettytextdiff explains things in a bit more detail. ## Demo -[jsfiddle demo](http://jsfiddle.net/YwSVY/) +[jsfiddle demo](http://jsfiddle.net/q7hyfev8/5/) ## Download From the [jQuery plugins site](http://plugins.jquery.com/pretty-text-diff/). @@ -93,6 +93,18 @@ in the [jsfiddle demo](#demo). false see some debug output in your browser's console + + + originalContent + None + Pass the original content as a parameter in your JS file, instead of creating an element in your HTML code to extract this content. + + + + changedContent + None + Pass the changed content as a parameter in your JS file, instead of creating an element in your HTML code to extract this content. + ## Development diff --git a/jquery.pretty-text-diff.coffee b/jquery.pretty-text-diff.coffee index 800cd93..6108610 100644 --- a/jquery.pretty-text-diff.coffee +++ b/jquery.pretty-text-diff.coffee @@ -1,5 +1,5 @@ ### -@preserve jQuery.PrettyTextDiff 1.0.3 +@preserve jQuery.PrettyTextDiff 1.0.4 See https://github.com/arnab/jQuery.PrettyTextDiff/ ### @@ -19,9 +19,14 @@ $.fn.extend dmp = new diff_match_patch(); @each -> - original = $(settings.originalContainer, this).text() + if settings.originalContent and settings.changedContent + original = $('
').html(settings.originalContent).text() + changed = $('
').html(settings.changedContent).text() + else + original = $(settings.originalContainer, this).text() + changed = $(settings.changedContainer, this).text() + $.fn.prettyTextDiff.debug "Original text found: ", original, settings - changed = $(settings.changedContainer, this).text() $.fn.prettyTextDiff.debug "Changed text found: ", changed, settings diffs = dmp.diff_main(original, changed)