サイドバイサイドでの表示に切り替えられるようにした。
@@ -174,38 +174,39 @@ | ||
174 | 174 | <script type="text/javascript" src="${theme_uri}/resources/jsdifflib/diffview.js"></script> |
175 | 175 | <link href="${theme_uri}/resources/jsdifflib/diffview.css" type="text/css" rel="stylesheet" /> |
176 | 176 | <script type="text/javascript"> |
177 | -function diffUsingJS() { | |
178 | - // get the baseText and newText values from the two textboxes, and split them into lines | |
179 | - var base = difflib.stringAsLines(document.getElementById("baseText").value); | |
180 | - var newtxt = difflib.stringAsLines(document.getElementById("newText").value); | |
181 | - | |
182 | - // create a SequenceMatcher instance that diffs the two sets of lines | |
183 | - var sm = new difflib.SequenceMatcher(base, newtxt); | |
184 | - | |
185 | - // get the opcodes from the SequenceMatcher instance | |
186 | - // opcodes is a list of 3-tuples describing what changes should be made to the base text | |
187 | - // in order to yield the new text | |
188 | - var opcodes = sm.get_opcodes(); | |
189 | - var diffoutputdiv = document.getElementById("diffoutputdiv") | |
190 | - while (diffoutputdiv.firstChild) diffoutputdiv.removeChild(diffoutputdiv.firstChild); | |
191 | - | |
192 | - // build the diff view and add it to the current DOM | |
193 | - diffoutputdiv.appendChild(diffview.buildView({ | |
194 | - baseTextLines: base, | |
195 | - newTextLines: newtxt, | |
196 | - opcodes: opcodes, | |
197 | - // set the display titles for each resource | |
198 | - baseTextName: "Base Text", | |
199 | - newTextName: "New Text", | |
200 | - contextSize: null, | |
201 | - viewType: 1 // 1 or 0 | |
202 | - })); | |
177 | +function diffUsingJS(type) { | |
178 | + // get the baseText and newText values from the two textboxes, and split them into lines | |
179 | + var base = difflib.stringAsLines(document.getElementById("baseText").value); | |
180 | + var newtxt = difflib.stringAsLines(document.getElementById("newText").value); | |
181 | + | |
182 | + // create a SequenceMatcher instance that diffs the two sets of lines | |
183 | + var sm = new difflib.SequenceMatcher(base, newtxt); | |
184 | + | |
185 | + // get the opcodes from the SequenceMatcher instance | |
186 | + // opcodes is a list of 3-tuples describing what changes should be made to the base text | |
187 | + // in order to yield the new text | |
188 | + var opcodes = sm.get_opcodes(); | |
189 | + var diffoutputdiv = document.getElementById("diffoutputdiv") | |
190 | + while (diffoutputdiv.firstChild) diffoutputdiv.removeChild(diffoutputdiv.firstChild); | |
191 | + | |
192 | + // build the diff view and add it to the current DOM | |
193 | + diffoutputdiv.appendChild(diffview.buildView({ | |
194 | + baseTextLines: base, | |
195 | + newTextLines: newtxt, | |
196 | + opcodes: opcodes, | |
197 | + // set the display titles for each resource | |
198 | + baseTextName: "Base Text", | |
199 | + newTextName: "New Text", | |
200 | + contextSize: null, | |
201 | + viewType: type // 1 or 0 | |
202 | + })); | |
203 | 203 | } |
204 | 204 | </script> |
205 | 205 | $diff |
206 | +<input type="checkbox" id="viewtype" onclick="diffUsingJS(this.checked ? 0 : 1)"><label for="viewtype">サイドバイサイドで表示</label> | |
206 | 207 | <div id="diffoutputdiv"/> |
207 | 208 | <script type="text/javascript"> |
208 | - diffUsingJS(); | |
209 | + diffUsingJS(1); | |
209 | 210 | </script> |
210 | 211 | |; |
211 | 212 |