diff --git a/js/app.js b/js/app.js index 74cbc288..e5ec07f5 100644 --- a/js/app.js +++ b/js/app.js @@ -1 +1,220 @@ -// CODE EXPLAINED channel \ No newline at end of file + +function myFunction() { + var d = new Date(); + console.log(d); + var weekday = new Array(7); + weekday[0]="Sunday"; + weekday[1]="Monday"; + weekday[2]="Tuesday"; + weekday[3]="Wednesday"; + weekday[4]="Thrusday"; + weekday[5]="Friday"; + weekday[6]="Saturday"; + + var month = new Array(11); + month[0] = "Jan"; + month[1] = "Feb"; + month[2] = "Mar"; + month[3] = "April"; + month[4] = "May"; + month[5] = "June"; + month[6] = "July"; + month[7] = "Aug"; + month[8] = "Sept"; + month[9] = "Oct"; + month[10] = "Nov"; + month[11] = "Dec"; + + var mon = month[d.getMonth()]; + var day = weekday[d.getDay()]; + var date = d.getDate(); + document.getElementById("date").innerHTML = day +", "+ mon + " "+date ; + } + + myFunction(); + + function showTime(){ + var date = new Date(); + var h = date.getHours(); // 0 - 23 + var m = date.getMinutes(); // 0 - 59 + + var session = "AM"; + + if(h == 0){ + h = 12; + } + + if(h > 12){ + h = h - 12; + session = "PM"; + } + + h = (h < 10) ? "0" + h : h; + m = (m < 10) ? "0" + m : m; + + + var time = h + ":" + m + ":" + " " + session; + document.getElementById("MyClockDisplay").innerText = time; + document.getElementById("MyClockDisplay").textContent = time; + + setTimeout(showTime, 1000); + +} + +showTime(); + +// showing data in todolist +const clear = document.querySelector(".clear"); +const list= document.getElementById("list"); +const input=document.getElementById('input'); + +const check = "fa-check-circle"; +const uncheck = "fa-circle-thin"; +const linethrough="lineThrough"; +let LIST, id; + + +//get item +let data = localStorage.getItem("storeitem"); + +if(data) +{ + LIST =JSON.parse(data); + id=LIST.length; + loadList(LIST); + +} +else{ + LIST=[]; + id=0; +} + +function loadList(array){ + array.forEach(function(item){ + add(item.name,item.id,item.done,item.trash); + }); +} +//clear +clear.addEventListener("click",function(){ + localStorage.clear(); + location.reload(); +}) + + + + function add(todo,id,done,trash){ + + + if(trash){ + return; + } + const don = done ? check:uncheck; + const line = done ? linethrough:""; + + const item = `
${todo}
+ +