From 3c72a4411d19c94efef113572c942e7baebaac41 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 22 Jun 2023 15:48:13 +0300 Subject: (checklist) Added proper export, import and opening of checklists (with proper title support) --- checklist.html | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'checklist.html') diff --git a/checklist.html b/checklist.html index d93db49..7b084f3 100644 --- a/checklist.html +++ b/checklist.html @@ -79,13 +79,21 @@ input {
-
+

- + + +

+

+ -

+ +


+

+ +

@@ -96,7 +104,6 @@ input { const lists = document.getElementById('lists'); const stylesheetLocked = document.getElementById('stylesheet-locked'); stylesheetLocked.disabled = true; - const expImpText = document.getElementById('exp-imp-text'); /* Item functionality */ @@ -228,6 +235,10 @@ input { /* Import-export */ const dropdown = document.getElementById('db-lists'); + const eiName = document.getElementById('ei-name'); + const eiValue = document.getElementById('ei-value'); + const name = document.getElementById('name'); + const dbRequest = window.indexedDB.open('checklist', 1); var db = '', store = ''; @@ -325,20 +336,36 @@ input { }); } - document.getElementById('import-btn').onclick = function () { - const name = dropdown.options[dropdown.selectedIndex].text; + document.getElementById('open-btn').onclick = function () { + const listName = dropdown.options[dropdown.selectedIndex].text; + var store = db.transaction('CheckLists', 'readwrite').objectStore('CheckLists'); - var val = store.get(name); + var val = store.get(listName); val.onsuccess = function() { + name.value = listName; parse(val.result.value, lists); } } + document.getElementById('delete-btn').onclick = function () { + const listName = dropdown.options[dropdown.selectedIndex].text; + + var store = db.transaction('CheckLists', 'readwrite').objectStore('CheckLists'); + store.delete(listName); + dropdown.remove(dropdown.selectedIndex); + } + + document.getElementById('import-btn').onclick = function () { + var store = db.transaction('CheckLists', 'readwrite').objectStore('CheckLists'); + store.put({ name: eiName.value, value: eiValue.value }); + } + document.getElementById('export-btn').onclick = function () { - expImpText.value = stringify().substring(1); + eiName.value = name.value; + eiValue.value = stringify().substring(1); var store = db.transaction('CheckLists', 'readwrite').objectStore('CheckLists'); - store.put({ name: 'ListTest', value: expImpText.value }); + store.put({ name: eiName.value, value: eiValue.value }); } } -- cgit v1.3.1-26-gb76a