update to version 1.0.0
This commit is contained in:
parent
0a8dc03a8a
commit
44c9c747fd
3 changed files with 1567 additions and 1465 deletions
2992
diff2html.js
2992
diff2html.js
File diff suppressed because it is too large
Load diff
2
diff2html.min.js
vendored
2
diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
38
index.html
38
index.html
|
|
@ -16,7 +16,6 @@
|
|||
<script type="text/javascript" src="diff2html.min.js"></script>
|
||||
<!-- -->
|
||||
|
||||
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/languages/scala.min.js"></script>
|
||||
|
||||
|
|
@ -203,25 +202,42 @@
|
|||
"+var text = 'diff --git a/components/app/app.html b/components/app/app.html\\nindex ecb7a95..027bd9b 100644\\n--- a/components/app/app.html\\n+++ b/components/app/app.html\\n@@ -52,0 +53,3 @@\\n+\\n+\\n+\\n@@ -56,0 +60,3 @@\\n+\\n+\\n+\\n'\n" +
|
||||
'+var patchLineList = [ false, false, false, false ];\n' +
|
||||
'+\n' +
|
||||
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n';
|
||||
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n' +
|
||||
"diff --git a/a.xml b/b.xml\n" +
|
||||
"index e54317e..82a9a56 100644\n" +
|
||||
"--- a/a.xml\n" +
|
||||
"+++ b/b.xml\n" +
|
||||
"@@ -242,4 +242,6 @@ need to create a new job for native server java api and move these tests to a ne\n" +
|
||||
" </packages>\n" +
|
||||
" </test>\n" +
|
||||
" -->\n" +
|
||||
"+\n" +
|
||||
"+\n";
|
||||
|
||||
$(document).ready(function () {
|
||||
var diff2Html = Diff2Html;
|
||||
var diffJson = diff2Html.getJsonFromDiff(lineDiffExample);
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// parse the diff to json
|
||||
var diffJson = Diff2Html.getJsonFromDiff(lineDiffExample);
|
||||
|
||||
var allFileLanguages = diffJson.map(function (line) {
|
||||
// collect all the file extensions in the json
|
||||
var allFileLanguages = diffJson.map(function(line) {
|
||||
return line.language;
|
||||
});
|
||||
var distinctLanguages = allFileLanguages.filter(function (v, i) {
|
||||
|
||||
// remove duplicated languages
|
||||
var distinctLanguages = allFileLanguages.filter(function(v, i) {
|
||||
return allFileLanguages.indexOf(v) == i;
|
||||
});
|
||||
|
||||
// pass the languages to the highlightjs plugin
|
||||
hljs.configure({languages: distinctLanguages});
|
||||
|
||||
$("#line-by-line").html(diff2Html.getPrettyHtmlFromJson(diffJson));
|
||||
$("#side-by-side").html(diff2Html.getPrettySideBySideHtmlFromJson(diffJson));
|
||||
// generate and inject the diff HTML into the desired place
|
||||
document.getElementById("line-by-line").innerHTML = Diff2Html.getPrettyHtmlFromJson(diffJson);
|
||||
document.getElementById("side-by-side").innerHTML = Diff2Html.getPrettySideBySideHtmlFromJson(diffJson);
|
||||
|
||||
var code = $(".d2h-code-line-ctn");
|
||||
code.map(function (i, line) {
|
||||
// collect all the code lines and execute the highlight on them
|
||||
var codeLines = document.getElementsByClassName("d2h-code-line-ctn");
|
||||
[].forEach.call(codeLines, function(line) {
|
||||
hljs.highlightBlock(line);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue