2023-02-23 18:53:28 +00:00
|
|
|
let dateOptions={month:"short",year:"numeric"},textareaLoaded=!1;function showErrorMessage(e,t){document.querySelector(`#${t}Error`).classList.remove("hidden"),document.querySelector(`#${t}Error 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 i=e+"e",d=document.createElement("form");d.id="timelineItem"+i,d.classList.add("timelineItem"),d.onsubmit=t=>updateEduItem(e,t),d.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="deleteEduItem(${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="${o}">\n </div>\n <h3 class="timelineHeader" id="timelineHeader${i}">${new Date(t).toLocaleString("en-gb",dateOptions)} - ${new Date(o).toLocaleString("en-gb",dateOptions)}</h3>\n <div class="gradeContainer formControl">\n <label for="grade${i}">Grade:</label>\n <input type="text" name="grade${i}" id="grade${i}" value="${r}" disabled>\n </div>\n <div class="formControl">\n <textarea class="courseText" name="course${i}" id="course${i}" cols="10" rows="3" disabled>${n}</textarea>\n </div>\n \n <div class="error hidden" id="eduError${i}">\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(d):document.getElementById("edu").appendChild(d)}function addWorkData(e,t,o,r,n,a,i=!1){let d=e+"w",c=document.createElement("form");c.id="timelineItem"+d,c.classList.add("timelineItem"),c.onsubmit=t=>updateWorkItem(e,t),c.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="deleteWorkItem(${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="${"Present"===o?"":o}">\n </div>\n <h3 class="timelineHeader" id="timelineHeader${d}">${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${d}" id="companyName${d}" value="${r}" disabled>\n -\n <input type="text" name="area${d}" id="area${d}" value="${n}" disabled> \n </div>\n <div class="formControl">\n <textarea class="jobTitleText" name="jobTitle${d}" id="jobTitle${d}" cols="10" rows="3" disabled>${a}</textarea>\n </div>\n \n <div class="error hidden" id="workError${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\t`,i?document.querySelector("#work").prepend(c):document.getElement
|