From 1fba61bf7a9caf8d18f31dde1e45d6f90ea2ba06 Mon Sep 17 00:00:00 2001
From: Sapna_713 <140054005+863770@users.noreply.github.com>
Date: Fri, 12 Jul 2024 16:38:47 +0530
Subject: [PATCH] Update App.svelte
code chaneges
---
src/App.svelte | 85 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 76 insertions(+), 9 deletions(-)
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