Skip to content

Commit

Permalink
Fix synchronised scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfpessoa committed Jan 15, 2017
1 parent b9386de commit 7a79d27
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 95 deletions.
7 changes: 4 additions & 3 deletions dist/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
Author: rtfpessoa
-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css">

<!--diff2html-css-->

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/scala.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/languages/scala.min.js"></script>

<!--diff2html-js-ui-->

<script>
$(document).ready(function() {
var diff2htmlUi = new Diff2HtmlUI();
//diff2html-fileListCloseable
//diff2html-synchronisedScroll
diff2htmlUi.highlightCode('#diff');
});
</script>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
"main": "./src/main.js",
"dependencies": {
"copy-paste": "^1.3.0",
"diff2html": "^2.0.11",
"diff2html": "^2.0.12",
"extend": "^3.0.0",
"open": "^0.0.5",
"request": "^2.79.0",
"yargs": "^6.5.0"
"yargs": "^6.6.0"
},
"devDependencies": {
"codacy-coverage": "^2.0.0",
"eslint": "^3.12.2",
"eslint": "^3.13.1",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"istanbul": "^0.4.5",
Expand Down
7 changes: 4 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@
config.synchronisedScroll = (baseConfig.synchronisedScroll === 'enabled');

var htmlContent = diff2Html.getPrettyHtml(jsonContent, config);
return callback(null, that._prepareHTML(htmlContent, config.showFilesOpen));
return callback(null, that._prepareHTML(htmlContent, config));
} else if (baseConfig.format === 'json') {
return callback(null, JSON.stringify(jsonContent));
}

return callback(new Error('Wrong output format `' + baseConfig.format + '`!'));
};

