- gitlist.git
- public
- web-worker
- commit-diff.js
This file ( 1kB ) exceeds the allowed full mode (48 kb) size.
The editor full hight is disabled, only scrolling is allowed..
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height
mode, although some users like it.
const showNumber = (lineInfo) => {
const first = lineInfo.line[0];
return first === ' ' || first === '@' || first === '-' || first === '+';
}
let htmlEncode
const construct = (data) => {
const diffs = data.diffs
for(let diffLineIndex in diffs.lines) {
diffs.lines[diffLineIndex].line = htmlEncode(diffs.lines[diffLineIndex].line)
}
let result = `
<table id="p3x-gitlist-commit-diff-ng-table" style="min-width: 100%; max-width: 100%">
<tr>
<td class="lineNo">Old</td>
<td class="lineNo"> </td>
<td class="old">${diffs.old}</td>
</tr>
<tr>
<td class="lineNo"> </td>
<td class="lineNo">New</td>
<td class="new">${diffs.new}</td>
</tr>
`
for(let lineInfo of diffs.lines) {
result += `
<tr>
<td class="lineNo">
${showNumber(lineInfo) ? lineInfo['num-old'] : ' '}
</td>
<td class="lineNo">
${showNumber(lineInfo) ? lineInfo['num-new'] : ' '}
</td>
<td style="width: 100%">
<pre class="${lineInfo.type}">${lineInfo.line}</pre>
</td>
</tr>
`
}
result += `
</table>
`
return result;
}
onmessage = function(e) {
eval(`htmlEncode = ${e.data.htmlEncode}`)
const result = construct(e.data);
postMessage(result)
}