var checkAll=document.getElementById("checkAll"),perPage=(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,i=0;ie.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"),i&&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",0#VZ'+e.id+"",name:e.name,owner:e.owner,desc:e.desc,industry_type:e.industry_type,star_value:e.star_value,location:e.location,employee:e.employee,website:e.website,contact_email:e.contact_email,since:e.since,image_src:e.image_src}),companyList.sort("id",{order:"desc"}),refreshCallbacks()}),companyList.remove("id",'#VZ001')},xhttp.open("GET","assets/json/company-list.json"),xhttp.send(),isCount=(new DOMParser).parseFromString(companyList.items.slice(-1)[0]._values.id,"text/html"),document.querySelector("#company-logo-input").addEventListener("change",function(){var e=document.querySelector("#companylogo-img"),t=document.querySelector("#company-logo-input").files[0],i=new FileReader;i.addEventListener("load",function(){e.src=i.result},!1),t&&i.readAsDataURL(t)});var isValue=isCount.body.firstElementChild.innerHTML,idField=document.getElementById("id-field"),companyNameField=document.getElementById("companyname-field"),companyLogoImg=document.getElementById("companylogo-img"),ownerField=document.getElementById("owner-field"),industry_typeField=document.getElementById("industry_type-field"),star_valueField=document.getElementById("star_value-field"),locationField=document.getElementById("location-field"),employeeField=document.getElementById("employee-field"),websiteField=document.getElementById("website-field"),contact_emailField=document.getElementById("contact_email-field"),sinceField=document.getElementById("since-field"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns=document.getElementsByClassName("edit-item-btn"),table=(viewBtns=document.getElementsByClassName("view-item-btn"),refreshCallbacks(),document.getElementById("showModal").addEventListener("show.bs.modal",function(e){e.relatedTarget.classList.contains("edit-item-btn")?(document.getElementById("exampleModalLabel").innerHTML="Edit Company",document.getElementById("showModal").querySelector(".modal-footer").style.display="block",document.getElementById("add-btn").innerHTML="Update"):e.relatedTarget.classList.contains("add-btn")?(document.getElementById("exampleModalLabel").innerHTML="Add Company",document.getElementById("showModal").querySelector(".modal-footer").style.display="block",document.getElementById("add-btn").innerHTML="Add Company"):(document.getElementById("exampleModalLabel").innerHTML="List Company",document.getElementById("showModal").querySelector(".modal-footer").style.display="none")}),ischeckboxcheck(),document.getElementById("showModal").addEventListener("hidden.bs.modal",function(){clearFields()}),document.querySelector("#companyList").addEventListener("click",function(){ischeckboxcheck()}),document.getElementById("customerTable")),tr=table.getElementsByTagName("tr"),trlist=table.querySelectorAll(".list tr"),count=11,forms=document.querySelectorAll(".tablelist-form");function ischeckboxcheck(){Array.from(document.getElementsByName("chk_child")).forEach(function(i){i.addEventListener("change",function(e){1==i.checked?e.target.closest("tr").classList.add("table-active"):e.target.closest("tr").classList.remove("table-active");var t=document.querySelectorAll('[name="chk_child"]:checked').length;e.target.closest("tr").classList.contains("table-active"),document.getElementById("remove-actions").style.display=0
${e._values.name}

${e._values.owner}

Information

${e._values.desc}

Industry Type ${e._values.industry_type}
Location ${e._values.location}
Employee ${e._values.employee}
Rating ${e._values.star_value}
Website ${e._values.website}
Contact Email ${e._values.contact_email}
Since ${e._values.since}
`,document.getElementById("company-view-detail").innerHTML=e)})})})}function clearFields(){companyLogoImg.src="assets/images/users/multi-user.jpg",companyNameField.value="",ownerField.value="",industry_typeField.value="",star_valueField.value="",locationField.value="",employeeField.value="",websiteField.value="",contact_emailField.value="",sinceField.value=""}function deleteMultiple(){ids_array=[];var e,t=document.getElementsByName("chk_child");for(i=0;i${ids_array[i]}`);document.getElementById("remove-actions").style.display="none",document.getElementById("checkAll").checked=!1,Swal.fire({title:"Deleted!",text:"Your data has been deleted.",icon:"success",confirmButtonClass:"btn btn-info w-xs mt-2",buttonsStyling:!1})}}):Swal.fire({title:"Please select at least one checkbox",confirmButtonClass:"btn btn-info",buttonsStyling:!1,showCloseButton:!0})}Array.prototype.slice.call(forms).forEach(function(i){i.addEventListener("submit",function(e){var t;i.checkValidity()?(e.preventDefault(),""===companyNameField.value||""===ownerField.value||""===industry_typeField.value||""===star_valueField.value||""===locationField.value||""===employeeField.value||""===websiteField.value||""===contact_emailField.value||""===sinceField.value||editlist?""!==companyNameField.value&&""!==ownerField.value&&""!==industry_typeField.value&&""!==star_valueField.value&&""!==locationField.value&&""!==employeeField.value&&""!==websiteField.value&&""!==contact_emailField.value&&""!==sinceField.value&&editlist&&(t=companyList.get({id:idField.value}),Array.from(t).forEach(function(e){(isid=(new DOMParser).parseFromString(e._values.id,"text/html")).body.firstElementChild.innerHTML==itemId&&e.values({id:`${idField.value}`,image_src:companyLogoImg.src,name:companyNameField.value,owner:ownerField.value,industry_type:industry_typeField.value,star_value:star_valueField.value,location:locationField.value,employee:employeeField.value,website:websiteField.value,contact_email:contact_emailField.value,since:sinceField.value})}),document.getElementById("close-modal").click(),clearFields(),Swal.fire({position:"center",icon:"success",title:"Company updated Successfully!",showConfirmButton:!1,timer:2e3,showCloseButton:!0})):(companyList.add({id:'#VZ'+count+"",image_src:companyLogoImg.src,name:companyNameField.value,owner:ownerField.value,industry_type:industry_typeField.value,star_value:star_valueField.value,location:locationField.value,employee:employeeField.value,website:websiteField.value,contact_email:contact_emailField.value,since:sinceField.value}),companyList.sort("id",{order:"desc"}),document.getElementById("close-modal").click(),clearFields(),refreshCallbacks(),count++,Swal.fire({position:"center",icon:"success",title:"Company inserted successfully!",showConfirmButton:!1,timer:2e3,showCloseButton:!0}))):(e.preventDefault(),e.stopPropagation())},!1)}),document.querySelector(".pagination-next").addEventListener("click",function(){document.querySelector(".pagination.listjs-pagination")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active").nextElementSibling.children[0].click()}),document.querySelector(".pagination-prev").addEventListener("click",function(){document.querySelector(".pagination.listjs-pagination")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active").previousSibling.children[0].click()});