Release version v2.3.2

This commit is contained in:
Rodrigo Fernandes 2017-10-16 23:50:42 +01:00
parent b88c775ebe
commit 5b8ef31d76
6 changed files with 17225 additions and 73 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "diff2html", "name": "diff2html",
"version": "2.3.1", "version": "2.3.2",
"homepage": "https://diff2html.xyz", "homepage": "https://diff2html.xyz",
"description": "Fast Diff to colorized HTML", "description": "Fast Diff to colorized HTML",
"keywords": [ "keywords": [

17207
dist/diff2html.js vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -488,7 +488,7 @@ $(document).ready(function() {
var $outputFormat = $('#diff-url-options-output-format'); var $outputFormat = $('#diff-url-options-output-format');
var $showFiles = $('#diff-url-options-show-files'); var $showFiles = $('#diff-url-options-show-files');
var $matching = $('#diff-url-options-matching'); var $matching = $('#diff-url-options-matching');
var $wordThreshold = $('#diff-url-options-match-words-threshold'); var $wordsThreshold = $('#diff-url-options-match-words-threshold');
var $matchingMaxComparisons = $('#diff-url-options-matching-max-comparisons'); var $matchingMaxComparisons = $('#diff-url-options-matching-max-comparisons');
if (window.location.search) { if (window.location.search) {
@ -502,10 +502,13 @@ $(document).ready(function() {
$outputFormat $outputFormat
.add($showFiles) .add($showFiles)
.add($matching) .add($matching)
.add($wordThreshold) .add($wordsThreshold)
.add($matchingMaxComparisons) .add($matchingMaxComparisons)
.change(function() { .change(function(e) {
smartDraw(); console.log('');
console.log(e);
console.log('');
smartDraw(null, true);
}); });
function getUrlFromSearch(search) { function getUrlFromSearch(search) {
@ -520,6 +523,22 @@ $(document).ready(function() {
return null; return null;
} }
function getParamsFromSearch(search) {
var map = {};
try {
search
.split('?')[1]
.split('&')
.map(function(e) {
var values = e.split('=');
map[values[0]] = values[1];
});
} catch (_ignore) {
}
return map;
}
function bind() { function bind() {
$('#url-btn').click(function(e) { $('#url-btn').click(function(e) {
e.preventDefault(); e.preventDefault();
@ -588,13 +607,13 @@ $(document).ready(function() {
}; };
} }
function smartDraw(urlOpt) { function smartDraw(urlOpt, forced) {
var url = urlOpt || $url.val(); var url = urlOpt || $url.val();
var req = prepareUrl(url); var req = prepareUrl(url);
draw(req); draw(req, forced);
} }
function draw(req) { function draw(req, forced) {
if (!validateUrl(req.url)) { if (!validateUrl(req.url)) {
console.error('Invalid url provided!'); console.error('Invalid url provided!');
return; return;
@ -605,7 +624,7 @@ $(document).ready(function() {
var outputFormat = $outputFormat.val(); var outputFormat = $outputFormat.val();
var showFiles = $showFiles.is(':checked'); var showFiles = $showFiles.is(':checked');
var matching = $matching.val(); var matching = $matching.val();
var wordThreshold = $wordThreshold.val(); var wordsThreshold = $wordsThreshold.val();
var matchingMaxComparisons = $matchingMaxComparisons.val(); var matchingMaxComparisons = $matchingMaxComparisons.val();
fetch(req.url, { fetch(req.url, {
@ -627,16 +646,34 @@ $(document).ready(function() {
$container.css({'width': ''}); $container.css({'width': ''});
} }
diff2htmlUi.draw(container, { var params = getParamsFromSearch(window.location.search);
outputFormat: outputFormat, delete params[searchParam];
showFiles: showFiles,
matching: matching, if (forced) {
matchWordsThreshold: wordThreshold, params['outputFormat'] = outputFormat;
matchingMaxComparisons: matchingMaxComparisons, params['showFiles'] = showFiles;
synchronisedScroll: true params['matching'] = matching;
}); params['wordsThreshold'] = wordsThreshold;
diff2htmlUi.fileListCloseable(container, false); params['matchingMaxComparisons'] = matchingMaxComparisons;
diff2htmlUi.highlightCode(container); } else {
params['outputFormat'] = params['outputFormat'] || outputFormat;
params['showFiles'] = String(params['showFiles']) !== 'false' || (params['showFiles'] === null && showFiles);
params['matching'] = params['matching'] || matching;
params['wordsThreshold'] = params['wordsThreshold'] || wordsThreshold;
params['matchingMaxComparisons'] = params['matchingMaxComparisons'] || matchingMaxComparisons;
$outputFormat.val(params['outputFormat']);
$showFiles.prop('checked', params['showFiles']);
$matching.val(params['matching']);
$wordsThreshold.val(params['wordsThreshold']);
$matchingMaxComparisons.val(params['matchingMaxComparisons']);
}
params['synchronisedScroll'] = params['synchronisedScroll'] || true;
diff2htmlUi.draw(container, params);
diff2htmlUi.fileListCloseable(container, params['fileListCloseable'] || false);
params['highlight'] && diff2htmlUi.highlightCode(container);
}); });
} }
@ -645,11 +682,15 @@ $(document).ready(function() {
} }
function updateUrl(url) { function updateUrl(url) {
var currentUrl = getUrlFromSearch(window.location.search); var params = getParamsFromSearch(window.location.search);
if (currentUrl === url) return; if (params[searchParam] === url) return;
window.location = 'demo.html?' + searchParam + '=' + url; params[searchParam] = url;
var paramString = Object.keys(params).map(function(k) { return k + '=' + params[k]; }).join('&');
window.location = 'demo.html?' + paramString;
} }
}); });

2
docs/demo.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "diff2html", "name": "diff2html",
"version": "2.3.1", "version": "2.3.2",
"homepage": "https://diff2html.xyz", "homepage": "https://diff2html.xyz",
"description": "Fast Diff to colorized HTML", "description": "Fast Diff to colorized HTML",
"keywords": [ "keywords": [