|
| 1 | +<script> |
| 2 | + function getFileName(line) { |
| 3 | + // Skips "|", "└", "├" found in file tree |
| 4 | + const index = line.search(/[a-zA-Z0-9]/); |
| 5 | + return line.substring(index).trim(); |
| 6 | + } |
| 7 | +
|
| 8 | + function toggleFile(element) { |
| 9 | + const patternInput = document.getElementById("pattern"); |
| 10 | + const patternFiles = patternInput.value ? patternInput.value.split(",").map(item => item.trim()) : []; |
| 11 | +
|
| 12 | + if (element.textContent.includes("Directory structure:")) { |
| 13 | + return; |
| 14 | + } |
| 15 | +
|
| 16 | + element.classList.toggle('line-through'); |
| 17 | + element.classList.toggle('text-gray-500'); |
| 18 | + |
| 19 | + const fileName = getFileName(element.textContent); |
| 20 | + const fileIndex = patternFiles.indexOf(fileName); |
| 21 | +
|
| 22 | + if (fileIndex !== -1) { |
| 23 | + patternFiles.splice(fileIndex, 1); |
| 24 | + } else { |
| 25 | + patternFiles.push(fileName); |
| 26 | + } |
| 27 | +
|
| 28 | + patternInput.value = patternFiles.join(", "); |
| 29 | + } |
| 30 | +</script> |
1 | 31 | {% if result %} |
2 | 32 | <div class="mt-10" data-results> |
3 | 33 | <div class="relative"> |
|
61 | 91 | </div> |
62 | 92 | <div class="relative"> |
63 | 93 | <div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div> |
64 | | - <textarea class="directory-structure w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10 h-[215px]" |
65 | | - readonly>{{ tree }}</textarea> |
| 94 | + <div class="directory-structure w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10 h-[215px] overflow-scroll" readonly> |
| 95 | + {% for line in tree.splitlines()%} |
| 96 | + <div name="tree-line" class="cursor-pointer hover:line-through hover:text-gray-500" onclick="toggleFile(this)">{{ line }}</div> |
| 97 | + {% endfor %} |
| 98 | + </div> |
66 | 99 | </div> |
67 | 100 | </div> |
68 | 101 | </div> |
|
0 commit comments