| 5 | function isEditable(name) { return editableExts.has(name.split('.').pop().toLowerCase()); } |
| 6 | let editingFile = ''; |
| 7 | function editFile(path) { |
| 8 | editingFile = path; |
| 9 | _('editor-title').textContent = path; |
| 10 | _('editor-content').value = 'Loading...'; |
| 11 | _('editor').style.display = 'block'; |
| 12 | const xhr = new XMLHttpRequest(); |
| 13 | xhr.open('GET', '/editfile?name=' + encodeURIComponent(path)); |
| 14 | xhr.onload = () => { _('editor-content').value = xhr.responseText; }; |
| 15 | xhr.onerror = () => { _('editor-content').value = 'Error loading file'; }; |
| 16 | xhr.send(); |
| 17 | } |
| 18 | function saveFile() { |
| 19 | const xhr = new XMLHttpRequest(); |
| 20 | xhr.open('POST', '/editfile?name=' + encodeURIComponent(editingFile)); |