Raffales-LMS/public/assets/js/pages/job-application.init.js

1 line
13 KiB
JavaScript
Raw Normal View History

2024-04-16 09:58:24 +00:00
var checkAll=document.getElementById("checkAll"),isChoiceEl=(checkAll&&(checkAll.onclick=function(){for(var e=document.querySelectorAll('.form-check-all input[type="checkbox"]'),t=document.querySelectorAll('.form-check-all input[type="checkbox"]:checked').length,a=0;a<e.length;a++)e[a].checked=this.checked,e[a].checked?e[a].closest("tr").classList.add("table-active"):e[a].closest("tr").classList.remove("table-active");document.getElementById("remove-actions").style.display=0<t?"none":"block"}),document.getElementById("idStatus")),choices=new Choices(isChoiceEl,{searchEnabled:!1}),isTypeEl=document.getElementById("idType"),choices=new Choices(isTypeEl,{searchEnabled:!1}),perPage=8,editlist=!1,options={valueNames:["id","company","designation","date","contacts","type","status"],page:perPage,pagination:!0,plugins:[ListPagination({left:2,right:2})]},applicationList=new List("applicationList",options).on("updated",function(e){0==e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="block":document.getElementsByClassName("noresult")[0].style.display="none";var t=1==e.i,a=e.i>e.matchingItems.length-e.page;document.querySelector(".pagination-prev.disabled")&&document.querySelector(".pagination-prev.disabled").classList.remove("disabled"),document.querySelector(".pagination-next.disabled")&&document.querySelector(".pagination-next.disabled").classList.remove("disabled"),t&&document.querySelector(".pagination-prev").classList.add("disabled"),a&&document.querySelector(".pagination-next").classList.add("disabled"),e.matchingItems.length<=perPage?document.querySelector(".pagination-wrap").style.display="none":document.querySelector(".pagination-wrap").style.display="flex",e.matchingItems.length==perPage&&document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(),0<e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="none":document.getElementsByClassName("noresult")[0].style.display="block"});const xhttp=new XMLHttpRequest;function isStatus(e){switch(e){case"Approved":return'<span class="badge badge-soft-success text-uppercase">'+e+"</span>";case"New":return'<span class="badge badge-soft-info text-uppercase">'+e+"</span>";case"Pending":return'<span class="badge badge-soft-warning text-uppercase">'+e+"</span>";case"Rejected":return'<span class="badge badge-soft-danger text-uppercase">'+e+"</span>"}}xhttp.onload=function(){var e=JSON.parse(this.responseText);Array.from(e).forEach(function(e){applicationList.add({id:'<a href="#" class="fw-medium link-primary">#VZ'+e.id+"</a>",company:'<div class="d-flex align-items-center"> <div class="flex-shrink-0"> <img src="'+e.company[0]+'" alt="" class="avatar-xxs rounded-circle image_src object-cover"> </div> <div class="flex-grow-1 ms-2 name">'+e.company[1]+"</div> </div>",designation:e.designation,date:e.date,contacts:e.contacts,type:e.type,status:isStatus(e.status)}),applicationList.sort("id",{order:"desc"}),refreshCallbacks()}),applicationList.remove("id",'<a href="#" class="fw-medium link-primary">#VZ001</a>')},xhttp.open("GET","assets/json/application-list.json"),xhttp.send(),document.querySelector("#companylogo-image-input").addEventListener("change",function(){var e=document.querySelector("#companylogo-img"),t=document.querySelector("#companylogo-image-input").files[0],a=new FileReader;a.addEventListener("load",function(){e.src=a.result},!1),t&&a.readAsDataURL(t)});var idField=document.getElementById("applicationId"),companyLogoImg=document.getElementById("companylogo-img"),companyField=document.getElementById("company-field"),designationField=document.getElementById("designation-field"),dateField=document.getElementById("date-field"),contactField=document.getElementById("contact-field"),statusField=document.getElementById("status-input"),typeField=document.getElementById("type-input"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns