- commit
- a3ee13bf023c51e617750bf32e3da3e807e4727f
- parent
- ea826f0640e8029fdf7da9646fc46ee674d30dec
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2021-09-12 05:36
add DELETE UI
Diffstat
| M | index.html | 1 | + |
| M | static/pad.js | 8 | ++++++++ |
2 files changed, 9 insertions, 0 deletions
diff --git a/index.html b/index.html
@@ -11,6 +11,7 @@ 11 11 <textarea autocomplete="off" readonly autofocus></textarea> 12 12 <footer> 13 13 Data (including history) will automatically be deleted after 7 days of inactivity. -1 14 <button type="button">Delete now</button> 14 15 </footer> 15 16 <script type="module" src="/static/pad.js"></script> 16 17 </body>
diff --git a/static/pad.js b/static/pad.js
@@ -94,6 +94,14 @@ el.addEventListener('input', function() {
94 94 sendChanges();
95 95 });
96 96
-1 97 document.querySelector('button').addEventListener('click', function() {
-1 98 if (confirm('Are you sure you want to delete all data?')) {
-1 99 return fetch(url, {method: 'DELETE'}).then(() => {
-1 100 location.reload();
-1 101 });
-1 102 }
-1 103 });
-1 104
97 105 window.addEventListener('offline', function() {
98 106 el.readOnly = true;
99 107 });