2023-06-26 03:54:25 +01:00
|
|
|
let dateOptions={month:"short",year:"numeric"},textareaLoaded=!1,editor=null;function goToPage(e){document.querySelectorAll(".editor section").forEach((t=>{t.style.display="none",t.id===e&&(t.style.display="block")}))}function addActiveClass(e){document.querySelectorAll("nav.sideNav ul li a").forEach((t=>{t.classList.remove("active"),t.id===e&&t.classList.add("active")}))}function showErrorMessage(e,t){document.querySelector(`#${t}Error`).classList.remove("hidden"),document.querySelector(`#${t}Error div`).innerText=e}function showSuccessMessage(e,t){document.querySelector(`#${t}Success`).classList.remove("hidden"),document.querySelector(`#${t}Success div`).innerText=e}function editCVItem(e){if(textareaLoaded=!1,document.querySelector(`#timelineItem${e}`).classList.toggle("editing"),e.includes("e"))return document.querySelector(`#grade${e}`).toggleAttribute("disabled"),void document.querySelector(`#course${e}`).toggleAttribute("disabled");document.querySelector(`#companyName${e}`).toggleAttribute("disabled"),document.querySelector(`#area${e}`).toggleAttribute("disabled"),document.querySelector(`#jobTitle${e}`).toggleAttribute("disabled")}function addEduData(e,t,o,r,n,a=!1){let d=e+"e",i=document.createElement("form");i.id="timelineItem"+d,i.classList.add("timelineItem"),i.onsubmit=t=>updateEduItem(e,t),i.innerHTML=`\n <div class="modifyBtnContainer">\n <button class="edit" type="button" id="edit${d}" onclick="editCVItem('${d}')"><i class="fa-solid fa-pen-to-square"></i></button>\n <button class="delete" type="button" id="delete${d}" onclick="deleteEduItem(${e})"><i class="fa-solid fa-trash"></i></button>\n </div>\n <div class="dateContainer formControl">\n <input type="date" name="dateFrom${d}" id="dateFrom${d}" onload="this.max = new Date().toISOString().split('T')[0]" value="${t}">\n -\n <input type="date" name="dateTo${d}" id="dateTo${d}" value="${o}">\n </div>\n <h3 class="timelineHeader" id="timelineHeader${d}">${new Date(t).toLocaleString("en-gb",dateOptions)} - ${new Date(o).toLocaleString("en-gb",dateOptions)}</h3>\n <div class="gradeContainer formControl">\n <label for="grade${d}">Grade:</label>\n <input type="text" name="grade${d}" id="grade${d}" value="${r}" disabled>\n </div>\n <div class="formControl">\n <textarea class="courseText" name="course${d}" id="course${d}" cols="10" rows="3" disabled>${n}</textarea>\n </div>\n \n <div class="error hidden" id="eduError${d}">\n <button class="close" type="button" onclick="this.parentElement.classList.toggle('hidden');">×</button>\n <div></div>\n </div>\n <input type="submit" value="Change">\n `,a?document.querySelector("#edu").prepend(i):document.getElementById("edu").appendChild(i)}function addWorkData(e,t,o,r,n,a,d=!1){let i=e+"w",c=document.createElement("form");c.id="timelineItem"+i,c.classList.add("timelineItem"),c.onsubmit=t=>updateWorkItem(e,t),c.innerHTML=`\n <div class="modifyBtnContainer">\n <button class="edit" type="button" id="edit${i}" onclick="editCVItem('${i}')"><i class="fa-solid fa-pen-to-square"></i></button>\n <button class="delete" type="button" id="delete${i}" onclick="deleteWorkItem(${e})"><i class="fa-solid fa-trash"></i></button>\n </div>\n <div class="dateContainer formControl">\n <input type="date" name="dateFrom${i}" id="dateFrom${i}" onload="this.max = new Date().toISOString().split('T')[0]" value="${t}">\n -\n <input type="date" name="dateTo${i}" id="dateTo${i}" value="${"Present"===o?"":o}">\n </div>\n <h3 class="timelineHeader" id="timelineHeader${i}">${new Date(t).toLocaleString("en-gb",dateOptions)} - ${"Present"===o?"Present":new Date(o).toLocaleString("en-gb",dateOptions)}</h3>\n <div class="companyAreaContainer formControl">\n <input type="text" name="companyName${i}" id="companyName${i}" value="${r}" disabled>\n -\n <input type="text" name="area${i}" id="area${i}" value="${n}" disabled> \n </div>\n <div class="form
|