diff.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <include file="Common/header" />
  2. <link href="__PUBLIC__/diff/diffview.css" rel="stylesheet">
  3. <style type="text/css">
  4. body {
  5. font-size: 12px;
  6. font-family: Sans-Serif;
  7. }
  8. h2 {
  9. margin: 0.5em 0 0.1em;
  10. text-align: center;
  11. }
  12. .top {
  13. text-align: center;
  14. }
  15. .textInput {
  16. display: block;
  17. width: 49%;
  18. float: left;
  19. display: none;
  20. }
  21. textarea {
  22. width:100%;
  23. height:300px;
  24. }
  25. label:hover {
  26. text-decoration: underline;
  27. cursor: pointer;
  28. }
  29. .spacer {
  30. margin-left: 10px;
  31. }
  32. .viewType {
  33. font-size: 16px;
  34. clear: both;
  35. text-align: center;
  36. padding: 1em;
  37. }
  38. #diffoutput {
  39. width: 835px;
  40. margin: 0 auto;
  41. }
  42. </style>
  43. <!-- <h1 class="top"><a href="http://github.com/cemerick/jsdifflib">jsdifflib</a> demo</h1> -->
  44. <div class="textInput">
  45. <h2>{$Think.Lang.cur_page_content}</h2>
  46. <textarea id="baseText">{$cur_page_content}</textarea>
  47. </div>
  48. <div class="textInput spacer">
  49. <h2>{$Think.Lang.history_page_content}</h2>
  50. <textarea id="newText">{$history_page_content}</textarea>
  51. </div>
  52. <div id="diffoutput"> </div>
  53. <include file="Common/footer" />
  54. <script src="__PUBLIC__/diff/diffview.js"></script>
  55. <script src="__PUBLIC__/diff/difflib.js"></script>
  56. <script type="text/javascript">
  57. $(function(){
  58. diffUsingJS(0);
  59. });
  60. function diffUsingJS(viewType) {
  61. "use strict";
  62. var byId = function (id) { return document.getElementById(id); },
  63. base = difflib.stringAsLines(byId("baseText").value),
  64. newtxt = difflib.stringAsLines(byId("newText").value),
  65. sm = new difflib.SequenceMatcher(base, newtxt),
  66. opcodes = sm.get_opcodes(),
  67. diffoutputdiv = byId("diffoutput")
  68. diffoutputdiv.innerHTML = "";
  69. diffoutputdiv.appendChild(diffview.buildView({
  70. baseTextLines: base,
  71. newTextLines: newtxt,
  72. opcodes: opcodes,
  73. baseTextName: "{$Think.Lang.cur_page_content}",
  74. newTextName: "{$Think.Lang.history_page_content}",
  75. viewType: viewType
  76. }));
  77. }
  78. </script>