├── src ├── img │ ├── demo.gif │ ├── trello.png │ ├── calendarImage.png │ ├── calendarStructure.png │ ├── resumeSectionDay.png │ ├── modalesarticleysection.png │ └── 4781812_bin_delete_file_garbage_recycle_icon.png ├── CSS │ ├── style.css │ ├── modal.css │ ├── calendar.css │ └── normalize.css └── JS │ ├── clearAside.js │ ├── modalFromDay.js │ ├── getMonth.js │ ├── script.js │ ├── showDialog.js │ └── saveData.js ├── README.md └── index.html /src/img/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/demo.gif -------------------------------------------------------------------------------- /src/img/trello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/trello.png -------------------------------------------------------------------------------- /src/img/calendarImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/calendarImage.png -------------------------------------------------------------------------------- /src/img/calendarStructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/calendarStructure.png -------------------------------------------------------------------------------- /src/img/resumeSectionDay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/resumeSectionDay.png -------------------------------------------------------------------------------- /src/img/modalesarticleysection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/modalesarticleysection.png -------------------------------------------------------------------------------- /src/img/4781812_bin_delete_file_garbage_recycle_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juliomc23/Calendar-JS-Vanilla/HEAD/src/img/4781812_bin_delete_file_garbage_recycle_icon.png -------------------------------------------------------------------------------- /src/CSS/style.css: -------------------------------------------------------------------------------- 1 | @import url(./normalize.css); 2 | @import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@200&display=swap'); 3 | @import url(./calendar.css); 4 | @import url(./modal.css); 5 | 6 | body{ 7 | position: relative; 8 | font-family: 'Nunito Sans', sans-serif; 9 | } -------------------------------------------------------------------------------- /src/JS/clearAside.js: -------------------------------------------------------------------------------- 1 | import {getEventData} from "./saveData.js"; 2 | function clearAsideEvent(e){ 3 | let control = 0; 4 | let localEvent = JSON.parse(localStorage.getItem("calendar_events")); 5 | 6 | //coger el padre del button e pasado por parametro y obtener el hijo con clase start-time-aside 7 | const parent = e.parentNode; 8 | let i = 0; 9 | const articleAside = parent.getAttribute("id"); 10 | const timeEventStart = parent.querySelectorAll(".start-time-aside"); 11 | const eventArticletoDelete = timeEventStart.item(0); 12 | const divSpanDay = document.querySelectorAll(".section__div--span"); 13 | divSpanDay.forEach(node=>{ 14 | let nodes = node.querySelectorAll(".section__span--span"); 15 | nodes.forEach(span =>{ 16 | if(span.textContent.split("-")[1] == eventArticletoDelete.textContent && control == 0){ 17 | node.removeChild(span); 18 | localEvent.splice(i, 1); 19 | control = 1; 20 | } 21 | i++; 22 | }); 23 | }) 24 | localStorage.setItem("calendar_events", JSON.stringify(localEvent)); 25 | e.removeEventListener("click", function(){ 26 | clearAsideEvent(e); 27 | }); 28 | 29 | 30 | 31 | getEventData(); 32 | } 33 | 34 | export {clearAsideEvent}; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSCalendar 2 | Project to developing a calendar 3 | 4 | # Description 5 | 6 | The project consists of the development of a calendar that must show all the months of the year and be able to store events, as well as delete them, taking into account the title, time, description and type of event. 7 | 8 | # Technologies 9 | 10 | CSS, HTML5, Javascript, localStorage, Date Objects, SMACSS. 11 | 12 | # Organization and improvements 13 | 14 | The way of organizing the project had several phases: 15 | 16 | The initial phase consisted of defining the visual elements of the calendar as well as its semantic HTML5 tags in order to later implement it in the HTML document. 17 | 18 | The next phase was the development of the functionality that allows scrolling through the months. 19 | 20 | The following phases consisted of the development of the functionalities to show the modal and the addition and elimination of events. 21 | 22 | This project has been realized by 100% peer coding. 23 | 24 | ###### Steps organization 25 | 26 | 27 | 28 | 29 | 30 | ##### PC image 31 |
32 | 33 | # Demo 34 |
35 | 36 | # Contributors 37 | Walber Melo
38 | Julio Macias
39 | Juan Carlos Cabello
40 | 41 | 42 | -------------------------------------------------------------------------------- /src/CSS/modal.css: -------------------------------------------------------------------------------- 1 | .main__section--modal { 2 | display: flex; 3 | flex-direction: column; 4 | justify-content: center; 5 | align-items: center; 6 | position: absolute; 7 | top: 50%; 8 | left: 50%; 9 | transform: translate(-50%, -50%); 10 | border: 1px solid black; 11 | z-index: 10; 12 | } 13 | 14 | .section__div--modalHeader { 15 | width: 100%; 16 | display: flex; 17 | justify-content: space-around; 18 | align-items: center; 19 | background-color: white; 20 | } 21 | 22 | .div__button--closeForm { 23 | height: 2.75rem; 24 | border: none; 25 | cursor: pointer; 26 | position: absolute; 27 | top: 0; 28 | right: 0; 29 | padding: 0.5rem; 30 | } 31 | 32 | .label__form { 33 | display: flex; 34 | flex-direction: column; 35 | justify-content: left; 36 | margin-bottom: 1rem; 37 | margin-left: 4rem; 38 | margin-right: 4rem; 39 | } 40 | 41 | .form__input--modal { 42 | height: 2.75rem; 43 | outline: none; 44 | } 45 | 46 | .form__input--modal:hover, 47 | .label__textarea--modal:hover { 48 | border: 1px solid black; 49 | } 50 | 51 | .main__div--blurModal { 52 | position: absolute; 53 | top: 0%; 54 | left: 0%; 55 | width: 100%; 56 | height: 100%; 57 | background-color: rgba(0, 0, 0, 0.6); 58 | backdrop-filter: blur(3px); 59 | z-index: 5; 60 | } 61 | 62 | .hide { 63 | display: none; 64 | } 65 | 66 | .section__form--event { 67 | display: flex; 68 | flex-direction: column; 69 | background-color: white; 70 | width: 100%; 71 | padding-top: 2rem; 72 | padding-bottom: 2rem; 73 | 74 | font-size: 1.2rem; 75 | color: #323232; 76 | font-weight: 600; 77 | } 78 | 79 | .form_div--buttonContainer { 80 | display: flex; 81 | justify-content: space-around; 82 | align-items: center; 83 | } 84 | 85 | .form__button--create, 86 | .form__button--cancel { 87 | background-color: #9d6ccb; 88 | box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.266); 89 | border: 1px solid rgb(175, 173, 173); 90 | border-radius: 5px; 91 | font-size: 1.6rem; 92 | color: #ffffff; 93 | font-weight: 500; 94 | padding: 0.5rem 2.5rem; 95 | margin-top: 0.5rem; 96 | } 97 | 98 | .form__button--cancel:hover, 99 | .form__button--create:hover { 100 | color: #9d6ccb; 101 | background-color: #ffffff; 102 | } 103 | -------------------------------------------------------------------------------- /src/JS/modalFromDay.js: -------------------------------------------------------------------------------- 1 | const form = document.getElementById("mainSectionModal"); 2 | const overlay = document.getElementById("blurModal"); 3 | const dateInput = document.getElementById("start-date") 4 | 5 | function createEventFromDay(e){ 6 | console.log(e); 7 | console.log(document.getElementById("start-date")); 8 | const startDate = document.querySelector("#start-date"); 9 | const date = new Date(); 10 | const day = date.toISOString(); 11 | const day1 = day.split(':')[0]; 12 | const min = day.split(':')[1]; 13 | let tabindexDay = e.getAttribute("tabindex"); 14 | let actualMonth = document.getElementById('currentMonth').textContent; 15 | const actualYear = document.getElementById('currentYear').textContent; 16 | let newDate = []; 17 | 18 | 19 | if(tabindexDay < 10){ 20 | tabindexDay = "0"+tabindexDay; 21 | } 22 | switch(actualMonth){ 23 | case "January": 24 | actualMonth = "01"; 25 | break; 26 | case "Februyary": 27 | actualMonth = "02"; 28 | break; 29 | case "March": 30 | actualMonth = "03"; 31 | break; 32 | case "April": 33 | actualMonth = "04"; 34 | break; 35 | case "May": 36 | actualMonth = "05"; 37 | break; 38 | case "June": 39 | actualMonth = "06"; 40 | break; 41 | case "July": 42 | actualMonth = "07"; 43 | break; 44 | case "August": 45 | actualMonth = "08"; 46 | break; 47 | case "September": 48 | actualMonth = "09"; 49 | break; 50 | case "October": 51 | actualMonth = "10"; 52 | break; 53 | case "November": 54 | actualMonth = "11"; 55 | break; 56 | case "December": 57 | actualMonth = "12"; 58 | break; 59 | } 60 | newDate.push(actualYear, actualMonth, tabindexDay); 61 | let fecha = []; 62 | fecha.push(day1); 63 | fecha.push(min); 64 | const stringCurrentMinutes = fecha.join(':').split('T')[1].split(':')[1]; 65 | let integerCurrentHour = parseInt(fecha.join(':').split('T')[1].split(':')[0])+2; 66 | if(integerCurrentHour < 10){ 67 | integerCurrentHour = "0"+integerCurrentHour; 68 | }else{ 69 | integerCurrentHour = integerCurrentHour; 70 | } 71 | 72 | const stringCurrentHour = integerCurrentHour.toString(); 73 | startDate.value = `${newDate.join('-')}T${stringCurrentHour}:${stringCurrentMinutes}`; 74 | form.classList.remove("hide"); 75 | overlay.classList.remove("hide"); 76 | // dateInput.setAttribute("value", `${day}/${month}/${year}T00:00`) 77 | } 78 | 79 | export {createEventFromDay} -------------------------------------------------------------------------------- /src/JS/getMonth.js: -------------------------------------------------------------------------------- 1 | import {addEventDay} from './saveData.js'; 2 | import {showDialogDayEvents} from "./showDialog.js" 3 | let flag = 0; 4 | let door = 0; 5 | let monthEvents = 0; 6 | const getMonth = (counter) => { 7 | const gridMonth = document.getElementById("section__div--gridMonth"); 8 | const currentMonth = document.getElementById("currentMonth"); 9 | const currentYearCalendar = document.getElementById("currentYear"); 10 | let anexMonth = counter -1; 11 | let day = 1; 12 | let arrayHours = []; 13 | // let monthEvents; 14 | door = 0; 15 | let idButtonDay = "addDay"; 16 | const month = [ 17 | "January", 18 | "February", 19 | "March", 20 | "April", 21 | "May", 22 | "June", 23 | "July", 24 | "August", 25 | "September", 26 | "October", 27 | "November", 28 | "December", 29 | ]; 30 | const date = new Date(); 31 | let currentYear = date.getFullYear(); 32 | let initialDay = new Date( 33 | date.getFullYear(), 34 | date.getMonth() + counter - 1 35 | ).getDay(); 36 | const diasMeses = new Date( 37 | date.getFullYear(), 38 | date.getMonth() + counter, 39 | 0 40 | ).getDate(); 41 | 42 | let lastMonth; 43 | if(counter == 1){ 44 | lastMonth = `${month[(date.getMonth()+anexMonth)%12]}` 45 | }else{ 46 | lastMonth = currentMonth.textContent; 47 | } 48 | 49 | if((date.getMonth()+anexMonth) < 0 && ((date.getMonth()+anexMonth)%12) != 0){ 50 | currentMonth.textContent = `${month[(((date.getMonth()+anexMonth)%12)+12)]}`; 51 | monthEvents = (((date.getMonth()+anexMonth)%12)+12); 52 | arrayHours = []; 53 | }else{ 54 | currentMonth.textContent = `${month[(date.getMonth()+anexMonth)%12]}`; 55 | monthEvents = (date.getMonth()+anexMonth)%12; 56 | arrayHours = []; 57 | } 58 | 59 | //Function to change the year 60 | getYear(currentMonth.textContent, lastMonth, date); 61 | 62 | for (let i = 1; i <= 42; i++) {//diasMeses + initialDay 63 | 64 | //Creamos elemento section para el dia 65 | const sectionDay = document.createElement("section"); 66 | //Creamos div para meter el dia 67 | const divDay = document.createElement("div"); 68 | //Crear button para crear eventos 69 | const buttonEvent = document.createElement("button"); 70 | buttonEvent.textContent = "+"; 71 | 72 | sectionDay.classList.add("div__section--days"); 73 | divDay.classList.add("section__div--singleDay"); 74 | 75 | if(initialDay == 0){ 76 | initialDay = 7 77 | } 78 | if (i >= initialDay && (door == 0)) { 79 | 80 | sectionDay.setAttribute("id", `${day}`); 81 | divDay.textContent = day; 82 | idButtonDay = "addDay" + day; 83 | //Add the class, id and tabindex to each button plus day event 84 | buttonEvent.setAttribute("class","buttonDay"); 85 | buttonEvent.setAttribute("tabindex", `${day}`); 86 | buttonEvent.setAttribute("id", idButtonDay); 87 | buttonEvent.setAttribute("type", "button") 88 | 89 | sectionDay.appendChild(divDay); 90 | sectionDay.appendChild(buttonEvent); 91 | 92 | if (divDay.textContent == date.getDate() && currentMonth.textContent == month[date.getMonth()] && currentYearCalendar.textContent == date.getFullYear()) { 93 | divDay.classList.add("section__div--currentDay"); 94 | } 95 | 96 | if (sectionDay.getAttribute("id") === diasMeses.toString()) { 97 | door = 1; 98 | } 99 | 100 | day++; 101 | 102 | } 103 | 104 | gridMonth.appendChild(sectionDay); 105 | if(i >= diasMeses+initialDay-1 && i%7==0){ 106 | i = 43; 107 | } 108 | } 109 | addEventDay(monthEvents, arrayHours); 110 | document.querySelectorAll(".section__div--singleDay").forEach(section=>{ 111 | section.addEventListener("click", function(){ 112 | showDialogDayEvents(section); 113 | }) 114 | }) 115 | }; 116 | 117 | function getYear(current, last, date){ 118 | const year = document.getElementById("currentYear"); 119 | 120 | if(flag == 0){ 121 | year.textContent = date.getFullYear(); 122 | flag = 1; 123 | } 124 | 125 | if(current === "December" && last === "January"){ 126 | year.textContent = `${parseInt(year.textContent) - 1}`; 127 | }else if(current === "January" && last === "December"){ 128 | year.textContent = `${parseInt(year.textContent) + 1}`; 129 | } 130 | } 131 | export { getMonth , monthEvents }; 132 | -------------------------------------------------------------------------------- /src/JS/script.js: -------------------------------------------------------------------------------- 1 | import { getMonth } from "./getMonth.js"; 2 | import { saveData, clearData, getEventData, addEventDay } from "./saveData.js"; 3 | import { createEventFromDay } from "./modalFromDay.js" 4 | import {clearAsideEvent} from "./clearAside.js" 5 | import {showDialogDayEvents} from "./showDialog.js" 6 | let counter = 1; 7 | 8 | getMonth(counter); 9 | getEventData(); 10 | 11 | const overlay = document.getElementById("blurModal"); 12 | const buttonNextMonth = document.getElementById("button-next--month"); 13 | const buttonBackMonth = document.getElementById("button-back--month"); 14 | const divMonth = document.getElementById("section__div--gridMonth"); 15 | const form = document.getElementById("mainSectionModal"); 16 | const buttonDayListAddEvent = document.querySelectorAll(".buttonDay"); 17 | let deleteButtonEventList = document.querySelectorAll("[data-delete]"); 18 | overlay.addEventListener("click", closeModal); 19 | buttonNextMonth.addEventListener("click", switchMonth); 20 | buttonBackMonth.addEventListener("click", switchMonthBack); 21 | 22 | //Listener to Open The model Form 23 | const buttonHeaderEvent = document 24 | .getElementById("headerCreateEvent") 25 | .addEventListener("click", createEvent); 26 | 27 | //Listener to close the modal Form 28 | const buttonCloseEvent = document 29 | .getElementById("button-close--form") 30 | .addEventListener("click", closeForm); 31 | 32 | //CLOSE MODAL WITH ESCAPE KEYBOARD 33 | document.addEventListener("keydown", function (e) { 34 | if (e.key === "Escape" && !overlay.classList.contains("hide")) { 35 | form.classList.add("hide"); 36 | overlay.classList.add("hide"); 37 | } 38 | 39 | if (e.key === "Enter" && !overlay.classList.contains("hide")) { 40 | form.classList.remove("hide"); 41 | overlay.classList.remove("hide"); 42 | } 43 | }); 44 | 45 | //Listener to save the form DATA 46 | // document 47 | 48 | document 49 | .getElementById("button-create--event") 50 | .addEventListener("click", function(){ 51 | saveData(); 52 | deleteButtonEventList = document.querySelectorAll("[data-delete]"); 53 | addListenerButtonDelete(); 54 | }); 55 | 56 | //Clear form 57 | document.getElementById("button-cancel--event").addEventListener("click", clearData); 58 | 59 | //Listener for buttonAddDay to Open the modal and passing the corresponding date 60 | Array.from(buttonDayListAddEvent).forEach(element =>{ 61 | document.getElementById(element.getAttribute("id")).addEventListener("click",function(){ 62 | createEventFromDay(element) 63 | }) 64 | }); 65 | 66 | //Listener for buttonDelete aside Events 67 | function addListenerButtonDelete(){ 68 | Array.from(deleteButtonEventList).forEach(eButton =>{ 69 | document.getElementById(eButton.getAttribute("id")).addEventListener("click", function(){ 70 | clearAsideEvent(eButton); 71 | deleteButtonEventList = document.querySelectorAll("[data-delete]"); 72 | addListenerButtonDelete(); 73 | }) 74 | }); 75 | } 76 | 77 | //Listener for section days to display dialog single day event 78 | document.querySelectorAll(".section__div--singleDay").forEach(section=>{ 79 | section.addEventListener("click", function(){ 80 | showDialogDayEvents(section); 81 | }) 82 | }) 83 | 84 | 85 | //FUNCTIONS 86 | function createEvent() { 87 | const startDate = document.querySelector("#start-date"); 88 | startDate.value = ""; 89 | form.classList.toggle("hide"); 90 | overlay.classList.toggle("hide"); 91 | } 92 | 93 | function closeForm() { 94 | form.classList.toggle("hide"); 95 | overlay.classList.toggle("hide"); 96 | } 97 | 98 | function closeModal() { 99 | form.classList.toggle("hide"); 100 | overlay.classList.toggle("hide"); 101 | } 102 | 103 | function switchMonth() { 104 | counter++; 105 | 106 | if (divMonth.hasChildNodes) { 107 | const childrens = document.querySelectorAll(".div__section--days"); 108 | Array.from(childrens).forEach((children) => { 109 | divMonth.removeChild(children); 110 | }); 111 | 112 | getMonth(counter); 113 | Array.from(buttonDayListAddEvent).forEach(element =>{ 114 | document.getElementById(element.getAttribute("id")).addEventListener("click",function(){ 115 | createEventFromDay(element) 116 | }) 117 | }); 118 | } else { 119 | getMonth(counter); 120 | } 121 | } 122 | 123 | function switchMonthBack() { 124 | counter--; 125 | 126 | if (divMonth.hasChildNodes) { 127 | const childrens = document.querySelectorAll(".div__section--days"); 128 | Array.from(childrens).forEach((children) => { 129 | divMonth.removeChild(children); 130 | }); 131 | 132 | getMonth(counter); 133 | Array.from(buttonDayListAddEvent).forEach(element =>{ 134 | document.getElementById(element.getAttribute("id")).addEventListener("click",function(){ 135 | createEventFromDay(element) 136 | }) 137 | }); 138 | } else { 139 | getMonth(counter); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/JS/showDialog.js: -------------------------------------------------------------------------------- 1 | export function showDialogDayEvents(section){ 2 | const eventDay = JSON.parse(localStorage.getItem("calendar_events")); 3 | const month = document.getElementById("currentMonth").textContent; 4 | const year = document.getElementById("currentYear").textContent; 5 | const main = document.getElementById("main__container"); 6 | const buttonCloseDialog = document.createElement("button"); 7 | const dialog = document.createElement("dialog"); 8 | dialog.setAttribute("class", "main__dialog--Event"); 9 | 10 | if(eventDay != null){ 11 | //Check if the div has events to show 12 | let divDay = document.getElementById(section.textContent);//number of day 13 | let divDayValue = divDay.getAttribute("id"); 14 | if(parseInt(divDay)<10){ 15 | divDay = "0"+divDay; 16 | } 17 | const eventsDay = divDay.querySelectorAll(".section__span--span"); 18 | if(eventsDay.length != 0){//Exists events in the day 19 | //run in localStorage to get the vents of the day 20 | Array.from(eventDay).forEach(element => { 21 | let dayEvent = parseInt(element.startDate.date.split("-")[2]); 22 | let monthEvent = element.startDate.date.split("-")[1]; 23 | let yearEvent = element.startDate.date.split("-")[0]; 24 | if(dayEvent == divDayValue && monthEvent == obtainMonth(month) && year == yearEvent){ 25 | const article = document.createElement("article"); 26 | article.setAttribute("class", "aside__article--Event"); 27 | const pTitle = document.createElement("p"); 28 | const pTime = document.createElement("p"); 29 | const pDescription = document.createElement("p"); 30 | const pTypeEvent = document.createElement("p"); 31 | pTitle.textContent = element.title; 32 | pTime.textContent = element.startDate.time; 33 | pDescription.textContent = element.description; 34 | pTypeEvent.textContent = element.typeEvent; 35 | article.appendChild(pTitle); 36 | article.appendChild(pTime); 37 | article.appendChild(pDescription); 38 | article.appendChild(pTypeEvent); 39 | buttonCloseDialog.setAttribute("id", "buttonCloseDialog"); 40 | buttonCloseDialog.setAttribute("class", "buttonCloseDialog"); 41 | buttonCloseDialog.textContent="X"; 42 | dialog.prepend(buttonCloseDialog); 43 | dialog.appendChild(article); 44 | dialog.setAttribute("open", ""); 45 | main.appendChild(dialog); 46 | } 47 | }); 48 | }else{ 49 | let message = document.createElement("p"); 50 | message.textContent = "No events to show"; 51 | dialog.appendChild(message); 52 | buttonCloseDialog.setAttribute("id", "buttonCloseDialog"); 53 | buttonCloseDialog.setAttribute("class", "buttonCloseDialog"); 54 | buttonCloseDialog.textContent="X"; 55 | dialog.setAttribute("open", ""); 56 | dialog.prepend(buttonCloseDialog); 57 | main.appendChild(dialog); 58 | } 59 | }else{ 60 | //Open dialog with "no events to show" message 61 | } 62 | buttonCloseDialog.addEventListener("click", function(){ 63 | dialog.removeAttribute("open"); 64 | // getEventData(); 65 | main.removeChild(dialog); 66 | }) 67 | 68 | } 69 | 70 | function obtainMonth(actualMonth){ 71 | let newMonth = new Date().getMonth(); 72 | switch(actualMonth){ 73 | case "January": 74 | actualMonth = "01"; 75 | break; 76 | case "Februyary": 77 | actualMonth = "02"; 78 | break; 79 | case "March": 80 | actualMonth = "03"; 81 | break; 82 | case "April": 83 | actualMonth = "04"; 84 | break; 85 | case "May": 86 | actualMonth = "05"; 87 | break; 88 | case "June": 89 | actualMonth = "06"; 90 | break; 91 | case "July": 92 | actualMonth = "07"; 93 | break; 94 | case "August": 95 | actualMonth = "08"; 96 | break; 97 | case "September": 98 | actualMonth = "09"; 99 | break; 100 | case "October": 101 | actualMonth = "10"; 102 | break; 103 | case "November": 104 | actualMonth = "11"; 105 | break; 106 | case "December": 107 | actualMonth = "12"; 108 | break; 109 | } 110 | return actualMonth; 111 | } 112 | -------------------------------------------------------------------------------- /src/CSS/calendar.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: "Open Sans", sans-serif; 3 | } 4 | 5 | /* HEADER SECTION */ 6 | .body__header { 7 | display: flex; 8 | justify-content: space-around; 9 | align-items: center; 10 | padding: 1rem; 11 | } 12 | 13 | .header__h1--tittle { 14 | color: #323232; 15 | } 16 | .header__calendar--icon { 17 | height: 2.75rem; 18 | } 19 | .header__button--create { 20 | background-color: #9d6ccb; 21 | box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.266); 22 | border: 1px solid rgb(175, 173, 173); 23 | color: #ffffff; 24 | border-radius: 5px; 25 | font-size: 2.75rem; 26 | font-weight: 600; 27 | letter-spacing: 1.2px; 28 | padding: 1rem; 29 | cursor: pointer; 30 | } 31 | 32 | .header__button--create:hover { 33 | font-weight: 600; 34 | color: #9d6ccb; 35 | background-color: #ffffff; 36 | } 37 | 38 | .body__div--separator { 39 | border: 0.7px solid rgb(175, 173, 173); 40 | -webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.2); 41 | -moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.2); 42 | box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.2); 43 | } 44 | 45 | .main__container { 46 | display: grid; 47 | grid-template-columns: 1fr 4fr; 48 | padding: 1rem; 49 | position: relative; 50 | } 51 | 52 | /* ASIDE SECTION */ 53 | .main__aside--aside-events { 54 | display: flex; 55 | flex-direction: column; 56 | align-items: flex-start; 57 | background-color: #9d6ccb; 58 | color: #ffffff; 59 | font-weight: 600; 60 | letter-spacing: 1.4px; 61 | padding: 1.5rem; 62 | } 63 | 64 | .aside__article--Event { 65 | line-height: 0.8rem; 66 | width: 90%; 67 | border: 1px solid #ccc; 68 | border-radius: 5px; 69 | font-size: 18px; 70 | font-weight: 400; 71 | letter-spacing: 1.2px; 72 | padding: 1.5rem; 73 | margin-top: 1rem; 74 | position: relative; 75 | } 76 | 77 | .article__button--deleteEvent { 78 | background-color: transparent; 79 | border: none; 80 | position: absolute; 81 | top: 0; 82 | right: 0; 83 | margin-top: 1rem; 84 | margin-right: 1rem; 85 | height: 2.75rem; 86 | stroke: #f3f3f3; 87 | } 88 | 89 | /* FINISH ASIDE SECTION */ 90 | .section__div--weekDays { 91 | font-size: 1.6rem; 92 | color: #323232c2; 93 | padding: 1.2rem; 94 | } 95 | .main__section--calendarContainer { 96 | border-left: 1px solid rgb(236, 231, 231); 97 | padding: 1rem; 98 | display: flex; 99 | flex-direction: column; 100 | justify-content: space-around; 101 | } 102 | 103 | .div__h5--month, 104 | .div__h5--year { 105 | font-size: 1.8rem; 106 | color: #323232c2; 107 | } 108 | 109 | .div__button--switchMonth { 110 | height: 2.75rem; 111 | /* border: 1px solid black; */ 112 | padding: 0.5em; 113 | cursor: pointer; 114 | font-weight: bold; 115 | } 116 | 117 | .div__button--switchMonth:hover { 118 | background-color: rgb(240, 236, 236); 119 | border-radius: 50%; 120 | } 121 | 122 | .section__div--switchMonth { 123 | border-bottom: 1px solid #ccc; 124 | display: flex; 125 | justify-content: space-around; 126 | align-items: center; 127 | padding-bottom: 1rem; 128 | } 129 | 130 | .section__div--weekDays { 131 | display: grid; 132 | margin-top: 2rem; 133 | margin-bottom: 2rem; 134 | grid-template-columns: repeat(7, 1fr); 135 | } 136 | 137 | .div__span--Day { 138 | display: flex; 139 | justify-content: center; 140 | align-items: center; 141 | font-weight: bold; 142 | } 143 | 144 | .section__div--gridMonth { 145 | display: grid; 146 | row-gap: 0.1rem; 147 | column-gap: 0.1rem; 148 | grid-template-columns: repeat(7, 1fr); 149 | grid-template-rows: repeat(6, 1fr); 150 | } 151 | 152 | .div__section--days { 153 | position: relative; 154 | border: 1px solid #ccc; 155 | display: flex; 156 | flex-direction: column; 157 | justify-content: flex-start; 158 | align-items: center; 159 | width: 15rem; 160 | height: 7.5rem; 161 | } 162 | 163 | .div__section--days:hover .buttonDay { 164 | display: flex; 165 | } 166 | 167 | .buttonDay { 168 | display: none; 169 | justify-content: center; 170 | align-items: center; 171 | border: 1px solid #ccc; 172 | border-radius: 100%; 173 | background-color: transparent; 174 | font-weight: bold; 175 | position: absolute; 176 | top: 5%; 177 | left: 80%; 178 | cursor: pointer; 179 | height: 2.75rem; 180 | width: 2.75rem; 181 | } 182 | 183 | .section__div--singleDay { 184 | margin-top: 5px; 185 | font-size: 1.8rem; 186 | color: #323232c2; 187 | font-weight: 600; 188 | margin-bottom: 1rem; 189 | cursor: pointer; 190 | } 191 | 192 | .section__div--currentDay { 193 | text-align: center; 194 | font-size: 2.4rem; 195 | color: #f3f3f3; 196 | width: 20%; 197 | background-color: #7a549e; 198 | border-bottom: 1px solid #ccc; 199 | border-radius: 50%; 200 | padding: 0.2rem; 201 | } 202 | 203 | .section__div--span { 204 | width: 100%; 205 | display: flex; 206 | flex-direction: column; 207 | } 208 | 209 | .section__span--span { 210 | padding-left: 1rem; 211 | border-bottom: 1px solid #ccc; 212 | } 213 | 214 | 215 | .main__dialog--Event{ 216 | width: 35rem; 217 | height: 15rem; 218 | position: absolute; 219 | top:30%; 220 | left:10%; 221 | overflow-y: scroll; 222 | } 223 | 224 | /* */ 225 | 226 | .main__dialog--Event::-webkit-scrollbar { 227 | -webkit-appearance: none; 228 | } 229 | 230 | .main__dialog--Event::-webkit-scrollbar:vertical { 231 | width: 10px; 232 | } 233 | 234 | .main__dialog--Event::-webkit-scrollbar-button:increment, 235 | .main__dialog--Event::-webkit-scrollbar-button { 236 | display: none; 237 | } 238 | 239 | .main__dialog--Event::-webkit-scrollbar:horizontal { 240 | height: 10px; 241 | } 242 | 243 | .main__dialog--Event::-webkit-scrollbar-thumb { 244 | background-color: #7a549e; 245 | border-radius: 20px; 246 | border: 1px solid var(--primary-color); 247 | } 248 | 249 | .main__dialog--Event::-webkit-scrollbar-track { 250 | border-radius: 10px; 251 | } 252 | 253 | .buttonCloseDialog{ 254 | background-color: transparent; 255 | border: 1px solid #7a549e; 256 | border-radius: 50%; 257 | width: 2.75rem; 258 | height: 2.75rem; 259 | font-size: 2rem; 260 | font-weight: bold; 261 | } 262 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | JS Calendar 16 | 17 | 18 |
19 |

JS Calendar

20 | 28 | 33 | 34 | 37 |
38 |
39 |
40 | 47 |
48 |
49 | 58 | 63 | 64 | 67 |
Month
68 |
Year
69 | 72 | 81 | 86 | 87 |
88 |
89 | Monday 90 | Tuesday 91 | Wednesday 92 | Thursday 93 | Friday 94 | Saturday 95 | Sunday 96 |
97 |
98 | 99 | 100 | 110 |
111 |
112 | 113 |
114 |
115 | 124 | 129 | 130 | 133 |
134 | 135 |
136 | 145 | 154 | 155 | 165 | 176 | 185 |
186 | 193 | 200 |
201 |
202 |
203 |
204 |
205 | 206 | 207 | -------------------------------------------------------------------------------- /src/CSS/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ 2 | 3 | /* Document 4 | ========================================================================== */ 5 | 6 | /** 7 | * 1. Correct the line height in all browsers. 8 | * 2. Prevent adjustments of font size after orientation changes in iOS. 9 | */ 10 | 11 | html { 12 | line-height: 1.15; /* 1 */ 13 | -webkit-text-size-adjust: 100%; /* 2 */ 14 | } 15 | 16 | /* Sections 17 | ========================================================================== */ 18 | 19 | /** 20 | * Remove the margin in all browsers. 21 | */ 22 | 23 | body { 24 | margin: 0; 25 | } 26 | 27 | /** 28 | * Render the `main` element consistently in IE. 29 | */ 30 | 31 | main { 32 | display: block; 33 | } 34 | 35 | /** 36 | * Correct the font size and margin on `h1` elements within `section` and 37 | * `article` contexts in Chrome, Firefox, and Safari. 38 | */ 39 | 40 | h1 { 41 | font-size: 2em; 42 | margin: 0.67em 0; 43 | } 44 | 45 | /* Grouping content 46 | ========================================================================== */ 47 | 48 | /** 49 | * 1. Add the correct box sizing in Firefox. 50 | * 2. Show the overflow in Edge and IE. 51 | */ 52 | 53 | hr { 54 | box-sizing: content-box; /* 1 */ 55 | height: 0; /* 1 */ 56 | overflow: visible; /* 2 */ 57 | } 58 | 59 | /** 60 | * 1. Correct the inheritance and scaling of font size in all browsers. 61 | * 2. Correct the odd `em` font sizing in all browsers. 62 | */ 63 | 64 | pre { 65 | font-family: monospace, monospace; /* 1 */ 66 | font-size: 1em; /* 2 */ 67 | } 68 | 69 | /* Text-level semantics 70 | ========================================================================== */ 71 | 72 | /** 73 | * Remove the gray background on active links in IE 10. 74 | */ 75 | 76 | a { 77 | background-color: transparent; 78 | } 79 | 80 | /** 81 | * 1. Remove the bottom border in Chrome 57- 82 | * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. 83 | */ 84 | 85 | abbr[title] { 86 | border-bottom: none; /* 1 */ 87 | text-decoration: underline; /* 2 */ 88 | text-decoration: underline dotted; /* 2 */ 89 | } 90 | 91 | /** 92 | * Add the correct font weight in Chrome, Edge, and Safari. 93 | */ 94 | 95 | b, 96 | strong { 97 | font-weight: bolder; 98 | } 99 | 100 | /** 101 | * 1. Correct the inheritance and scaling of font size in all browsers. 102 | * 2. Correct the odd `em` font sizing in all browsers. 103 | */ 104 | 105 | code, 106 | kbd, 107 | samp { 108 | font-family: monospace, monospace; /* 1 */ 109 | font-size: 1em; /* 2 */ 110 | } 111 | 112 | /** 113 | * Add the correct font size in all browsers. 114 | */ 115 | 116 | small { 117 | font-size: 80%; 118 | } 119 | 120 | /** 121 | * Prevent `sub` and `sup` elements from affecting the line height in 122 | * all browsers. 123 | */ 124 | 125 | sub, 126 | sup { 127 | font-size: 75%; 128 | line-height: 0; 129 | position: relative; 130 | vertical-align: baseline; 131 | } 132 | 133 | sub { 134 | bottom: -0.25em; 135 | } 136 | 137 | sup { 138 | top: -0.5em; 139 | } 140 | 141 | /* Embedded content 142 | ========================================================================== */ 143 | 144 | /** 145 | * Remove the border on images inside links in IE 10. 146 | */ 147 | 148 | img { 149 | border-style: none; 150 | } 151 | 152 | /* Forms 153 | ========================================================================== */ 154 | 155 | /** 156 | * 1. Change the font styles in all browsers. 157 | * 2. Remove the margin in Firefox and Safari. 158 | */ 159 | 160 | button, 161 | input, 162 | optgroup, 163 | select, 164 | textarea { 165 | font-family: inherit; /* 1 */ 166 | font-size: 100%; /* 1 */ 167 | line-height: 1.15; /* 1 */ 168 | margin: 0; /* 2 */ 169 | } 170 | 171 | /** 172 | * Show the overflow in IE. 173 | * 1. Show the overflow in Edge. 174 | */ 175 | 176 | button, 177 | input { /* 1 */ 178 | overflow: visible; 179 | } 180 | 181 | /** 182 | * Remove the inheritance of text transform in Edge, Firefox, and IE. 183 | * 1. Remove the inheritance of text transform in Firefox. 184 | */ 185 | 186 | button, 187 | select { /* 1 */ 188 | text-transform: none; 189 | } 190 | 191 | /** 192 | * Correct the inability to style clickable types in iOS and Safari. 193 | */ 194 | 195 | button, 196 | [type="button"], 197 | [type="reset"], 198 | [type="submit"] { 199 | -webkit-appearance: button; 200 | } 201 | 202 | /** 203 | * Remove the inner border and padding in Firefox. 204 | */ 205 | 206 | button::-moz-focus-inner, 207 | [type="button"]::-moz-focus-inner, 208 | [type="reset"]::-moz-focus-inner, 209 | [type="submit"]::-moz-focus-inner { 210 | border-style: none; 211 | padding: 0; 212 | } 213 | 214 | /** 215 | * Restore the focus styles unset by the previous rule. 216 | */ 217 | 218 | button:-moz-focusring, 219 | [type="button"]:-moz-focusring, 220 | [type="reset"]:-moz-focusring, 221 | [type="submit"]:-moz-focusring { 222 | outline: 1px dotted ButtonText; 223 | } 224 | 225 | /** 226 | * Correct the padding in Firefox. 227 | */ 228 | 229 | fieldset { 230 | padding: 0.35em 0.75em 0.625em; 231 | } 232 | 233 | /** 234 | * 1. Correct the text wrapping in Edge and IE. 235 | * 2. Correct the color inheritance from `fieldset` elements in IE. 236 | * 3. Remove the padding so developers are not caught out when they zero out 237 | * `fieldset` elements in all browsers. 238 | */ 239 | 240 | legend { 241 | box-sizing: border-box; /* 1 */ 242 | color: inherit; /* 2 */ 243 | display: table; /* 1 */ 244 | max-width: 100%; /* 1 */ 245 | padding: 0; /* 3 */ 246 | white-space: normal; /* 1 */ 247 | } 248 | 249 | /** 250 | * Add the correct vertical alignment in Chrome, Firefox, and Opera. 251 | */ 252 | 253 | progress { 254 | vertical-align: baseline; 255 | } 256 | 257 | /** 258 | * Remove the default vertical scrollbar in IE 10+. 259 | */ 260 | 261 | textarea { 262 | overflow: auto; 263 | } 264 | 265 | /** 266 | * 1. Add the correct box sizing in IE 10. 267 | * 2. Remove the padding in IE 10. 268 | */ 269 | 270 | [type="checkbox"], 271 | [type="radio"] { 272 | box-sizing: border-box; /* 1 */ 273 | padding: 0; /* 2 */ 274 | } 275 | 276 | /** 277 | * Correct the cursor style of increment and decrement buttons in Chrome. 278 | */ 279 | 280 | [type="number"]::-webkit-inner-spin-button, 281 | [type="number"]::-webkit-outer-spin-button { 282 | height: auto; 283 | } 284 | 285 | /** 286 | * 1. Correct the odd appearance in Chrome and Safari. 287 | * 2. Correct the outline style in Safari. 288 | */ 289 | 290 | [type="search"] { 291 | -webkit-appearance: textfield; /* 1 */ 292 | outline-offset: -2px; /* 2 */ 293 | } 294 | 295 | /** 296 | * Remove the inner padding in Chrome and Safari on macOS. 297 | */ 298 | 299 | [type="search"]::-webkit-search-decoration { 300 | -webkit-appearance: none; 301 | } 302 | 303 | /** 304 | * 1. Correct the inability to style clickable types in iOS and Safari. 305 | * 2. Change font properties to `inherit` in Safari. 306 | */ 307 | 308 | ::-webkit-file-upload-button { 309 | -webkit-appearance: button; /* 1 */ 310 | font: inherit; /* 2 */ 311 | } 312 | 313 | /* Interactive 314 | ========================================================================== */ 315 | 316 | /* 317 | * Add the correct display in Edge, IE 10+, and Firefox. 318 | */ 319 | 320 | details { 321 | display: block; 322 | } 323 | 324 | /* 325 | * Add the correct display in all browsers. 326 | */ 327 | 328 | summary { 329 | display: list-item; 330 | } 331 | 332 | /* Misc 333 | ========================================================================== */ 334 | 335 | /** 336 | * Add the correct display in IE 10+. 337 | */ 338 | 339 | template { 340 | display: none; 341 | } 342 | 343 | /** 344 | * Add the correct display in IE 10. 345 | */ 346 | 347 | [hidden] { 348 | display: none; 349 | } 350 | -------------------------------------------------------------------------------- /src/JS/saveData.js: -------------------------------------------------------------------------------- 1 | import { monthEvents } from "./getMonth.js" 2 | 3 | let titleEvent = document.getElementById("title-event"); 4 | let startDate = document.getElementById("start-date"); 5 | let timeRemindEvent = document.getElementById("time"); 6 | let description = document.getElementById("textarea-description"); 7 | let typeEvent = document.getElementById("Meeting"); 8 | let asideEvents = document.getElementById("aside-events"); 9 | const asidePempty = document.getElementById('aside-p-empty') 10 | const form = document.getElementById("mainSectionModal"); 11 | const overlay = document.getElementById("blurModal"); 12 | const year = document.getElementById("currentYear"); 13 | let months; 14 | let control = 0; 15 | let arrayHours = []; 16 | let daySection = ""; 17 | let idEvent = 1; 18 | let arrData = []; 19 | 20 | if (localStorage.length !== 0) { 21 | arrData = JSON.parse(localStorage.getItem("calendar_events")); 22 | 23 | 24 | } 25 | 26 | function saveData() { 27 | if(JSON.parse(localStorage.getItem("calendar_events")) != null){ 28 | idEvent = JSON.parse(localStorage.getItem("calendar_events")).length+1; 29 | arrData = JSON.parse(localStorage.getItem("calendar_events")); 30 | } 31 | let timeSplit = startDate.value.split("T"); 32 | let objData = { 33 | title: titleEvent.value, 34 | startDate: { 35 | time: timeSplit[1], 36 | date: timeSplit[0], 37 | }, 38 | timeRemindEvent: timeRemindEvent.value, 39 | description: description.value, 40 | typeEvent: typeEvent.value, 41 | id:idEvent, 42 | }; 43 | if(JSON.parse(localStorage.getItem("calendar_events")) == null){ 44 | arrData = []; 45 | } 46 | if((JSON.parse(localStorage.getItem("calendar_events")) != null && JSON.parse(localStorage.getItem("calendar_events")).length == 0)){ 47 | arrData = JSON.parse(localStorage.getItem("calendar_events")); 48 | } 49 | 50 | if((JSON.parse(localStorage.getItem("calendar_events")) != null && JSON.parse(localStorage.getItem("calendar_events")).length != 0)){ 51 | let localEvents = JSON.parse(localStorage.getItem("calendar_events")); 52 | localEvents.forEach(event =>{ 53 | daySection = document.getElementById(`${parseInt(objData.startDate.date.split('-')[2])}`); 54 | 55 | if(!arrayHours.includes(objData.startDate.time) && (daySection.getAttribute("id") == parseInt(objData.startDate.date.split("-")[2]))){ 56 | arrData.push(objData); 57 | orderLocal(arrData) 58 | localStorage.setItem("calendar_events", JSON.stringify(arrData)); 59 | getEventData(); 60 | addEventDay(months, arrayHours); 61 | } 62 | }); 63 | }else{ 64 | 65 | arrData.push(objData); 66 | orderLocal(arrData) 67 | localStorage.setItem("calendar_events", JSON.stringify(arrData)); 68 | getEventData(); 69 | addEventDay(months, arrayHours); 70 | } 71 | overlay.classList.add('hide'); 72 | 73 | form.classList.add('hide'); 74 | } 75 | 76 | function addEventDay(monthEvents, array) { 77 | months = monthEvents; 78 | arrayHours = array; 79 | 80 | //we get localStorage item 81 | const events = JSON.parse(localStorage.getItem("calendar_events")); 82 | //loop localStorage 83 | if (events != null) { //if localStorage is not empty 84 | 85 | events.forEach(eventsLocal => { //recorremos el localStorage con este bucle 86 | 87 | if ((parseInt(eventsLocal.startDate.date.split('-')[1]) == months + 1) && (year.textContent == eventsLocal.startDate.date.split('-')[0])) { //comprobamos si el mes del evento que está en el local es igual al mes actual 88 | const daySection = document.getElementById(`${parseInt(eventsLocal.startDate.date.split('-')[2])}`); //obtenemos el dia del evento 89 | 90 | 91 | if (daySection.hasChildNodes()) { //si el daySection tiene hijos hacemos una comprobacion de daySection 92 | 93 | if (daySection.querySelector('.section__div--span') == null) { //comprobamos si daySection tiene hijos con la clase section__div--span 94 | //creamos el hijo en caso de que de null 95 | const divEvents = document.createElement('div'); 96 | divEvents.setAttribute('class', 'section__div--span'); 97 | 98 | 99 | if(divEvents.querySelectorAll('.section__span--span').length == 0){ 100 | const span = document.createElement('span'); 101 | span.setAttribute('class', 'section__span--span'); 102 | span.textContent = `${eventsLocal.title}-${eventsLocal.startDate.time}`; 103 | divEvents.appendChild(span); 104 | daySection.appendChild(divEvents); 105 | arrayHours.push(eventsLocal.startDate.time); 106 | } 107 | }else{ 108 | for(let i = 0; i < events.length; i++){ 109 | if(!arrayHours.includes(events[i].startDate.time) && (daySection.getAttribute("id") == parseInt(events[i].startDate.date.split("-")[2]))){ 110 | let divEvents = daySection.querySelector(".section__div--span"); 111 | const span = document.createElement('span'); 112 | span.setAttribute('class', 'section__span--span'); 113 | span.textContent = `${events[i].title}-${events[i].startDate.time}`; 114 | divEvents.appendChild(span); 115 | arrayHours.push(events[i].startDate.time); 116 | } 117 | } 118 | } 119 | } 120 | } 121 | }); 122 | control = 0; 123 | } 124 | 125 | } 126 | 127 | function orderLocal(arrData) { 128 | arrData.sort((a, b) => new Date(a.startDate.date).getTime() - new Date(b.startDate.date).getTime()); 129 | } 130 | 131 | 132 | function getEventData() { 133 | let events = JSON.parse(localStorage.getItem("calendar_events")); 134 | 135 | const date = new Date(); 136 | 137 | if (localStorage.getItem("calendar_events") != null) { 138 | 139 | 140 | 141 | if (asideEvents.hasChildNodes) { 142 | 143 | 144 | const articles = document.querySelectorAll('.aside__article--Event'); 145 | 146 | articles.forEach(children => { 147 | asideEvents.removeChild(children) 148 | }) 149 | 150 | 151 | } 152 | 153 | let counterId = 1; 154 | let counterIdButton = 1; 155 | events.forEach((element) => { 156 | 157 | let eventArticle = document.createElement("article"); 158 | eventArticle.className = "aside__article--Event" 159 | let eventTitle = element.title; 160 | let eventDate = element.startDate.date; 161 | let eventTime = element.startDate.time; 162 | let eventDescription = element.description; 163 | let typeEvent = element.typeEvent; 164 | let buttonDeleteEvent = document.createElement("button"); 165 | let idButtonDelete = "buttonDelete-"; 166 | let i = 0; 167 | 168 | while (i < 5) { 169 | idButtonDelete = idButtonDelete + counterId; 170 | let eventInfo = document.createElement("p"); 171 | switch (i) { 172 | case 0: 173 | const img = document.createElement("img"); 174 | img.setAttribute("src", "./src/img/4781812_bin_delete_file_garbage_recycle_icon.png"); 175 | img.setAttribute('class', 'button__img--bin'); 176 | buttonDeleteEvent.setAttribute("class", "article__button--deleteEvent"); 177 | buttonDeleteEvent.setAttribute("data-delete", counterIdButton);//idEvent, element.id 178 | buttonDeleteEvent.setAttribute("id", idButtonDelete); 179 | eventArticle.setAttribute("id", "aside__article--Event"+counterIdButton) 180 | buttonDeleteEvent.appendChild(img); 181 | eventInfo.setAttribute("id", "title-aside"); 182 | eventInfo.textContent = eventTitle; 183 | eventArticle.appendChild(buttonDeleteEvent); 184 | eventArticle.appendChild(eventInfo); 185 | break; 186 | case 1: 187 | eventInfo.setAttribute("id", "start-date-aside"); 188 | eventInfo.textContent = eventDate; 189 | eventArticle.appendChild(eventInfo); 190 | break; 191 | case 2: 192 | eventInfo.setAttribute("class", "start-time-aside"); 193 | eventInfo.textContent = eventTime; 194 | eventArticle.appendChild(eventInfo); 195 | break; 196 | case 3: 197 | eventInfo.setAttribute("id", "description-aside"); 198 | eventInfo.textContent = eventDescription; 199 | eventArticle.appendChild(eventInfo); 200 | break; 201 | case 4: 202 | eventInfo.setAttribute("id", "type-event-aside"); 203 | eventInfo.textContent = typeEvent; 204 | eventArticle.appendChild(eventInfo); 205 | break; 206 | } 207 | counterId++; 208 | i++; 209 | } 210 | asideEvents.appendChild(eventArticle); 211 | counterIdButton++; 212 | }); 213 | 214 | if (asideEvents.hasChildNodes) { 215 | 216 | const articles = document.querySelectorAll('.aside__article--Event'); 217 | 218 | 219 | if (articles.length != 0) { 220 | asidePempty.classList.add('hide') 221 | } else { 222 | asidePempty.classList.remove('hide') 223 | } 224 | 225 | } 226 | 227 | } 228 | } 229 | 230 | function clearData() { 231 | titleEvent.value = ""; 232 | startDate.value = ""; 233 | timeRemindEvent.value = "5"; 234 | description.value = ""; 235 | typeEvent.value = "meeting"; 236 | } 237 | 238 | export { saveData, clearData, getEventData, addEventDay }; 239 | --------------------------------------------------------------------------------