Compare commits
2 Commits
dbe938af1c
...
038f014f9c
| Author | SHA1 | Date | |
|---|---|---|---|
| 038f014f9c | |||
| 17ff666965 |
@ -147,7 +147,7 @@
|
||||
const remBtn = document.createElement('button');
|
||||
remBtn.className = 'btn btn-outline-danger';
|
||||
remBtn.type = 'button';
|
||||
remBtn.textContent = 'Remove';
|
||||
remBtn.textContent = 'entfernen';
|
||||
remBtn.addEventListener('click', () => removeFolder(key, i));
|
||||
nameGroup.appendChild(remBtn);
|
||||
}
|
||||
@ -170,7 +170,7 @@
|
||||
const addFld = document.createElement('button');
|
||||
addFld.className = 'btn btn-sm btn-primary mb-2';
|
||||
addFld.type = 'button';
|
||||
addFld.textContent = 'Add Folder';
|
||||
addFld.textContent = 'Ordner hinzufügen';
|
||||
addFld.addEventListener('click', () => addFolder(key));
|
||||
body.appendChild(addFld);
|
||||
}
|
||||
@ -186,32 +186,49 @@
|
||||
actions.appendChild(openButton);
|
||||
}
|
||||
|
||||
if (!isEdit) {
|
||||
const openButton = document.createElement('button');
|
||||
openButton.className = 'btn btn-secondary btn-sm me-2';
|
||||
openButton.onclick = () => toClipboard(`${window.location.origin}/?secret=${rec.secret}`);
|
||||
openButton.textContent = 'Link kopieren';
|
||||
actions.appendChild(openButton);
|
||||
}
|
||||
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.className = 'btn btn-danger btn-sm me-2 delete-btn';
|
||||
delBtn.type = 'button';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.textContent = 'löschen';
|
||||
delBtn.dataset.secret = key;
|
||||
actions.appendChild(delBtn);
|
||||
|
||||
const cloneBtn = document.createElement('button');
|
||||
cloneBtn.className = 'btn btn-secondary btn-sm me-2';
|
||||
cloneBtn.type = 'button';
|
||||
cloneBtn.textContent = 'Clone';
|
||||
cloneBtn.textContent = 'clonen';
|
||||
cloneBtn.addEventListener('click', () => cloneRec(key));
|
||||
actions.appendChild(cloneBtn);
|
||||
|
||||
if (isEdit || expired) {
|
||||
const renewBtn = document.createElement('button');
|
||||
renewBtn.className = 'btn btn-info btn-sm me-2';
|
||||
renewBtn.type = 'button';
|
||||
renewBtn.textContent = 'erneuern';
|
||||
renewBtn.addEventListener('click', () => renewRec(key));
|
||||
actions.appendChild(renewBtn);
|
||||
}
|
||||
|
||||
if (isEdit) {
|
||||
const saveBtn = document.createElement('button');
|
||||
saveBtn.className = 'btn btn-success btn-sm';
|
||||
saveBtn.type = 'button';
|
||||
saveBtn.textContent = 'Save';
|
||||
saveBtn.textContent = 'speichern';
|
||||
saveBtn.addEventListener('click', () => saveRec(key));
|
||||
actions.appendChild(saveBtn);
|
||||
} else {
|
||||
const editBtn = document.createElement('button');
|
||||
editBtn.className = 'btn btn-warning btn-sm';
|
||||
editBtn.type = 'button';
|
||||
editBtn.textContent = 'Edit';
|
||||
editBtn.textContent = 'bearbeiten';
|
||||
editBtn.addEventListener('click', () => editRec(key));
|
||||
actions.appendChild(editBtn);
|
||||
}
|
||||
@ -241,10 +258,49 @@
|
||||
const rec = JSON.parse(JSON.stringify(data[idx]));
|
||||
const existing = data.map(r => r.secret);
|
||||
rec.secret = generateSecret(existing);
|
||||
const futureDate = new Date();
|
||||
futureDate.setDate(futureDate.getDate() + 35);
|
||||
// Format as DD.MM.YYYY for validity input
|
||||
const dd = String(futureDate.getDate()).padStart(2, '0');
|
||||
const mm = String(futureDate.getMonth() + 1).padStart(2, '0');
|
||||
const yyyy = futureDate.getFullYear();
|
||||
rec.validity = `${dd}.${mm}.${yyyy}`;
|
||||
data.splice(idx+1, 0, rec);
|
||||
editing.add(rec.secret);
|
||||
render();
|
||||
}
|
||||
async function renewRec(secret) {
|
||||
// find current record
|
||||
const rec = data.find(r => r.secret === secret);
|
||||
if (!rec) return;
|
||||
|
||||
// generate a fresh unique secret
|
||||
const existing = data.map(r => r.secret);
|
||||
const newSecret = generateSecret(existing);
|
||||
|
||||
// validity = today + 35 days, formatted as YYYY-MM-DD
|
||||
const future = new Date();
|
||||
future.setDate(future.getDate() + 35);
|
||||
const yyyy = future.getFullYear();
|
||||
const mm = String(future.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(future.getDate()).padStart(2, '0');
|
||||
const validity = `${yyyy}-${mm}-${dd}`;
|
||||
|
||||
// keep folders unchanged
|
||||
const folders = rec.folders.map(f => ({
|
||||
foldername: f.foldername,
|
||||
folderpath: f.folderpath
|
||||
}));
|
||||
|
||||
// persist via existing endpoint
|
||||
await sendAction({
|
||||
action: 'update',
|
||||
oldSecret: secret,
|
||||
newSecret,
|
||||
validity,
|
||||
folders
|
||||
});
|
||||
}
|
||||
function addFolder(secret) {
|
||||
data.find(r => r.secret === secret).folders.push({foldername:'', folderpath:''});
|
||||
render();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user