let userAgent; let isSafari = false; let browserName; let filter; const urlParams = new URLSearchParams(window.location.search); let getfilter = urlParams.get('q'); let cid = urlParams.get('cid'); console.log(getfilter, cid); $('.likeSee__views').click(function () { window.location.href = `./index_designerList.html?q=views&cid=${cid}` $(this).css('color', '#EE7800'); }) $('.likeSee__sort').click(function () { window.location.href = `./index_designerList.html?cid=${cid}` $(this).css('color', '#EE7800'); }) function getQuery() { let query = getfilter; if (query == 'views') { filter = 'views'; $('.likeSee__views').css('color', '#EE7800'); } else { filter = 'dateSort'; $('.likeSee__sort').css('color', '#EE7800'); } } getQuery(); // pagination variables let num_per_page = 100; let n = 0; let n_video = 0; let n_columns = 0; let totalPages = { intro: 0, video: 0, columns: 0, vr360: 0, company: 0, }; window.onload = function () { if (screen.width < 600) { window.location.href = `./index_designerList_mb.html?cid=${cid}`; } userAgent = navigator.userAgent; detectBrowser(userAgent); detectDirection(); let result; let designer; let id = 0; $.ajax({ method: "GET", url: "./json/realtime.json", dataType: "json", }).done(function (msg) { result = [...msg]; renderSec00(result); }); $.ajax({ method: "GET", // url: `./json/designers-${cid}.json`, url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=1`, dataType: "json", }).done(function (msg) { designer = [...msg][0]; console.log(designer) if (filter == 'views') { designer['Content'][0]['Carddata'].sort(function (a, b) { return a[filter] > b[filter] ? -1 : 1; }) } else { designer['Content'][0]['Carddata'].sort(function (a, b) { return a[filter] > b[filter] ? 1 : -1; }) } console.log(designer['Content'][0]['Carddata']); renderinfoCard(designer); renderTab(designer['Content']); renderTabContent(designer['Content'], designer); renderModalTitle(designer['CompanyName']); // $(window).scroll(function () { // loadMore(); // }) $(window).scroll(function () { var scrollTop = $(this).scrollTop(); var scrollHeight = $('body').prop("scrollHeight"); var clientHeight = document.documentElement.clientHeight; let last = document.querySelector('#pills-intro .work__row>div:last-child'); // if (scrollTop + clientHeight >= scrollHeight - 5) { let bottom = $("body").height() - $(window).height() - 1; if ($(window).scrollTop() >= bottom) { loadMoretest(); } }) }); } function scroll_bottom_load_data(page) { $.ajax({ method: "GET", url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=${page}`, }).done(function (msg) { result = [...msg]; let append = ''; let d = result[0].Content[0].Carddata; // let cardcontent=[] let nowTab = document.querySelector('.infoContent .tab-pane.show'); if (nowTab === document.querySelector('#pills-intro')) { for (let j = 0; j < d.length; j++) { let tagStr = '' for (let k = 0; k < d[j]['tag'].length; k++) { tagStr += `${d[j]['tag'][k]['name']}` } append += `
` // var cardcontent2=cardcontent.push.d; } if (d.length === 0) { $('#loading_img').css("display", "none") } // console.log(cardcontent2); $('#pills-intro .work__row').append(append); }else if (nowTab === document.querySelector('#pills-video')) { let append = ''; let d = result[0].Content[0].Carddata; for(let j = 0;j < d.length; j ++) { let tagStr = '' for(let k = 0;k < d[j]['tag'].length; k ++) { tagStr += `${d[j]['tag'][k]['name']}` } append += `` } if (d.length === 0) { $('#loading_img').css("display", "none") } $('#pills-video .work__row').append(append); }else if (nowTab === document.querySelector('#pills-columns')) { let append = ''; let d = result[0].Content[0].Carddata; for(let j = 0;j < d.length; j ++) { let tagStr = '' for(let k = 0;k < d[j]['tag'].length; k ++) { tagStr += `${d[j]['tag'][k]['name']}` } append += `` } $('#pills-columns .work__row').append(append); } }); } var page = 1; function loadMoretest() { setTimeout(function () { // let pageNum = 2; // if(page<=pageNum){ // pageNum++; // page++; // }else{ // } scroll_bottom_load_data(page); page++; return page }, 500); } function loadMore(page) { var scrollTop = $(this).scrollTop(); var scrollHeight = $('body').prop("scrollHeight"); var clientHeight = document.documentElement.clientHeight; let nowTab = document.querySelector('.infoContent .tab-pane.show'); if (nowTab === document.querySelector('#pills-intro')) { let last = document.querySelector('#pills-intro .work__row>div:last-child'); // let pageNum = Math.ceil(totalPages.intro / 12) - 1; // if (scrollTop + clientHeight >= scrollHeight - 5) { if ($(this).scrollTop() > last.offsetTop) { // n=1; // n ++; // console.log(n); // $.ajax({ // method: "GET", // url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=${b}`, // }).done(function (msg) { // result = [...msg]; // // console.log(result); // let append = ''; // let d = result[0].Content[0].Carddata; // for (let j = 0; j < d.length; j++) { // console.log(d); // let tagStr = '' // for (let k = 0; k < d[j]['tag'].length; k++) { // tagStr += `${d[j]['tag'][k]['name']}` // } // append += `` // } // $('#pills-intro .work__row').append(append); // }); } } // else if (nowTab === document.querySelector('#pills-video')) { // let pageNum = Math.ceil(totalPages.video / 9) - 1; // console.log(totalPages.video); // let last = document.querySelector('#pills-video .work__row>div:last-child'); // if ($(this).scrollTop() > last.offsetTop) { // if (n_video >= pageNum) { // n_video = pageNum; // console.log('n-video:', n_video); // console.log('pageNum', pageNum); // return; // } else { // console.log('pass-video'); // n_video++; // console.log('test'); // let append = ''; // let d = designer['Content'][1].Carddata.slice(9 * n_video, (9 * n_video) + 9); // for (let j = 0; j < d.length; j++) { // let tagStr = '' // for (let k = 0; k < d[j]['tags'].length; k++) { // tagStr += `${d[j]['tags'][k]['name']}` // } // append += `` // } // $('#pills-video .work__row').append(append); // } // } // } else if (nowTab === document.querySelector('#pills-columns')) { // let last = document.querySelector('#pills-columns .work__row>div:last-child'); // let pageNum = Math.ceil(totalPages.columns / 9) - 1; // if ($(this).scrollTop() > last) { // if (n_columns >= pageNum) { // n_columns = pageNum; // return; // } else { // n_columns++; // console.log('test'); // let append = ''; // let d = designer['Content'][2].Carddata.slice(9 * n_columns, (9 * n_columns) + 9); // for (let j = 0; j < d.length; j++) { // let tagStr = '' // for (let k = 0; k < d[j]['tags'].length; k++) { // tagStr += `${d[j]['tags'][k]['name']}` // } // append += `` // } // $('#pills-columns .work__row').append(append); // } // } // } } function detectDirection() { let height = (window.screen.width * 5) / 12; console.log(height); $('.sec-02 .slide-item').css('height', `${height}px`); } function detectBrowser(agent) { if (userAgent.match(/chrome|chromium|crios/i)) { browserName = "chrome"; } else if (userAgent.match(/firefox|fxios/i)) { browserName = "firefox"; } else if (userAgent.match(/safari/i)) { browserName = "safari"; } else if (userAgent.match(/opr\//i)) { browserName = "opera"; } else if (userAgent.match(/edg/i)) { browserName = "edge"; } else { browserName = "No browser detection"; } if (browserName === 'safari') { isSafari = true; } console.log(isSafari); } function renderSec00(data) { let temp = data[0]['data']; renderBullet(temp); renderBannerStr('sec-00__slider', temp); $(".sec-00__slider").slick({ dots: false, speed: 500, autoplay: true, autoplaySpeed: 4000, arrows: true, prevArrow: '', nextArrow: '' }); $('.sec-00__bullet').removeClass('bullet-active'); $('.sec-00__bullet').eq($('.slick-active').data('slick-index')).addClass('bullet-active'); // $('.sec-00__slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){ // console.log(currentSlide); // console.log($('.slick-active').data('slick-index')); // }); $('.sec-00__slider').on('afterChange', function (event, slick, currentSlide) { // console.log(currentSlide); // console.log($('.slick-active').data('slick-index')); $('.sec-00__bullet').removeClass('bullet-active'); $('.sec-00__bullet').eq(currentSlide).addClass('bullet-active'); }); } function renderBullet(data) { let str = ''; for (let i = 0; i < data.length; i++) { str += '' } console.log('bullet'); $('.sec-00__bulletList').html(str); } // function renderBannerStr(sec, data) { // let str = ''; // for(let i = 0; i < data.length; i++){ // if(data[i]['Dwebp'] && !isSafari) { // str+= `` // } else { // str+= `` // } // } // $(`.${sec}`).html(str); // } function renderBannerStr(sec, data) { let str = ''; for (let i = 0; i < data.length; i++) { if (data[i]['Dwebp'] && !isSafari) { str += `` } else { str += `` } } $(`.${sec}`).html(str); } function renderinfoCard(designer) { $('.hero__img').attr('src', designer['BannerImg']); $('.infoCard__avatar').css('backgroundImage', `url(${designer['Designerimg']})`) $('.infoCard__name').text(designer['DesignerName']); $('.infoCard__seo').text(designer['Description']); $('.infoCard__company').text(designer['CompanyName']); if (designer['Approve'] !== '') { $('.infoCard__approve').html(designer['Approve']); } // Basics let str = ''; for (let i = 0; i < designer['Basics'].length; i++) { str += `` } $('.infoCard__basics').html(str); // Branches let otherStr = ''; for (let i = 0; i < designer['Branches'].length; i++) { otherStr += ` ` if(designer['Branches'][i].fax==""){ otherStr += ` ` }else{ otherStr += `` } } $('.infoCard__branches').html(otherStr); let currentURL = window.location.href; // scMedia let mediaStr = ''; for (let i = 0; i < designer['scMedia'].length; i++) { if (i === 4) { mediaStr += ` `; } else if (i === 1) { mediaStr += ` `; } else if (i === 2) { mediaStr += ` `; } else if (i === 3) { mediaStr += ` `; } else { mediaStr += ` `; } } $('.scMedia').html(mediaStr); document.querySelector('.dislike').addEventListener('click', function () { $('.dislike').css('display', 'none'); $('.like').css('display', 'block'); }) document.querySelector('.like').addEventListener('click', function () { $('.dislike').css('display', 'block'); $('.like').css('display', 'none'); }) // term condition let termStr = ''; for (let i = 0; i < designer['Terms'].length; i++) { termStr += `` } $('.infoCard__terms').html(termStr); } function renderTab(content) { let tabTitleStr = ''; for (let i = 0; i < content.length; i++) { if (content[i]['Carddata'] == "" & content[i]['info'] == undefined) { tabTitleStr += `` } else { if (i == 0) { tabTitleStr += `