<script type="text/javascript" src="${theme_uri}/resources/jsdifflib/diffview.js"></script>
<link href="${theme_uri}/resources/jsdifflib/diffview.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
-function diffUsingJS() {\r
- // get the baseText and newText values from the two textboxes, and split them into lines\r
- var base = difflib.stringAsLines(document.getElementById("baseText").value);\r
- var newtxt = difflib.stringAsLines(document.getElementById("newText").value);\r
-\r
- // create a SequenceMatcher instance that diffs the two sets of lines\r
- var sm = new difflib.SequenceMatcher(base, newtxt);\r
-\r
- // get the opcodes from the SequenceMatcher instance\r
- // opcodes is a list of 3-tuples describing what changes should be made to the base text\r
- // in order to yield the new text\r
- var opcodes = sm.get_opcodes();\r
- var diffoutputdiv = document.getElementById("diffoutputdiv")\r
- while (diffoutputdiv.firstChild) diffoutputdiv.removeChild(diffoutputdiv.firstChild);\r
-\r
- // build the diff view and add it to the current DOM\r
- diffoutputdiv.appendChild(diffview.buildView({\r
- baseTextLines: base,\r
- newTextLines: newtxt,\r
- opcodes: opcodes,\r
- // set the display titles for each resource\r
- baseTextName: "Base Text",\r
- newTextName: "New Text",\r
- contextSize: null,\r
- viewType: 1 // 1 or 0\r
- }));\r
+function diffUsingJS(type) {
+ // get the baseText and newText values from the two textboxes, and split them into lines
+ var base = difflib.stringAsLines(document.getElementById("baseText").value);
+ var newtxt = difflib.stringAsLines(document.getElementById("newText").value);
+
+ // create a SequenceMatcher instance that diffs the two sets of lines
+ var sm = new difflib.SequenceMatcher(base, newtxt);
+
+ // get the opcodes from the SequenceMatcher instance
+ // opcodes is a list of 3-tuples describing what changes should be made to the base text
+ // in order to yield the new text
+ var opcodes = sm.get_opcodes();
+ var diffoutputdiv = document.getElementById("diffoutputdiv")
+ while (diffoutputdiv.firstChild) diffoutputdiv.removeChild(diffoutputdiv.firstChild);
+
+ // build the diff view and add it to the current DOM
+ diffoutputdiv.appendChild(diffview.buildView({
+ baseTextLines: base,
+ newTextLines: newtxt,
+ opcodes: opcodes,
+ // set the display titles for each resource
+ baseTextName: "Base Text",
+ newTextName: "New Text",
+ contextSize: null,
+ viewType: type // 1 or 0
+ }));
}
</script>
$diff
+<input type="checkbox" id="viewtype" onclick="diffUsingJS(this.checked ? 0 : 1)"><label for="viewtype">¥µ¥¤¥É¥Ð¥¤¥µ¥¤¥É¤Çɽ¼¨</label>
<div id="diffoutputdiv"/>
<script type="text/javascript">
- diffUsingJS();
+ diffUsingJS(1);
</script>
|;