Delete preset-ui.js

This commit is contained in:
simonpipe 2025-12-19 15:35:00 +01:00
parent 429771bbd5
commit a34754a95b

View file

@ -1,81 +0,0 @@
// preset-ui.js
window.PresetUI = {
renderTable() {
const tableBody = document.querySelector('#sortable-tbody');
if (!tableBody) return;
tableBody.innerHTML = '';
window.PresetManager.presets.forEach((preset, index) => {
const row = document.createElement('tr');
row.setAttribute('data-index', index);
row.innerHTML = `
<td class="drag-handle"></td>
<td><input type="text" value="${preset.name}" onchange="PresetUI.changeName(${index}, this.value)"></td>
<td><input type="text" value="${preset.url}" onchange="PresetUI.changeURL(${index}, this.value)"></td>
<td><button class="delete-btn" onclick="PresetUI.deletePreset(${index})"><i class="fas fa-trash-alt"></i></button></td>
`;
tableBody.appendChild(row);
});
this.updateExportFields();
},
async updateExportFields() {
const exportField = document.getElementById('export-string-field');
if (!exportField || !window.PresetManager) return;
const dataString = await window.PresetManager.generateExportCode(false);
const baseUrl = window.location.origin + window.location.pathname;
exportField.value = baseUrl + '#' + dataString;
},
copyShareLink() {
const exportField = document.getElementById('export-string-field');
if (!exportField || !exportField.value) return;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(exportField.value)
.catch(() => this.fallbackCopy(exportField));
} else {
this.fallbackCopy(exportField);
}
},
fallbackCopy(field) {
field.select();
field.setSelectionRange(0, 99999);
try {
document.execCommand('copy');
} catch (err) {
window.UI.showAlert("Fehler", "Link bitte manuell kopieren.");
}
},
addPreset() {
// Hier Umlaute vermeiden oder Entities nutzen beim Default-Namen
window.PresetManager.presets.push({ name: 'Neuer Sender', url: '' });
this.renderTable();
},
deletePreset(index) {
// "Löschen" -> "L&ouml;schen" zur Sicherheit
window.UI.showConfirm("L&ouml;schen", "Sender wirklich entfernen?", (conf) => {
if (conf) {
window.PresetManager.presets.splice(index, 1);
this.renderTable();
}
});
},
changeName(i, v) {
window.PresetManager.presets[i].name = v;
this.updateExportFields();
},
changeURL(i, v) {
window.PresetManager.presets[i].url = v;
this.updateExportFields();
}
};
window.addPreset = () => window.PresetUI.addPreset();
window.deletePreset = (i) => window.PresetUI.deletePreset(i);
window.copyShareLink = () => window.PresetUI.copyShareLink();