diff --git a/app.js b/app.js index 10ee3b8..e7a5848 100644 --- a/app.js +++ b/app.js @@ -8,6 +8,8 @@ const search = document.querySelector('#search'); const collection = document.querySelector('#collection'); const collectionDone = document.querySelector('#collection-done'); const clearAllBtn = document.querySelector('#clearall'); +const shareAllBtn = document.querySelector('#shareall'); +const installApp = document.querySelector('#installapp'); setInterval(clockFunction,1000); loadEventListeners(); @@ -117,6 +119,14 @@ function loadEventListeners(){ search.addEventListener('keyup', searchItem); + // share all + + shareAllBtn.addEventListener('click',share); + + // install app + + installApp.addEventListener('click',install); + } // get tasks from local stroge @@ -263,3 +273,42 @@ function searchItem(e){ } +// share + +function share() { + let notes = ""; + if (localStorage.getItem('tasks')) { + notes = JSON.parse(localStorage.getItem('tasks')); + navigator.share({ + title : "Day Planner", + text : notes + }); + } else{ + alert("Please add something to the list.") + } + +} + + +// insatll app +let bip = null; +window.addEventListener('beforeinstallprompt',event =>{ + event.preventDefault(); + bip = event; +}); + +function install() { + if (bip) { + bip.prompt(); + console.log(bip); + } else { + alert( + ` + 1. Click on 3 dots at top right corner of your browser. + 2. Find install app. + 3. Click on it. + ` + ) + } +} + diff --git a/app.webmanifest b/app.webmanifest new file mode 100644 index 0000000..eae2dcd --- /dev/null +++ b/app.webmanifest @@ -0,0 +1,45 @@ +{ + "name": "Day Planner", + "short_name": "Day Planner", + "start_url": "./", + "orientation": "any", + "theme_color": "#da2d2d", + "scope": "./", + "display": "standalone", + "description" : "This app helps you to plan your day by writing down the task and marking as done when you complete it.", + "icons" : [ + { + "src": "icons/logo-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src" : "icons/logo-1024.png", + "sizes": "1024x1024", + "type": "image/png" + }, + { + "src": "icons/logo-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + "screenshots" : [ + { + "src": "screenshot/screenshot1.png", + "sizes": "563x1218", + "type": "image/png" + }, + { + "src" : "screenshot/screenshot2.png", + "sizes" : "563x1218", + "type" : "image/png" + }, + { + "src" : "screenshot/screenshot3.png", + "sizes" : "563x1218", + "type" : "image/png" + } + ] +} \ No newline at end of file diff --git a/icons/logo-1024.png b/icons/logo-1024.png new file mode 100644 index 0000000..b51062f Binary files /dev/null and b/icons/logo-1024.png differ diff --git a/icons/logo-512.png b/icons/logo-512.png new file mode 100644 index 0000000..a69952f Binary files /dev/null and b/icons/logo-512.png differ diff --git a/index.html b/index.html index d1a6f57..293d96e 100644 --- a/index.html +++ b/index.html @@ -2,102 +2,123 @@
- - - + + + + + - - + + + + - - + + - - + + + + + + + + - - - - -