-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2017 Nathan Herald, Rohland de Charmoy, Anton Frattaroli | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>htmldiff.js example</title> | ||
<style type="text/css"> | ||
table { | ||
border: 1px solid #d9d9d9; | ||
} | ||
|
||
td { | ||
border: 1px solid #d9d9d9; | ||
padding: 3px; | ||
} | ||
|
||
/* Diff related styles */ | ||
|
||
ins { | ||
background-color: #cfc; | ||
text-decoration: inherit; | ||
} | ||
|
||
del { | ||
color: #999; | ||
background-color: #FEC8C8; | ||
} | ||
|
||
ins.mod { | ||
background-color: #FFE1AC; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>htmldiff.js Example</h1> | ||
<h2>Old Text</h2> | ||
<div class="old-text"></div> | ||
<h2>New Text</h2> | ||
<div class="new-text"></div> | ||
<h2>Diff</h2> | ||
<div class="diff-text"></div> | ||
<script src="html-diff.js"></script> | ||
<script type="text/javascript"> | ||
var oldText = '<p>This is some sample text to demonstrate the capability of the <strong>HTML diff tool</strong>.</p><p>It is based on the C# implementation found <a href="https://github.com/Rohland/htmldiff.net">here</a> that is based off of the Ruby implementation found <a href="http://github.com/myobie/htmldiff">here</a>. Note how the link has no tooltip</p><table cellpadding="0" cellspacing="0"><tr><td>Some sample text</td><td>Some sample value</td></tr><tr><td>Data 1 (this row will be removed)</td><td>Data 2</td></tr></table>'; | ||
var newText = '<p>This is some sample text to demonstrate the awesome capabilities of the <strong>HTML diff tool</strong>.</p><br/><br/>Extra spacing here that was not here before.<p>It is based on the C# implementation found <a href="https://github.com/Rohland/htmldiff.net">here</a> that is based off of the Ruby implementation found <a title="Cool tooltip" href="http://github.com/myobie/htmldiff">here</a>. Note how the link has a tooltip now and the HTML diff algorithm has preserved formatting.</p><table cellpadding="0" cellspacing="0"><tr><td>Some sample <strong>bold text</strong></td><td>Some sample value</td></tr></table>'; | ||
var htmlDiff = new HtmlDiff(oldText, newText); | ||
var output = htmlDiff.Build(); | ||
|
||
document.getElementsByClassName('old-text')[0].innerHTML = oldText; | ||
document.getElementsByClassName('new-text')[0].innerHTML = newText; | ||
document.getElementsByClassName('diff-text')[0].innerHTML = output; | ||
</script> | ||
</body> | ||
</html> |