User:Cacycle/diff.js: Difference between revisions

Content deleted Content added
1.0.4 (August 26, 2014) sort blocks moved from block by old number
1.0.5 (August 26, 2014) fix fragment marks (maxWords), fullDiff support
Line 2:
 
// @name wDiff
// @version 1.0.45
// @date August 26, 2014
// @description improved word-based diff library with block move detection
Line 1,888:
 
// moved block too small, make it a deletion at its original position
if ( (groups[movedGroup].wordsmaxWords < wDiff.blockMinLength) || (wDiff.showBlockMoves == false) ) {
mark = wDiff.htmlDeleteStart + wDiff.HtmlEscape(movedText) + wDiff.htmlDeleteEnd;
}
Line 1,994:
text.diff = text.diff.replace(/<\/(\w+)><!--wDiff(Delete|Insert)--><\1\b[^>]*\bclass="wDiff\2"[^>]*>/g, '');
text.diff = text.diff.replace(/\t/g, wDiff.htmlTab);
text.diff = wDiff.htmlContainerStart + wDiff.htmlFragmentStart + text.diff + wDiff.htmlFragmentEnd + wDiff.htmlContainerEnd;
return;
};
Line 2,013:
 
// remove container by non-regExp replace
diffhtml = diffhtml.replace(wDiff.htmlContainerStart, '');
diffhtml = diffhtml.replace(wDiff.htmlContainerEndhtmlFragmentStart, '');
html = html.replace(wDiff.htmlFragmentEnd, '');
 
html = html.replace(wDiff.htmlContainerEnd, '')
// scan for diff html tags
var regExpDiff = /<\w+\b[^>]*\bclass="wDiff(MarkLeft|MarkRight|BlockLeft|BlockRight|Delete|Insert)"[^>]*>(.|\n)*?<!--wDiff\1-->/g;
Line 2,304 ⟶ 2,306:
 
wDiff.DebugGroups = function(groups) {
var dump = '\ni \tblSta \tblEnd \tmWord \twords \tchars \tfixed \oldNm \tmoved \tmFrom \tcolor \tmoved \tdiff\n';
for (var i = 0; i < groups.length; i ++) {
dump += i + ' \t' + groups[i].blockStart + ' \t' + groups[i].blockEnd + ' \t' + groups[i].maxWords + ' \t' + groups[i].words + ' \t' + groups[i].chars + ' \t' + groups[i].fixed + ' \t' + groups[i].oldNumber + ' \t' + groups[i].moved.toString()movedFrom + ' \t' + groups[i].movedFromcolor + ' \t' + groups[i].colormoved.toString() + ' \t' + wDiff.DebugShortenString(groups[i].diff) + '\n';
}
return dump;