| 412 | |
| 413 | |
| 414 | const generateCompareCodesText = (codeFormat, suggestion) =>{ |
| 415 | const { Diff } = window; |
| 416 | const preCodeMesageSplit = codeFormat.split("<commit_msg>") |
| 417 | const preCode = preCodeMesageSplit[0].slice(15) |
| 418 | |
| 419 | let html = [] |
| 420 | const diff = Diff.diffChars(preCode, suggestion) |
| 421 | |
| 422 | diff.forEach((part) => { |
| 423 | let blockContent = part.value |
| 424 | |
| 425 | if (part.added){ |
| 426 | html.push(`<span style="color: green;">${blockContent}</span>`) |
| 427 | }else if(part.removed){ |
| 428 | html.push(`<span style="color: red;">${blockContent}</span>`) |
| 429 | }else{ |
| 430 | html.push(`<span style="color: grey;">${blockContent}</span>`) |
| 431 | } |
| 432 | |
| 433 | }); |
| 434 | |
| 435 | return html.join('') |
| 436 | } |
| 437 | |
| 438 | utility.viewCodeResult = (suggestion, animationElement, codeFormat, requestType, activeRequestTextarea) => { |
| 439 | switch (requestType) { |