PageSourceSearch

https://raitotec.com/js/contact.min.js?v=1791468381

js raitotec.com collected 2026-10-08 14:06:36 UTC 13,400 bytes, 24 lines download raw bytes

1document.addEventListener('DOMContentLoaded',function(){const contactForm=document.getElementById('contactForm');if(contactForm){const successModal=new bootstrap.Modal(document.getElementById('successModal'));const sectorSelect=document.getElementById('sector');const phoneInput=document.getElementById('phone');const sectorsData=window.raitoSectors||[];const dynamicSectorsWrapper=document.getElementById('dynamic-sectors-wrapper');const dynamicOptionsWrapper=document.getElementById('dynamic-options-wrapper');const dynamicSubGroupsWrapper=document.getElementById('dynamic-sub-groups-wrapper');const finalSectorIdInput=document.getElementById('final_sector_id');const sectorOptionIdSelect=document.getElementById('sector_option_id');const dynamicOptionsLabel=document.getElementById('dynamic-options-label');const rootSelect=document.querySelector('.dynamic-sector-select[data-level="0"]');if(rootSelect){const rootSectors=sectorsData.filter(s=>s.parent_id===null);rootSectors.forEach(s=>{const option=document.createElement('option');option.value=s.id;option.textContent=s.label;rootSelect.appendChild(option)});rootSelect.addEventListener('change',handleSectorChange)}
2function getChildren(parentId){return sectorsData.filter(s=>s.parent_id==parentId)}
3function getSector(id){return sectorsData.find(s=>s.id==id)}
4function handleSectorChange(e){const select=e.target;const level=parseInt(select.getAttribute('data-level'),10);let selectedId=select.value;const allSelectGroups=dynamicSectorsWrapper.querySelectorAll('.form-group');allSelectGroups.forEach(group=>{const selectEl=group.querySelector('select');if(selectEl&&parseInt(selectEl.getAttribute('data-level'),10)>level){group.remove()}});if(!selectedId&&level>0){const parentLevel=level-1;const parentSelect=document.querySelector(`.dynamic-sector-select[data-level="${parentLevel}"]`);if(parentSelect){selectedId=parentSelect.value}}
5finalSectorIdInput.value=selectedId;dynamicOptionsWrapper.style.display='none';sectorOptionIdSelect.innerHTML='<option value="">اختر</option>';sectorOptionIdSelect.style.display='';dynamicOptionsWrapper.querySelectorAll('.sector-option-field').forEach(el=>el.remove());clearSubGroups();if(!selectedId)return;const selectedSector=getSector(selectedId);const children=getChildren(selectedId);if(children.length>0&&select.value!==""){const nextLevel=level+1;const groupDiv=document.createElement('div');groupDiv.className='form-group mt-3';groupDiv.id=`sector-group-${nextLevel}`;const label=document.createElement('label');label.className='form-label';const childrenLabel=(selectedSector&&selectedSector.children_label)?selectedSector.children_label:'القطاع الفرعي';label.innerHTML=`<i class="fas fa-code-branch"></i> ${childrenLabel}`;const newSelect=document.createElement('select');newSelect.className='form-control dynamic-sector-select';newSelect.setAttribute('data-level',nextLevel);const initialOption=document.createElement('option');initialOption.value='';initialOption.textContent=`اختر ${childrenLabel}`;newSelect.appendChild(initialOption);children.forEach(c=>{const opt=document.createElement('option');opt.value=c.id;opt.textContent=c.label;newSelect.appendChild(opt)});newSelect.addEventListener('change',handleSectorChange);groupDiv.appendChild(label);groupDiv.appendChild(newSelect);dynamicSectorsWrapper.appendChild(groupDiv);showSectorOptions(selectedSector);showSubGroups(selectedSector)}else if(select.value!==""){showSectorOptions(selectedSector);showSubGroups(selectedSector)}}
6function showSectorOptions(sector){if(!sector)return;let options=(sector.options&&sector.options.length>0)?sector.options:[];let optionsLabel=sector.options_label||'';if(options.length===0&&sector.parent_id){const parentSector=getSector(sector.parent_id);if(parentSector&&parentSector.options&&parentSector.options.length>0){options=parentSector.options;optionsLabel=parentSector.options_label||''}}
7if(options.length===0)return;if(optionsLabel){dynamicOptionsLabel.innerHTML=`<i class="fas fa-list-ul"></i> ${optionsLabel}`}else{dynamicOptionsLabel.innerHTML=''}
8const selectOptions=options.filter(o=>(o.type||'select')==='select');const nonSelectOptions=options.filter(o=>o.type&&o.type!=='select');if(selectOptions.length>0){sectorOptionIdSelect.innerHTML='<option value="">اختر</option>';selectOptions.forEach(opt=>{const option=document.createElement('option');option.value=opt.id;option.textContent=opt.label;sectorOptionIdSelect.appendChild(option)});sectorOptionIdSelect.style.display=''}else{sectorOptionIdSelect.style.display='none';sectorOptionIdSelect.innerHTML='<option value="">اختر</option>'}
9nonSelectOptions.forEach(opt=>{const wrapper=document.createElement('div');wrapper.className='form-group mt-3 sector-option-field';const label=document.createElement('label');label.className='form-label';label.innerHTML=`<i class="fas fa-edit"></i> ${opt.label}`;const input=document.createElement('input');input.type=opt.type==='integer'?'number':'text';input.className='form-control sector-option-value-input';input.setAttribute('data-option-id',opt.id);input.setAttribute('data-option-type',opt.type);input.placeholder=`أدخل ${opt.label}`;if(opt.type==='integer')input.min='0';wrapper.appendChild(label);wrapper.appendChild(input);dynamicOptionsWrapper.appendChild(wrapper)});dynamicOptionsWrapper.style.display='block'}
10function clearSubGroups(){dynamicSubGroupsWrapper.innerHTML=''}
11function showSubGroups(sector){if(!sector)return;let subGroups=(sector.sub_groups&&sector.sub_groups.length>0)?sector.sub_groups:[];if(subGroups.length===0&&sector.parent_id){const parentSector=getSector(sector.parent_id);if(parentSector&&parentSector.sub_groups&&parentSector.sub_groups.length>0){subGroups=parentSector.sub_groups}}
12if(subGroups.length===0)return;subGroups.forEach(sg=>{if(!sg.choices||sg.choices.length===0)return;const selectChoices=sg.choices.filter(ch=>(ch.type||'select')==='select');const nonSelectChoices=sg.choices.filter(ch=>ch.type&&ch.type!=='select');if(selectChoices.length>0){const col=document.createElement('div');col.className='col-12 mt-3 sub-group-item';const groupDiv=document.createElement('div');groupDiv.className='form-group';const label=document.createElement('label');label.className='form-label';label.innerHTML=`<i class="fas fa-layer-group"></i> ${sg.label}`;const select=document.createElement('select');select.className='form-control sub-group-select';select.setAttribute('data-sub-group-id',sg.id);const initialOpt=document.createElement('option');initialOpt.value='';initialOpt.textContent=`اختر ${sg.label}`;select.appendChild(initialOpt);
12selectChoices.forEach(ch=>{const opt=document.createElement('option');opt.value=ch.id;opt.textContent=ch.label;select.appendChild(opt)});groupDiv.appendChild(label);groupDiv.appendChild(select);col.appendChild(groupDiv);dynamicSubGroupsWrapper.appendChild(col)}
13nonSelectChoices.forEach(ch=>{const col=document.createElement('div');col.className='col-12 mt-3 sub-group-item';const groupDiv=document.createElement('div');groupDiv.className='form-group';const label=document.createElement('label');label.className='form-label';label.innerHTML=`<i class="fas fa-edit"></i> ${ch.label}`;const input=document.createElement('input');input.type=ch.type==='integer'?'number':'text';input.className='form-control sub-group-choice-input';input.setAttribute('data-sub-group-id',sg.id);input.setAttribute('data-choice-id',ch.id);input.setAttribute('data-choice-type',ch.type);input.placeholder=`أدخل ${ch.label}`;if(ch.type==='integer')input.min='0';groupDiv.appendChild(label);groupDiv.appendChild(input);col.appendChild(groupDiv);dynamicSubGroupsWrapper.appendChild(col)})})}
14function collectSubGroupChoices(){const choices=[];document.querySelectorAll('.sub-group-select').forEach(sel=>{if(sel.value){choices.push({sub_group_id:parseInt(sel.getAttribute('data-sub-group-id'),10),choice_id:parseInt(sel.value,10),value:null,})}});document.querySelectorAll('.sub-group-choice-input').forEach(input=>{if(input.value.trim()){choices.push({sub_group_id:parseInt(input.getAttribute('data-sub-group-id'),10),choice_id:parseInt(input.getAttribute('data-choice-id'),10),value:input.value.trim(),})}});return choices}
15phoneInput.addEventListener('input',function(e){e.target.value=e.target.value.replace(/[^+0-9\s().-]/g,'')});function isValidPhone(value){const digits=value.replace(/\D/g,'');return/^[+0-9\s().-]+$/.test(value)&&digits.length>=8&&digits.length<=15}
16function clearValidationErrors(){document.querySelectorAll('.invalid-feedback').forEach(el=>{el.textContent='';el.style.display='none'});document.querySelectorAll('.form-control.is-invalid').forEach(el=>{el.classList.remove('is-invalid')})}
17function showValidationErrors(errors){for(const[field,messages]of Object.entries(errors)){let targetField=field;if(field==='sector_id'){const hiddenError=document.getElementById('error-sector_id');if(hiddenError){hiddenError.style.display='block';hiddenError.textContent=messages[0]}
18document.querySelectorAll('.dynamic-sector-select').forEach(el=>el.classList.add('is-invalid'));continue}
19const errorDiv=document.getElementById('error-'+field);const input=document.querySelector('[name="'+field+'"]');if(errorDiv){errorDiv.textContent=messages[0];errorDiv.style.display='block'}
20if(input){input.classList.add('is-invalid')}}}
21contactForm.addEventListener('submit',function(e){e.preventDefault();clearValidationErrors();if(!isValidPhone(phoneInput.value)){const phoneError=document.getElementById('error-phone');phoneError.textContent='يرجى إدخال رقم دولي صحيح من 8 إلى 15 رقماً.';phoneError.style.display='block';phoneInput.classList.add('is-invalid');phoneInput.focus();return}
22const finalSecId=finalSectorIdInput.value;if(!finalSecId){const hiddenError=document.getElementById('error-sector_id');hiddenError.style.display='block';hiddenError.textContent='يرجى اختيار القطاع بشكل صحيح.';return}
23const optionValues={};document.querySelectorAll('.sector-option-value-input').forEach(input=>{if(input.value.trim()!==''){optionValues[input.getAttribute('data-option-id')]=input.value.trim()}});const formData={full_name:document.getElementById('fullName').value,company_name:document.getElementById('companyName').value,phone:document.getElementById('phone').value,email:document.getElementById('email').value,sector_id:finalSecId,sector_option_id:sectorOptionIdSelect.value||null,sector_option_value:Object.keys(optionValues).length>0?JSON.stringify(optionValues):null,sub_group_choices:collectSubGroupChoices(),message:document.getElementById('message').value,};const submitButton=contactForm.querySelector('.contact-btn-submit');const originalContent=submitButton.innerHTML;submitButton.disabled=!0;submitButton.innerHTML='<span class="spinner-border spinner-border-sm ms-2"></span> جاري الإرسال...';const csrfToken=document.querySelector('meta[name="csrf-token"]').getAttribute('content');fetch('/contact',{method:'POST',headers:{'Content-Type':'application/json','Accept':'application/json','X-CSRF-TOKEN':csrfToken,},body:JSON.stringify(formData),}).then(response=>{if(response.ok){return response.json().then(data=>({ok:!0,data}))}
24return response.json().then(data=>({ok:!1,status:response.status,data}))}).then(result=>{submitButton.disabled=!1;submitButton.innerHTML=originalContent;if(result.ok){contactForm.reset();document.querySelectorAll('.smart-question').forEach(q=>q.style.display='none');const firstSelect=document.querySelector('.dynamic-sector-select[data-level="0"]');if(firstSelect)firstSelect.value='';const allSelectGroups=dynamicSectorsWrapper.querySelectorAll('.form-group');allSelectGroups.forEach(group=>{const selectEl=group.querySelector('select');if(selectEl&&parseInt(selectEl.getAttribute('data-level'),10)>0){group.remove()}});clearSubGroups();finalSectorIdInput.value='';window.location.href='/contact/success'}else if(result.status===422&&result.data.errors){showValidationErrors(result.data.errors)}else{alert('حدث خطأ أثناء الإرسال. يرجى المحاولة مرة أخرى.')}}).catch(error=>{console.error('Error:',error);submitButton.disabled=!1;submitButton.innerHTML=originalContent;alert('حدث خطأ في الاتصال. يرجى المحاولة مرة أخرى.')})});const formInputs=document.querySelectorAll('.form-control');
24formInputs.forEach(input=>{input.addEventListener('focus',function(){this.parentElement.classList.add('focused')});input.addEventListener('blur',function(){if(this.value===''){this.parentElement.classList.remove('focused')}})});const stepCards=document.querySelectorAll('.expectation-card');const observerOptions={threshold:0.2,rootMargin:'0px 0px -100px 0px'};const observer=new IntersectionObserver(function(entries){entries.forEach((entry,index)=>{if(entry.isIntersecting){setTimeout(()=>{entry.target.style.opacity='1';entry.target.style.transform='translateY(0)'},index*200)}})},observerOptions);stepCards.forEach(card=>{card.style.opacity='0';card.style.transform='translateY(30px)';card.style.transition='all 0.6s ease';observer.observe(card)});const testimonialCards=document.querySelectorAll('.testimonial-card');testimonialCards.forEach(card=>{card.addEventListener('mouseenter',function(){this.style.transform='translateY(-5px)'});card.addEventListener('mouseleave',function(){this.style.transform='translateY(0)'})})}})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.