|
480 | 480 | const originalName = index => sm.names[index]; |
481 | 481 | originalTextArea = null; |
482 | 482 | if (sm.sources.length > 0) { |
483 | | - fileList.selectedIndex = 0; |
484 | 483 | const updateOriginalSource = () => { |
485 | 484 | const source = sm.sources[fileList.selectedIndex]; |
486 | 485 | originalTextArea = createTextArea({ |
|
503 | 502 | }; |
504 | 503 | fileList.onchange = updateOriginalSource; |
505 | 504 | updateOriginalSource(); |
| 505 | + } else { |
| 506 | + const option = document.createElement('option'); |
| 507 | + option.textContent = `(no original code)`; |
| 508 | + option.disabled = true; |
| 509 | + fileList.appendChild(option); |
506 | 510 | } |
| 511 | + fileList.selectedIndex = 0; |
507 | 512 |
|
508 | 513 | generatedTextArea = createTextArea({ |
509 | 514 | sourceIndex: null, |
|
1377 | 1382 | isInvalid = false; |
1378 | 1383 |
|
1379 | 1384 | c.clearRect(0, 0, innerWidth, innerHeight); |
1380 | | - if (!originalTextArea || !generatedTextArea) return; |
| 1385 | + if (!generatedTextArea) return; |
1381 | 1386 |
|
1382 | 1387 | const bodyStyle = getComputedStyle(document.body); |
1383 | | - originalTextArea.draw(bodyStyle); |
| 1388 | + if (originalTextArea) originalTextArea.draw(bodyStyle); |
1384 | 1389 | generatedTextArea.draw(bodyStyle); |
1385 | 1390 |
|
1386 | 1391 | // Draw the splitter |
1387 | 1392 | c.fillStyle = 'rgba(127, 127, 127, 0.2)'; |
1388 | 1393 | c.fillRect((innerWidth >>> 1) - (splitterWidth >> 1), toolbarHeight, splitterWidth, innerHeight - toolbarHeight - statusBarHeight); |
1389 | 1394 |
|
1390 | 1395 | // Draw the arrow between the two hover areas |
1391 | | - if (hover && hover.mapping && originalTextArea.sourceIndex === hover.mapping.originalSource) { |
| 1396 | + if (hover && hover.mapping && originalTextArea && originalTextArea.sourceIndex === hover.mapping.originalSource) { |
1392 | 1397 | const originalHoverRect = originalTextArea.getHoverRect(); |
1393 | 1398 | const generatedHoverRect = generatedTextArea.getHoverRect(); |
1394 | 1399 | if (originalHoverRect && generatedHoverRect) { |
|
0 commit comments