Update for hogan.js
This commit is contained in:
parent
48113523e4
commit
edd5a8fb5c
8 changed files with 3825 additions and 5906 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -19,5 +19,8 @@ target/
|
||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
|
# Istanbul
|
||||||
|
coverage/
|
||||||
|
|
||||||
# Bower
|
# Bower
|
||||||
bower_components/
|
bower_components/
|
||||||
|
|
|
||||||
|
|
@ -1,170 +0,0 @@
|
||||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/column-line-number.html"] = (function() {
|
|
||||||
function root(env, context, frame, runtime, cb) {
|
|
||||||
var lineno = null;
|
|
||||||
var colno = null;
|
|
||||||
var output = "";
|
|
||||||
try {
|
|
||||||
var parentTemplate = null;
|
|
||||||
output += "<tr>\n <td class=\"d2h-code-linenumber ";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
|
||||||
output += "\"></td>\n <td class=\"";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
|
||||||
output += "\">\n <div class=\"d2h-code-line ";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
|
||||||
output += "\"> ";
|
|
||||||
output += runtime.suppressValue((lineno = 3, colno = 77, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"escape"), "utils[\"escape\"]", context, [runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "block")),"header")])), env.opts.autoescape);
|
|
||||||
output += "</div>\n </td>\n</tr>\n";
|
|
||||||
if(parentTemplate) {
|
|
||||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
||||||
} else {
|
|
||||||
cb(null, output);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
} catch (e) {
|
|
||||||
cb(runtime.handleError(e, lineno, colno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
root: root
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
})();
|
|
||||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/empty-diff.html"] = (function() {
|
|
||||||
function root(env, context, frame, runtime, cb) {
|
|
||||||
var lineno = null;
|
|
||||||
var colno = null;
|
|
||||||
var output = "";
|
|
||||||
try {
|
|
||||||
var parentTemplate = null;
|
|
||||||
output += "<tr>\n <td class=\"";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
|
||||||
output += "\">\n <div class=\"d2h-code-line ";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
|
||||||
output += "\">\n File without changes\n </div>\n </td>\n</tr>\n";
|
|
||||||
if(parentTemplate) {
|
|
||||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
||||||
} else {
|
|
||||||
cb(null, output);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
} catch (e) {
|
|
||||||
cb(runtime.handleError(e, lineno, colno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
root: root
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
})();
|
|
||||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/file-diff.html"] = (function() {
|
|
||||||
function root(env, context, frame, runtime, cb) {
|
|
||||||
var lineno = null;
|
|
||||||
var colno = null;
|
|
||||||
var output = "";
|
|
||||||
try {
|
|
||||||
var parentTemplate = null;
|
|
||||||
output += "<div id=\"";
|
|
||||||
output += runtime.suppressValue((lineno = 0, colno = 32, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "printerUtils")),"getHtmlId"), "printerUtils[\"getHtmlId\"]", context, [runtime.contextOrFrameLookup(context, frame, "file")])), env.opts.autoescape);
|
|
||||||
output += "\" class=\"d2h-file-wrapper\" data-lang=\"";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"language"), env.opts.autoescape);
|
|
||||||
output += "\">\n <div class=\"d2h-file-header\">\n <span class=\"d2h-file-stats\">\n <span class=\"d2h-lines-added\">\n <span>+";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"addedLines"), env.opts.autoescape);
|
|
||||||
output += "</span>\n </span>\n <span class=\"d2h-lines-deleted\">\n <span>-";
|
|
||||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"deletedLines"), env.opts.autoescape);
|
|
||||||
output += "</span>\n </span>\n </span>\n <span class=\"d2h-file-name-wrapper\">\n <span class=\"d2h-file-name\"> ";
|
|
||||||
output += runtime.suppressValue((lineno = 11, colno = 67, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "printerUtils")),"getDiffName"), "printerUtils[\"getDiffNam\"]", context, [runtime.contextOrFrameLookup(context, frame, "file")])), env.opts.autoescape);
|
|
||||||
output += "</span>\n </span>\n </div>\n <div class=\"d2h-file-diff\">\n <div class=\"d2h-code-wrapper\">\n <table class=\"d2h-diff-table\">\n <tbody class=\"d2h-diff-tbody\">\n ";
|
|
||||||
output += runtime.suppressValue(env.getFilter("safe").call(context, runtime.contextOrFrameLookup(context, frame, "diffs")), env.opts.autoescape);
|
|
||||||
output += "\n </tbody>\n </table>\n </div>\n </div>\n</div>\n";
|
|
||||||
if(parentTemplate) {
|
|
||||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
||||||
} else {
|
|
||||||
cb(null, output);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
} catch (e) {
|
|
||||||
cb(runtime.handleError(e, lineno, colno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
root: root
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
})();
|
|
||||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/line.html"] = (function() {
|
|
||||||
function root(env, context, frame, runtime, cb) {
|
|
||||||
var lineno = null;
|
|
||||||
var colno = null;
|
|
||||||
var output = "";
|
|
||||||
try {
|
|
||||||
var parentTemplate = null;
|
|
||||||
output += "<tr>\n <td class=\"d2h-code-linenumber ";
|
|
||||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
|
||||||
output += "\">\n <div class=\"line-num1\">";
|
|
||||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 2, colno = 50, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"valueOrEmpty"), "utils[\"valueOrEmp\"]", context, [runtime.contextOrFrameLookup(context, frame, "oldNumber")]))), env.opts.autoescape);
|
|
||||||
output += "</div>\n <div class=\"line-num2\">";
|
|
||||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 3, colno = 50, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"valueOrEmpty"), "utils[\"valueOrEmp\"]", context, [runtime.contextOrFrameLookup(context, frame, "newNumber")]))), env.opts.autoescape);
|
|
||||||
output += "</div>\n </td>\n <td class=\"";
|
|
||||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
|
||||||
output += "\">\n <div class=\"d2h-code-line ";
|
|
||||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
|
||||||
output += "\">";
|
|
||||||
if(runtime.contextOrFrameLookup(context, frame, "prefix")) {
|
|
||||||
output += "\n <span class=\"d2h-code-line-prefix\">";
|
|
||||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 8, colno = 89, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"convertWhiteSpaceToNonBreakingSpace"), "utils[\"convertWhi\"]", context, [runtime.contextOrFrameLookup(context, frame, "prefix")]))), env.opts.autoescape);
|
|
||||||
output += "</span>\n ";
|
|
||||||
;
|
|
||||||
}
|
|
||||||
if(runtime.contextOrFrameLookup(context, frame, "content")) {
|
|
||||||
output += "<span class=\"d2h-code-line-ctn\">";
|
|
||||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 11, colno = 86, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"convertWhiteSpaceToNonBreakingSpace"), "utils[\"convertWhi\"]", context, [runtime.contextOrFrameLookup(context, frame, "content")]))), env.opts.autoescape);
|
|
||||||
output += "</span>";
|
|
||||||
;
|
|
||||||
}
|
|
||||||
output += "\n </div>\n </td>\n</tr>\n";
|
|
||||||
if(parentTemplate) {
|
|
||||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
||||||
} else {
|
|
||||||
cb(null, output);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
} catch (e) {
|
|
||||||
cb(runtime.handleError(e, lineno, colno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
root: root
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
})();
|
|
||||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/wrapper.html"] = (function() {
|
|
||||||
function root(env, context, frame, runtime, cb) {
|
|
||||||
var lineno = null;
|
|
||||||
var colno = null;
|
|
||||||
var output = "";
|
|
||||||
try {
|
|
||||||
var parentTemplate = null;
|
|
||||||
output += "<div class=\"d2h-wrapper\">\n ";
|
|
||||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "content"), env.opts.autoescape);
|
|
||||||
output += "\n</div>\n";
|
|
||||||
if(parentTemplate) {
|
|
||||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
|
||||||
} else {
|
|
||||||
cb(null, output);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
} catch (e) {
|
|
||||||
cb(runtime.handleError(e, lineno, colno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
root: root
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
})();
|
|
||||||
|
|
||||||
1
diff2html-templates.min.js
vendored
1
diff2html-templates.min.js
vendored
File diff suppressed because one or more lines are too long
268
diff2html-ui.js
268
diff2html-ui.js
|
|
@ -1,189 +1,143 @@
|
||||||
/******/ (function(modules) { // webpackBootstrap
|
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||||
/******/ // The module cache
|
(function (global){
|
||||||
/******/ var installedModules = {};
|
/*
|
||||||
|
*
|
||||||
|
* Diff to HTML (diff2html-ui.js)
|
||||||
|
* Author: rtfpessoa
|
||||||
|
*
|
||||||
|
* Depends on: [ jQuery ]
|
||||||
|
* Optional dependencies on: [ highlight.js ]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/******/ // The require function
|
/*global $, hljs*/
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
|
|
||||||
/******/ // Check if module is in cache
|
(function() {
|
||||||
/******/ if(installedModules[moduleId])
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
|
||||||
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
var diffJson = null;
|
||||||
/******/ var module = installedModules[moduleId] = {
|
var defaultTarget = "body";
|
||||||
/******/ exports: {},
|
|
||||||
/******/ id: moduleId,
|
|
||||||
/******/ loaded: false
|
|
||||||
/******/ };
|
|
||||||
|
|
||||||
/******/ // Execute the module function
|
function Diff2HtmlUI(config) {
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
var cfg = config || {};
|
||||||
|
|
||||||
/******/ // Flag the module as loaded
|
if (cfg.diff) {
|
||||||
/******/ module.loaded = true;
|
diffJson = Diff2Html.getJsonFromDiff(cfg.diff);
|
||||||
|
} else if (cfg.json) {
|
||||||
|
diffJson = cfg.json;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******/ // Return the exports of the module
|
Diff2HtmlUI.prototype.draw = function(targetId, config) {
|
||||||
/******/ return module.exports;
|
var cfg = config || {};
|
||||||
/******/ }
|
var $target = this._getTarget(targetId);
|
||||||
|
$target.html(Diff2Html.getPrettyHtml(diffJson, cfg));
|
||||||
|
};
|
||||||
|
|
||||||
|
Diff2HtmlUI.prototype.fileListCloseable = function(targetId, startVisible) {
|
||||||
|
var $target = this._getTarget(targetId);
|
||||||
|
|
||||||
/******/ // expose the modules object (__webpack_modules__)
|
var hashTag = this._getHashTag();
|
||||||
/******/ __webpack_require__.m = modules;
|
|
||||||
|
|
||||||
/******/ // expose the module cache
|
var $showBtn = $target.find(".d2h-show");
|
||||||
/******/ __webpack_require__.c = installedModules;
|
var $hideBtn = $target.find(".d2h-hide");
|
||||||
|
var $fileList = $target.find(".d2h-file-list");
|
||||||
|
|
||||||
/******/ // __webpack_public_path__
|
if (hashTag === 'files-summary-show') show();
|
||||||
/******/ __webpack_require__.p = "";
|
else if (hashTag === 'files-summary-hide') hide();
|
||||||
|
else if (startVisible) show();
|
||||||
|
else hide();
|
||||||
|
|
||||||
/******/ // Load entry module and return exports
|
$showBtn.click(show);
|
||||||
/******/ return __webpack_require__(0);
|
$hideBtn.click(hide);
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ([
|
|
||||||
/* 0 */
|
|
||||||
/***/ function(module, exports) {
|
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(global) {/*
|
function show() {
|
||||||
*
|
$showBtn.hide();
|
||||||
* Diff to HTML (diff2html-ui.js)
|
$hideBtn.show();
|
||||||
* Author: rtfpessoa
|
$fileList.show();
|
||||||
*
|
}
|
||||||
* Depends on: [ jQuery ]
|
|
||||||
* Optional dependencies on: [ highlight.js ]
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*global $, hljs*/
|
function hide() {
|
||||||
|
$hideBtn.hide();
|
||||||
|
$showBtn.show();
|
||||||
|
$fileList.hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
(function() {
|
Diff2HtmlUI.prototype.highlightCode = function(targetId) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
var diffJson = null;
|
var $target = that._getTarget(targetId);
|
||||||
var defaultTarget = "body";
|
|
||||||
|
|
||||||
function Diff2HtmlUI(config) {
|
var languages = that._getLanguages($target);
|
||||||
var cfg = config || {};
|
|
||||||
|
|
||||||
if (cfg.diff) {
|
// pass the languages to the highlightjs plugin
|
||||||
diffJson = Diff2Html.getJsonFromDiff(cfg.diff);
|
hljs.configure({languages: languages});
|
||||||
} else if (cfg.json) {
|
|
||||||
diffJson = cfg.json;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype.draw = function(targetId, config) {
|
// collect all the code lines and execute the highlight on them
|
||||||
var cfg = config || {};
|
var $codeLines = $target.find(".d2h-code-line-ctn");
|
||||||
var $target = this._getTarget(targetId);
|
$codeLines.map(function(i, line) {
|
||||||
$target.html(Diff2Html.getPrettyHtml(diffJson, cfg));
|
hljs.highlightBlock(line);
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Diff2HtmlUI.prototype.fileListCloseable = function(targetId, startVisible) {
|
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
||||||
var $target = this._getTarget(targetId);
|
var $target;
|
||||||
|
|
||||||
var hashTag = this._getHashTag();
|
if (typeof targetId === 'object' && targetId instanceof jQuery) {
|
||||||
|
$target = targetId;
|
||||||
|
} else if (typeof targetId === 'string') {
|
||||||
|
$target = $(targetId);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
|
||||||
var $showBtn = $target.find(".d2h-show");
|
return $target;
|
||||||
var $hideBtn = $target.find(".d2h-hide");
|
};
|
||||||
var $fileList = $target.find(".d2h-file-list");
|
|
||||||
|
|
||||||
if (hashTag === 'files-summary-show') show();
|
Diff2HtmlUI.prototype._getLanguages = function($target) {
|
||||||
else if (hashTag === 'files-summary-hide') hide();
|
var allFileLanguages = [];
|
||||||
else if (startVisible) show();
|
|
||||||
else hide();
|
|
||||||
|
|
||||||
$showBtn.click(show);
|
if (diffJson) {
|
||||||
$hideBtn.click(hide);
|
// collect all the file extensions in the json
|
||||||
|
allFileLanguages = diffJson.map(function(line) {
|
||||||
|
return line.language;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$target.find(".d2h-file-wrapper").map(function(i, file) {
|
||||||
|
allFileLanguages.push($(file).data("lang"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function show() {
|
// return only distinct languages
|
||||||
$showBtn.hide();
|
return this._distinct(allFileLanguages);
|
||||||
$hideBtn.show();
|
};
|
||||||
$fileList.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide() {
|
Diff2HtmlUI.prototype._getHashTag = function() {
|
||||||
$hideBtn.hide();
|
var docUrl = document.URL;
|
||||||
$showBtn.show();
|
var hashTagIndex = docUrl.indexOf('#');
|
||||||
$fileList.hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype.highlightCode = function(targetId) {
|
var hashTag = null;
|
||||||
var that = this;
|
if (hashTagIndex !== -1) {
|
||||||
|
hashTag = docUrl.substr(hashTagIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
var $target = that._getTarget(targetId);
|
return hashTag;
|
||||||
|
};
|
||||||
|
|
||||||
var languages = that._getLanguages($target);
|
Diff2HtmlUI.prototype._distinct = function(collection) {
|
||||||
|
return collection.filter(function(v, i) {
|
||||||
|
return collection.indexOf(v) === i;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// pass the languages to the highlightjs plugin
|
module.exports.Diff2HtmlUI = Diff2HtmlUI;
|
||||||
hljs.configure({languages: languages});
|
|
||||||
|
|
||||||
// collect all the code lines and execute the highlight on them
|
// Expose diff2html in the browser
|
||||||
var $codeLines = $target.find(".d2h-code-line-ctn");
|
global.Diff2HtmlUI = Diff2HtmlUI;
|
||||||
$codeLines.map(function(i, line) {
|
|
||||||
hljs.highlightBlock(line);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getTarget = function(targetId) {
|
})();
|
||||||
var $target;
|
|
||||||
|
|
||||||
if (typeof(targetId) === 'object' && targetId instanceof jQuery) {
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||||
$target = targetId;
|
},{}]},{},[1]);
|
||||||
} else if (typeof(targetId) === 'string') {
|
|
||||||
$target = $(targetId);
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $target;
|
|
||||||
};
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getLanguages = function($target) {
|
|
||||||
var allFileLanguages = [];
|
|
||||||
|
|
||||||
if (diffJson) {
|
|
||||||
// collect all the file extensions in the json
|
|
||||||
allFileLanguages = diffJson.map(function(line) {
|
|
||||||
return line.language;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$target.find(".d2h-file-wrapper").map(function(i, file) {
|
|
||||||
allFileLanguages.push($(file).data("lang"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// return only distinct languages
|
|
||||||
return this._distinct(allFileLanguages);
|
|
||||||
};
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._getHashTag = function() {
|
|
||||||
var docUrl = document.URL;
|
|
||||||
var hashTagIndex = docUrl.indexOf('#');
|
|
||||||
|
|
||||||
var hashTag = null;
|
|
||||||
if (hashTagIndex !== -1) {
|
|
||||||
hashTag = docUrl.substr(hashTagIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashTag;
|
|
||||||
};
|
|
||||||
|
|
||||||
Diff2HtmlUI.prototype._distinct = function(collection) {
|
|
||||||
return collection.filter(function(v, i) {
|
|
||||||
return collection.indexOf(v) === i;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.Diff2HtmlUI = Diff2HtmlUI;
|
|
||||||
|
|
||||||
// Expose diff2html in the browser
|
|
||||||
global.Diff2HtmlUI = Diff2HtmlUI;
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
|
||||||
|
|
||||||
/***/ }
|
|
||||||
/******/ ]);
|
|
||||||
|
|
|
||||||
2
diff2html-ui.min.js
vendored
2
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"object"==typeof targetId&&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}())}]);
|
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){(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"object"==typeof targetId&&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(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);
|
||||||
9270
diff2html.js
9270
diff2html.js
File diff suppressed because one or more lines are too long
8
diff2html.min.js
vendored
8
diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -9,16 +9,15 @@
|
||||||
Author: rtfpessoa
|
Author: rtfpessoa
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/github.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/github.min.css">
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
|
<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.1.0/highlight.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/scala.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/languages/scala.min.js"></script>
|
||||||
|
|
||||||
<!-- diff2html -->
|
<!-- diff2html -->
|
||||||
<link rel="stylesheet" type="text/css" href="diff2html.css">
|
<link rel="stylesheet" type="text/css" href="diff2html.css">
|
||||||
<script type="text/javascript" src="diff2html-templates.js"></script>
|
|
||||||
<script type="text/javascript" src="diff2html.js"></script>
|
<script type="text/javascript" src="diff2html.js"></script>
|
||||||
<script type="text/javascript" src="diff2html-ui.js"></script>
|
<script type="text/javascript" src="diff2html-ui.js"></script>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue