$(function () { const vaLue = $('.zxService').next().val(); const Json = JSON.parse(vaLue) const svgIcons = [ '', '', '', '', '' ]; // Remove $('.zxService').next().remove(); const Item = '.zxServiceItem'; const processByNumericValue = { 1: { html: 'ico', account: false, getIcon: false, link: true }, 2: { html: 'ico', account: false, getIcon: false, link: true }, 3: { html: 'ico', account: false, getIcon: false, link: true }, 4: { html: 'ico', account: false, getIcon: false, link: true }, 5: { html: 'ico', account: false, getIcon: 0, link: true }, 6: { html: 'ico', account: true, getIcon: 1, link: false }, 7: { html: 'ico', account: true, getIcon: 2, link: false }, 8: { html: 'ico', account: false, getIcon: false, link: true }, 9: { html: 'ico', account: false, getIcon: 3, link: true }, 10: { html: 'ico', account: false, getIcon: 4, link: true }, 11: { html: 'ico', account: true, getIcon: false, link: true } }; $(Item).each(function () { const nums = $(this).attr('class').split(' '); nums.forEach(num => { if (num.startsWith('zxItem-')) { const numericPart = num.substring('zxItem-'.length); const numericValue = parseInt(numericPart); const $this = $(this); const index = $this.index(); const data = Json.staffList[index - 1]; const thisImg = $this.find('.zxItem-Img'); const processConfig = processByNumericValue[numericValue]; if (processConfig) { const iconHtml = processConfig.getIcon !== false ? getIcon(processConfig.getIcon) : data.iconUrl; const linkHtml = processConfig.link === true ? data.link : 'javascript:;'; const accountHtml = processConfig.account ? `

${data.account}

` : ''; $this.append(`${iconHtml}`); if (numericValue === 11 || numericValue === 6 || numericValue === 7) { $this.append(`
${thisImg.html()}${accountHtml}
`); } thisImg.remove(); } } }); }); function getIcon(iconIndex) { return svgIcons[iconIndex]; } var serBox = $('.zxService').height(); $('.zxItem-detail').parent().addClass('hasDetail'); $('.hasDetail').hover(function () { var $this = $(this); var detailHeight = $this.find('.zxItem-detail').height(); var detailTop = $this.find('.zxItem-detail').parent().position().top; var detailOut = serBox - detailTop; var isDetailOut = detailOut - detailHeight; $this.toggleClass('small', isDetailOut < 0); }); $(window).on('load', function () { gsap.to('.zxService', { right: 15, opacity: 1 }) }); $('#goTop').on('click', function () { gsap.to(window, { duration: 1, scrollTo: { y: 0 } }); }); $('#goBottom').on('click', function () { var pageHeight = document.documentElement.scrollHeight - window.innerHeight; gsap.to(window, { duration: 1, scrollTo: { y: pageHeight } }); }); });