Sha256: 3a4588082cf9812931819a25811c94bd41ef004b873d28e355c2b77ff479d1bf
Contents?: true
Size: 921 Bytes
Versions: 92
Compression:
Stored size: 921 Bytes
Contents
/* global JsDiff */ $(() => { $(".diff-i18n_html, .diff-i18n").each(function(_index, element) { const diffElement = $(element); const valueElement = diffElement.find(".diff__value"); const oldValue = valueElement.data("old-value").replace(/</g, "<").replace(/>/g, ">"); const newValue = valueElement.data("new-value").replace(/</g, "<").replace(/>/g, ">"); const diff = JsDiff.diffChars(oldValue, newValue); let outputHTML = ""; diff.forEach(({added, removed, value}) => { let color = ""; if (added) { color = "#89ffaa"; } else if (removed) { color = "red"; } if (added || removed) { outputHTML += `<span style="background-color: ${color}">${value}</span>`; } else { outputHTML += value; } }); outputHTML = outputHTML.replace(/\n/g, "<br><br>"); valueElement.html(outputHTML); }); })
Version data entries
92 entries across 92 versions & 1 rubygems