Fix repeated variable name in same scope (thanks Codacy)
This commit is contained in:
parent
9205e5e0a1
commit
f4ff89302a
8 changed files with 39 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.0-beta3",
|
"version": "2.0.0-beta5",
|
||||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
7
dist/diff2html-ui.js
vendored
7
dist/diff2html-ui.js
vendored
|
|
@ -126,9 +126,14 @@
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
||||||
var $target;
|
var $target;
|
||||||
if (targetId) {
|
|
||||||
|
if (targetId instanceof jQuery) {
|
||||||
|
$target = targetId;
|
||||||
|
} else if (typeof(targetId) === 'string') {
|
||||||
$target = $(targetId);
|
$target = $(targetId);
|
||||||
} else {
|
} else {
|
||||||
|
console.error("Wrong target provided! Falling back to default value 'body'.");
|
||||||
|
console.log("Please provide a jQuery object or a valid DOM query string.");
|
||||||
$target = $(defaultTarget);
|
$target = $(defaultTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
dist/diff2html-ui.min.js
vendored
2
dist/diff2html-ui.min.js
vendored
|
|
@ -1 +1 @@
|
||||||
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json)}var diffJson=null,defaultTarget="body";Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg))},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),hashTag=this._getHashTag(),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");"files-summary-show"===hashTag?show():"files-summary-hide"===hashTag?hide():startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,$target=that._getTarget(targetId),languages=that._getLanguages($target);hljs.configure({languages:languages});var $codeLines=$target.find(".d2h-code-line-ctn");$codeLines.map(function(i,line){hljs.highlightBlock(line)})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return $target=$(targetId?targetId:defaultTarget)},Diff2HtmlUI.prototype._getLanguages=function($target){var allFileLanguages=[];return diffJson?allFileLanguages=diffJson.map(function(line){return line.language}):$target.find(".d2h-file-wrapper").map(function(i,file){allFileLanguages.push($(file).data("lang"))}),this._distinct(allFileLanguages)},Diff2HtmlUI.prototype._getHashTag=function(){var docUrl=document.URL,hashTagIndex=docUrl.indexOf("#"),hashTag=null;return-1!==hashTagIndex&&(hashTag=docUrl.substr(hashTagIndex+1)),hashTag},Diff2HtmlUI.prototype._distinct=function(collection){return collection.filter(function(v,i){return collection.indexOf(v)===i})},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(exports,function(){return this}())}]);
|
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json)}var diffJson=null,defaultTarget="body";Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg))},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),hashTag=this._getHashTag(),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");"files-summary-show"===hashTag?show():"files-summary-hide"===hashTag?hide():startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,$target=that._getTarget(targetId),languages=that._getLanguages($target);hljs.configure({languages:languages});var $codeLines=$target.find(".d2h-code-line-ctn");$codeLines.map(function(i,line){hljs.highlightBlock(line)})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return targetId instanceof jQuery?$target=targetId:"string"==typeof targetId?$target=$(targetId):(console.error("Wrong target provided! Falling back to default value 'body'."),console.log("Please provide a jQuery object or a valid DOM query string."),$target=$(defaultTarget)),$target},Diff2HtmlUI.prototype._getLanguages=function($target){var allFileLanguages=[];return diffJson?allFileLanguages=diffJson.map(function(line){return line.language}):$target.find(".d2h-file-wrapper").map(function(i,file){allFileLanguages.push($(file).data("lang"))}),this._distinct(allFileLanguages)},Diff2HtmlUI.prototype._getHashTag=function(){var docUrl=document.URL,hashTagIndex=docUrl.indexOf("#"),hashTag=null;return-1!==hashTagIndex&&(hashTag=docUrl.substr(hashTagIndex+1)),hashTag},Diff2HtmlUI.prototype._distinct=function(collection){return collection.filter(function(v,i){return collection.indexOf(v)===i})},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(exports,function(){return this}())}]);
|
||||||
24
dist/diff2html.js
vendored
24
dist/diff2html.js
vendored
|
|
@ -325,10 +325,10 @@
|
||||||
if (utils.startsWith(line, 'diff')) {
|
if (utils.startsWith(line, 'diff')) {
|
||||||
startFile();
|
startFile();
|
||||||
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) {
|
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) {
|
||||||
currentFile.oldName = values[1];
|
currentFile.oldName = values;
|
||||||
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
||||||
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) {
|
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) {
|
||||||
currentFile.newName = values[1];
|
currentFile.newName = values;
|
||||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||||
} else if (currentFile && utils.startsWith(line, '@@')) {
|
} else if (currentFile && utils.startsWith(line, '@@')) {
|
||||||
startBlock(line);
|
startBlock(line);
|
||||||
|
|
@ -391,7 +391,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSrcFilename(line, cfg) {
|
function getSrcFilename(line, cfg) {
|
||||||
var prefixes = ["a\\/", "i\\/", "w\\/", "c\\/", "o\\/"];
|
var prefixes = ["a/", "i/", "w/", "c/", "o/"];
|
||||||
|
|
||||||
if (cfg.srcPrefix) prefixes.push(cfg.srcPrefix);
|
if (cfg.srcPrefix) prefixes.push(cfg.srcPrefix);
|
||||||
|
|
||||||
|
|
@ -399,7 +399,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDstFilename(line, cfg) {
|
function getDstFilename(line, cfg) {
|
||||||
var prefixes = ["b\\/", "i\\/", "w\\/", "c\\/", "o\\/"];
|
var prefixes = ["b/", "i/", "w/", "c/", "o/"];
|
||||||
|
|
||||||
if (cfg.dstPrefix) prefixes.push(cfg.dstPrefix);
|
if (cfg.dstPrefix) prefixes.push(cfg.dstPrefix);
|
||||||
|
|
||||||
|
|
@ -407,8 +407,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getFilename(linePrefix, line, prefixes) {
|
function _getFilename(linePrefix, line, prefixes) {
|
||||||
var prefixesStr = prefixes.join("|");
|
var FilenameRegExp = new RegExp('^' + linePrefix + ' "?(.+?)"?$');
|
||||||
return new RegExp('^' + linePrefix + ' "?(?:' + prefixesStr + ')(.+?)"?$').exec(line);
|
|
||||||
|
var filename;
|
||||||
|
var values = FilenameRegExp.exec(line);
|
||||||
|
if (values && values[1]) {
|
||||||
|
filename = values[1];
|
||||||
|
var matchingPrefixes = prefixes.filter(function(p) {
|
||||||
|
return filename.indexOf(p) === 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (matchingPrefixes[0]) filename = filename.slice(matchingPrefixes[0].length); // remove prefix if exists
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.DiffParser = new DiffParser();
|
module.exports.DiffParser = new DiffParser();
|
||||||
|
|
|
||||||
7
dist/diff2html.min.js
vendored
7
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.0-beta3",
|
"version": "2.0.0-beta5",
|
||||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
|
|
@ -249,11 +249,11 @@
|
||||||
var values = FilenameRegExp.exec(line);
|
var values = FilenameRegExp.exec(line);
|
||||||
if (values && values[1]) {
|
if (values && values[1]) {
|
||||||
filename = values[1];
|
filename = values[1];
|
||||||
var prefix = prefixes.find(function(prefix) {
|
var matchingPrefixes = prefixes.filter(function(p) {
|
||||||
return filename.startsWith(prefix);
|
return filename.indexOf(p) === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (prefix) filename = filename.slice(prefix.length); // remove prefix if exists
|
if (matchingPrefixes[0]) filename = filename.slice(matchingPrefixes[0].length); // remove prefix if exists
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,14 @@
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
||||||
var $target;
|
var $target;
|
||||||
if (targetId) {
|
|
||||||
|
if (targetId instanceof jQuery) {
|
||||||
|
$target = targetId;
|
||||||
|
} else if (typeof(targetId) === 'string') {
|
||||||
$target = $(targetId);
|
$target = $(targetId);
|
||||||
} else {
|
} else {
|
||||||
|
console.error("Wrong target provided! Falling back to default value 'body'.");
|
||||||
|
console.log("Please provide a jQuery object or a valid DOM query string.");
|
||||||
$target = $(defaultTarget);
|
$target = $(defaultTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue