improve setting page
This commit is contained in:
parent
dbe938af1c
commit
17ff666965
@ -147,7 +147,7 @@
|
|||||||
const remBtn = document.createElement('button');
|
const remBtn = document.createElement('button');
|
||||||
remBtn.className = 'btn btn-outline-danger';
|
remBtn.className = 'btn btn-outline-danger';
|
||||||
remBtn.type = 'button';
|
remBtn.type = 'button';
|
||||||
remBtn.textContent = 'Remove';
|
remBtn.textContent = 'entfernen';
|
||||||
remBtn.addEventListener('click', () => removeFolder(key, i));
|
remBtn.addEventListener('click', () => removeFolder(key, i));
|
||||||
nameGroup.appendChild(remBtn);
|
nameGroup.appendChild(remBtn);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@
|
|||||||
const addFld = document.createElement('button');
|
const addFld = document.createElement('button');
|
||||||
addFld.className = 'btn btn-sm btn-primary mb-2';
|
addFld.className = 'btn btn-sm btn-primary mb-2';
|
||||||
addFld.type = 'button';
|
addFld.type = 'button';
|
||||||
addFld.textContent = 'Add Folder';
|
addFld.textContent = 'Ordner hinzufügen';
|
||||||
addFld.addEventListener('click', () => addFolder(key));
|
addFld.addEventListener('click', () => addFolder(key));
|
||||||
body.appendChild(addFld);
|
body.appendChild(addFld);
|
||||||
}
|
}
|
||||||
@ -186,17 +186,25 @@
|
|||||||
actions.appendChild(openButton);
|
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');
|
const delBtn = document.createElement('button');
|
||||||
delBtn.className = 'btn btn-danger btn-sm me-2 delete-btn';
|
delBtn.className = 'btn btn-danger btn-sm me-2 delete-btn';
|
||||||
delBtn.type = 'button';
|
delBtn.type = 'button';
|
||||||
delBtn.textContent = 'Delete';
|
delBtn.textContent = 'löschen';
|
||||||
delBtn.dataset.secret = key;
|
delBtn.dataset.secret = key;
|
||||||
actions.appendChild(delBtn);
|
actions.appendChild(delBtn);
|
||||||
|
|
||||||
const cloneBtn = document.createElement('button');
|
const cloneBtn = document.createElement('button');
|
||||||
cloneBtn.className = 'btn btn-secondary btn-sm me-2';
|
cloneBtn.className = 'btn btn-secondary btn-sm me-2';
|
||||||
cloneBtn.type = 'button';
|
cloneBtn.type = 'button';
|
||||||
cloneBtn.textContent = 'Clone';
|
cloneBtn.textContent = 'clonen';
|
||||||
cloneBtn.addEventListener('click', () => cloneRec(key));
|
cloneBtn.addEventListener('click', () => cloneRec(key));
|
||||||
actions.appendChild(cloneBtn);
|
actions.appendChild(cloneBtn);
|
||||||
|
|
||||||
@ -204,14 +212,14 @@
|
|||||||
const saveBtn = document.createElement('button');
|
const saveBtn = document.createElement('button');
|
||||||
saveBtn.className = 'btn btn-success btn-sm';
|
saveBtn.className = 'btn btn-success btn-sm';
|
||||||
saveBtn.type = 'button';
|
saveBtn.type = 'button';
|
||||||
saveBtn.textContent = 'Save';
|
saveBtn.textContent = 'speichern';
|
||||||
saveBtn.addEventListener('click', () => saveRec(key));
|
saveBtn.addEventListener('click', () => saveRec(key));
|
||||||
actions.appendChild(saveBtn);
|
actions.appendChild(saveBtn);
|
||||||
} else {
|
} else {
|
||||||
const editBtn = document.createElement('button');
|
const editBtn = document.createElement('button');
|
||||||
editBtn.className = 'btn btn-warning btn-sm';
|
editBtn.className = 'btn btn-warning btn-sm';
|
||||||
editBtn.type = 'button';
|
editBtn.type = 'button';
|
||||||
editBtn.textContent = 'Edit';
|
editBtn.textContent = 'bearbeiten';
|
||||||
editBtn.addEventListener('click', () => editRec(key));
|
editBtn.addEventListener('click', () => editRec(key));
|
||||||
actions.appendChild(editBtn);
|
actions.appendChild(editBtn);
|
||||||
}
|
}
|
||||||
@ -241,6 +249,13 @@
|
|||||||
const rec = JSON.parse(JSON.stringify(data[idx]));
|
const rec = JSON.parse(JSON.stringify(data[idx]));
|
||||||
const existing = data.map(r => r.secret);
|
const existing = data.map(r => r.secret);
|
||||||
rec.secret = generateSecret(existing);
|
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);
|
data.splice(idx+1, 0, rec);
|
||||||
editing.add(rec.secret);
|
editing.add(rec.secret);
|
||||||
render();
|
render();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user