diff --git a/src/App.svelte b/src/App.svelte index 0f3cfb05..a7711ae7 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,11 +1,78 @@ - -
- Hello World -
- \ No newline at end of file + import{onMount} from 'svelte'; + let pages=[]; + let currentPageIndex = 0; + let title = 'New Note'; + let note = 'Today is an excellent day !!'; + onMount( () => { + const savedPages=localStorage.getItem("pages"); + if(savedPages){ + pages=JSON.parse(savedPages); + title=pages[currentPageIndex] || "New Page"; + note=localStorage.getItem(title); + } + else{ + addPage(); + } + }); + + function saveNote(){ + const storedPageName = pages[currentPageIndex]; + if(storedPageName != title){ + localStorage.removeItem(storedPageName); + pages[currentPageIndex]=title; + } + + localStorage.setItem(title ,note); + localStorage.setItem("pages",JSON.stringify(pages)); + } + function addPage(){ + pages.push("New Page"); + selectPage(pages.length ? pages.length -1 : 0); + } + function selectPage(index){ + currentPageIndex=index; + title=pages[currentPageIndex]; + note=localStorage.getItem(title); + } + + + + +
+
+

+ +
+
+ +
+ + \ No newline at end of file