Diff2HtmlInterface.prototype._prepareHTML = function(content, showFilesOpen) {
Diff2HtmlInterface.prototype._prepareHTML = function(content, config) {
var templatePath = path.resolve(__dirname, '..', 'dist', 'template.html');
var template = utils.readFileSync(templatePath);

Expand All @@ -109,7 +109,8 @@
return template
.replace('<!--diff2html-css-->', '<style>\n' + cssContent + '\n</style>')
.replace('<!--diff2html-js-ui-->', '<script>\n' + jsUiContent + '\n</script>')
.replace('//diff2html-fileListCloseable', 'diff2htmlUi.fileListCloseable("#diff", ' + showFilesOpen + ');')
.replace('//diff2html-fileListCloseable', 'diff2htmlUi.fileListCloseable("#diff", ' + config.showFilesOpen + ');')
.replace('//diff2html-synchronisedScroll', 'diff2htmlUi.synchronisedScroll("#diff", ' + config.synchronisedScroll + ');')
.replace('<!--diff2html-diff-->', content);
};

Expand Down
119 changes: 33 additions & 86 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

bl@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398"
dependencies:
readable-stream "~2.0.5"

bluebird@^2.3, bluebird@^2.9.x:
version "2.11.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
Expand Down Expand Up @@ -231,7 +225,7 @@ co@^4.6.0:

codacy-coverage@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/codacy-coverage/-/codacy-coverage-2.0.0.tgz#58c5b5df4bcaaa7b52142417f2f8774ed3fb4fe7"
resolved "https://registry.npmjs.org/codacy-coverage/-/codacy-coverage-2.0.0.tgz#58c5b5df4bcaaa7b52142417f2f8774ed3fb4fe7"
dependencies:
bluebird "^2.9.x"
commander "^2.x"
Expand Down Expand Up @@ -272,7 +266,7 @@ concat-stream@^1.4.6:

copy-paste@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/copy-paste/-/copy-paste-1.3.0.tgz#a7e6c4a1c28fdedf2b081e72b97df2ef95f471ed"
resolved "https://registry.npmjs.org/copy-paste/-/copy-paste-1.3.0.tgz#a7e6c4a1c28fdedf2b081e72b97df2ef95f471ed"
dependencies:
iconv-lite "^0.4.8"
optionalDependencies:
Expand Down Expand Up @@ -330,21 +324,21 @@ delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"

diff2html@^2.0.11:
version "2.0.11"
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-2.0.11.tgz#b0ccb1d8da49702fdc191737c4b1f5e6fa8affc6"
diff2html@^2.0.12:
version "2.0.12"
resolved "https://registry.npmjs.org/diff2html/-/diff2html-2.0.12.tgz#20eda2f1ffd14027716485c938e3fe21dc379455"
dependencies:
diff "^3.1.0"
diff "^3.2.0"
hogan.js "^3.0.2"
whatwg-fetch "^1.0.0"
whatwg-fetch "^2.0.1"

diff@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf"

diff@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.1.0.tgz#9406c73a401e6c2b3ba901c5e2c44eb6a60c5385"
diff@^3.2.0:
version "3.2.0"
resolved "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"

doctrine@^1.2.2:
version "1.5.0"
Expand Down Expand Up @@ -443,15 +437,15 @@ escope@^3.6.0:

eslint-plugin-promise@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.4.0.tgz#6ba9048c2df57be77d036e0c68918bc9b4fc4195"
resolved "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.4.0.tgz#6ba9048c2df57be77d036e0c68918bc9b4fc4195"

eslint-plugin-standard@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-2.0.1.tgz#3589699ff9c917f2c25f76a916687f641c369ff3"
resolved "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-2.0.1.tgz#3589699ff9c917f2c25f76a916687f641c369ff3"

eslint@^3.12.2:
version "3.12.2"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.12.2.tgz#6be5a9aa29658252abd7f91e9132bab1f26f3c34"
eslint@^3.13.1:
version "3.13.1"
resolved "https://registry.npmjs.org/eslint/-/eslint-3.13.1.tgz#564d2646b5efded85df96985332edd91a23bff25"
dependencies:
babel-code-frame "^6.16.0"
chalk "^1.1.3"
Expand Down Expand Up @@ -483,7 +477,7 @@ eslint@^3.12.2:
require-uncached "^1.0.2"
shelljs "^0.7.5"
strip-bom "^3.0.0"
strip-json-comments "~1.0.1"
strip-json-comments "~2.0.1"
table "^3.7.8"
text-table "~0.2.0"
user-home "^2.0.0"
Expand Down Expand Up @@ -535,7 +529,7 @@ exit-hook@^1.0.0:

extend@^3.0.0, extend@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4"
resolved "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4"

extsprintf@1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -579,14 +573,6 @@ forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"

form-data@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25"
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.5"
mime-types "^2.1.11"

form-data@~2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4"
Expand Down Expand Up @@ -869,7 +855,7 @@ isstream@~0.1.2:

istanbul@^0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b"
resolved "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b"
dependencies:
abbrev "1.0.x"
async "1.x"
Expand Down Expand Up @@ -1054,7 +1040,7 @@ mime-db@~1.24.0:
version "1.24.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.24.0.tgz#e2d13f939f0016c6e4e9ad25a8652f126c467f0c"

mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.7:
mime-types@^2.1.12, mime-types@~2.1.7:
version "2.1.12"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.12.tgz#152ba256777020dd4663f54c2e7bc26381e71729"
dependencies:
Expand Down Expand Up @@ -1082,7 +1068,7 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1:

mocha@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.2.0.tgz#7dc4f45e5088075171a68896814e6ae9eb7a85e3"
resolved "https://registry.npmjs.org/mocha/-/mocha-3.2.0.tgz#7dc4f45e5088075171a68896814e6ae9eb7a85e3"
dependencies:
browser-stdout "1.3.0"
commander "2.9.0"
Expand Down Expand Up @@ -1112,10 +1098,6 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"

node-uuid@~1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f"

nopt@1.0.10:
version "1.0.10"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
Expand Down Expand Up @@ -1161,7 +1143,7 @@ onetime@^1.0.0:

open@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"
resolved "https://registry.npmjs.org/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"

optimist@^0.6.1:
version "0.6.1"
Expand Down Expand Up @@ -1249,10 +1231,6 @@ progress@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"

qs@~6.2.0:
version "6.2.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625"

qs@~6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442"
Expand All @@ -1272,7 +1250,7 @@ read-pkg@^1.0.0:
normalize-package-data "^2.3.2"
path-type "^1.0.0"

readable-stream@~2.0.0, readable-stream@~2.0.5:
readable-stream@~2.0.0:
version "2.0.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e"
dependencies:
Expand Down Expand Up @@ -1310,35 +1288,9 @@ request-promise@^0.x:
lodash "^3.10.0"
request "^2.34"

request@^2.34:
version "2.75.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
bl "~1.1.2"
caseless "~0.11.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.0.0"
har-validator "~2.0.6"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
node-uuid "~1.4.7"
oauth-sign "~0.8.1"
qs "~6.2.0"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "~0.4.1"

request@^2.79.0:
request@^2.34, request@^2.79.0:
version "2.79.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
resolved "https://registry.npmjs.org/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
Expand Down Expand Up @@ -1520,9 +1472,9 @@ strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"

strip-json-comments@~1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91"
strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"

supports-color@3.1.2, supports-color@^3.1.0:
version "3.1.2"
Expand Down Expand Up @@ -1629,9 +1581,9 @@ verror@1.3.6:
dependencies:
extsprintf "1.0.2"

whatwg-fetch@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-1.1.1.tgz#ac3c9d39f320c6dce5339969d054ef43dd333319"
whatwg-fetch@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.1.tgz#078b9461bbe91cea73cbce8bb122a05f9e92b772"

which-module@^1.0.0:
version "1.0.0"
Expand All @@ -1647,10 +1599,6 @@ window-size@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"

window-size@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075"

wordwrap@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
Expand Down Expand Up @@ -1693,9 +1641,9 @@ yargs-parser@^4.2.0:
dependencies:
camelcase "^3.0.0"

yargs@^6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.5.0.tgz#a902e23a1f0fe912b2a03f6131b7ed740c9718ff"
yargs@^6.6.0:
version "6.6.0"
resolved "https://registry.npmjs.org/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208"
dependencies:
camelcase "^3.0.0"
cliui "^3.2.0"
Expand All @@ -1708,7 +1656,6 @@ yargs@^6.5.0:
set-blocking "^2.0.0"
string-width "^1.0.2"
which-module "^1.0.0"
window-size "^0.2.0"
y18n "^3.2.1"
yargs-parser "^4.2.0"

Expand Down

0 comments on commit 7a79d27

Please sign in to comment.