').append(welUl));
}
function _onClickCommentBoxToggleBtn(weEvt) {
var welCommentTr = $(this).closest('tr');
var welCodeTr = welCommentTr.prev('tr');
var welPath = welCodeTr.closest('table');
var sType = $(this).data('type');
if(sType=='open') {
_showCommentBox(welCommentTr,welPath.data('filePath'),welCodeTr.data('line'),welCodeTr.data('type'));
$(this).data('type','close').text(Messages("code.closeCommentBox"));
} else {
_hideCommentBox();
$(this).data('type','open').text(Messages("code.openCommentBox"));
}
}
function _hideCommentBox() {
htElement.welCommentTr.remove();
htElement.welEmptyCommentForm.find('[name=path]').removeAttr('value');
htElement.welEmptyCommentForm.find('[name=line]').removeAttr('value');
htElement.welEmptyCommentForm.find('[name=side]').removeAttr('value');
htElement.welComments.after(htElement.welEmptyCommentForm);
_updateMiniMap();
}
/**
* @param {Event} weEvt
*/
function _onClickLineNumA(weEvt) {
var commentForm =
$(weEvt.target).closest('tr').next().find('#comment-form');
if (commentForm.length > 0) {
_hideCommentBox();
} else {
var welRow = $(this).closest('tr');
var welPath = welRow.closest('table');
if(welRow.data('type')=='add' || welRow.data('type')=='context' || welRow.data('type')=='remove') {
_showCommentBox(welRow, welPath.data('filePath'), welRow.data('line'),welRow.data('type'));
}
}
}
/**
* @param {Object} welTr
* @param {Object} welUl
*/
function _createCommentThreadOnLine(welTr,sPath) {
var waComments = htElement.welComments.children('li.comment');
var welUl = $('
',{class:'comments'});
var nLinenum = welTr.data('line');
var sSide = (welTr.data('type') == 'remove') ? 'A' : 'B';
for(var i = 0; i < waComments.length; i++) {
var welComment = $(waComments[i]);
if (sPath == welComment.data('path')
&& nLinenum == welComment.data('line')
&& sSide == welComment.data('side')) {
welUl.append(welComment);
}
}
return welUl;
}
/**
* @param {Object} welTr
*/
function _showCommentBox(welTr,sPath,nLine,sType) {
var welTd = $("
",{class:'diff-comment-box',colspan:3});
var welCommentTr;
var sSide = (sType == 'remove') ? 'A' : 'B';
if (htElement.welCommentTr) {
htElement.welCommentTr.remove();
}
htElement.welCommentTr = $("
")
.append(welTd.append(htElement.welEmptyCommentForm));
welCommentTr = htElement.welCommentTr;
welCommentTr.find('[name="path"]').val(sPath);
welCommentTr.find('[name="line"]').val(nLine);
welCommentTr.find('[name="side"]').val(sSide);
welTr.after(htElement.welCommentTr);
_updateMiniMap();
}
/**
* @param {String} sDiff
* @return {Object} 렌더링한 결과로 만들어진 HTML 테이블
*/
function _renderDiff(sDiff) {
var rxDiff = /^Index: [\S]+\n[=]+\n/igm;
var aMatchDiff = sDiff.match(rxDiff);
var aDiffPath = sDiff.split(rxDiff).slice(1);
var rxHunkHeader = /@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/;
var rxFileHeader = /^(---|\+\+\+) (.+)\t[^\t]+$/; // http://en.wikipedia.org/wiki/Diff#Unified_format
var sPath;
aDiffPath.forEach(function(sDiffRow,nIndex){
var welDiffWrapOuter = $('',{class:'diff-partial-outer'});
var welDiffWrapInner = $('',{class:'diff-partial-inner'});
var welDiffMeta = $('',{class:'diff-partial-meta'});
var welDiffMetaCommit = $('',{class:'diff-partial-commit'});
var welDiffMetaFile = $('',{class:'diff-partial-file'});
var welDiffCodeWrap = $('',{class:'diff-partial-code'});
var welDiffCodeTable = $('
',{class:'diff-container show-comments'});
var welDiffCodeTableBody = $('
');
var aLine = sDiffRow.split('\n').slice(0,-1);
var sPath;
var nLineA=1;
var nLineB=1;
var nLastLineA=1;
var nLastLineB=1;
var nCodeLineA;
var nCodeLineB;
if(aLine[0].indexOf('file marked as a binary type') !==-1) {
var sDiffIndex = aMatchDiff[nIndex].split('\n')[0];
var welLineA = $('