// $(".popular").hide(); $(document).on("click", ".likeSee__state__filter--item", function (event) { // $(".News").toggle(); // $(".popular").toggle(); $(".likeSee__state__filter--item").removeClass('active'); $(this).addClass("active"); }); const urlParams = new URLSearchParams(window.location.search); let id = urlParams.get('cid'); console.log(id); function get_data() { $.ajax({ method: "GET", // url: `json/Columns-${id}.json`, url: `https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=new&page=1`, // url:`json/Columns.json`, dataType: "json", }) .done(function (msg) { console.log(msg); let ColumnsContent = ""; let ColumnsTag = ""; let breadcrumbTitle = ""; let article_info = ""; let OtherColumns = ""; let PopularColumns = ""; let author_inf=""; breadcrumbTitle = `${msg[0].Columnstitle}` article_info = `

${msg[0].Columnstitle}

${msg[0].ColumnsDate}| 人氣:${msg[0].ColumnsViews}
`; ColumnsContent = `${msg[0].ColumnsContent}`; for (let j = 0; j < msg[0].ColumnsTag.length; j++) { ColumnsTag += ' \ ' + msg[0].ColumnsTag[j].Tag + ''; } for (let i = 0; i < 12; i++) { OtherColumns += '
\ \
\ \
\ '+ msg[0].OtherColumns[i].Columnstitle + '\
\
' OtherColumns += '

' for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) { OtherColumns += '\ ' + msg[0].OtherColumns[i].ColumnsTag[k].Tag + '' } OtherColumns += '

' OtherColumns += '
' } author_inf=`
${msg[0].author_inf}
`; // for(let i=0; i
\ // \ //
\ // \ //
\ // '+msg[0].PopularColumns[i].Columnstitle+'\ //
\ //
' // PopularColumns+='

' // for(k=0; k'+msg[0].PopularColumns[i].ColumnsTag[k].Tag+'' // } // PopularColumns+='

' // PopularColumns+='
' // } $('.article_info').html(article_info); $('.breadcrumb-title').html(breadcrumbTitle); $('.ColumnsContent').html(ColumnsContent); $('.ColumnsTag').html(ColumnsTag); $('.OtherColumns').html(OtherColumns); $('.anchor_info').html(author_inf); // $('.PopularColumns').html(PopularColumns); }); } function renderSec07() { $.ajax({ method: "GET", // url: `json/bannerAds-${id}.json`, url: `https://m3.hhh.com.tw:18686/getColumnAds`, dataType: "json", }) .done(function (msg) { console.log(msg); console.log(msg.length); let str = ''; for (let i = 0; i < msg.length; i++) { str += `
` } $(`.sec-07__slider`).html(str); $(".sec-07__slider").slick({ dots: false, autoplay: true, arrows: true, slidesToShow: 4, slidesToScroll: 1, autoplaySpeed: 7000, initialSlide: 0, infinite: true, prevArrow: '', nextArrow: '' }); }); } get_data(); renderSec07(); let filter; $(".views").click(function () { console.log(1); filter = "hot"; get_views_data(); }); $(".recently").click(function () { console.log(2); filter = "new"; get_views_data(); }); function get_views_data() { $.ajax({ method: "GET", url:`https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=${filter}&page=1`, // url: `json/Columns-${id}.json`, // url:`json/cases.json`, dataType: "json", }) .done(function (msg) { console.log(msg); // msg[0].OtherColumns.sort(function (a, b) { // return a['Views'] > b['Views'] ? -1 : 1; // }); console.log(msg[0].OtherColumns); let OtherColumns = ""; for (let i = 0; i < msg[0].OtherColumns.length; i++) { OtherColumns += '
\ \
\ \
\ '+ msg[0].OtherColumns[i].Columnstitle + '\
\
' OtherColumns += '

' for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) { OtherColumns += '\ ' + msg[0].OtherColumns[i].ColumnsTag[k].Tag + '' } OtherColumns += '

' OtherColumns += '
' } $('.OtherColumns').html(OtherColumns); }); }; if ($(".views").hasClass("active")) { filter = "hot"; // alert('1'); } else { filter = "new"; // alert('2'); } function scroll_bottom_load_data(page) { $.ajax({ method: "GET", // url: `json/cases-${id}.json`, // url:`json/cases.json`, url: `https://m3.hhh.com.tw:18686/gencolumn?id=${id}&sort=${filter}&page=${page}`, dataType: "json", }) .done(function (msg) { let OtherColumns = ""; for (let i = 0; i < msg[0].OtherColumns.length; i++) { OtherColumns += '
\ \
\ \
\ '+ msg[0].OtherColumns[i].Columnstitle + '\
\
' OtherColumns += '

' for (k = 0; k < msg[0].OtherColumns[i].ColumnsTag.length; k++) { OtherColumns += '\ ' + msg[0].OtherColumns[i].ColumnsTag[k].Tag + '' } OtherColumns += '

' OtherColumns += '
' } // $('.OtherColumns').html(OtherColumns); $('.OtherColumns').append(OtherColumns); }); } $(window).scroll(function () { var scrollTop = $(this).scrollTop(); var scrollHeight = $('body').prop("scrollHeight"); var clientHeight = document.documentElement.clientHeight; if (jQuery(window).width() < 767) { //一樣 var scrollHeight2 = document.documentElement.scrollHeight; if (scrollTop + clientHeight >= scrollHeight - 5) { loadMore_m(); console.log(page); } } else { if (scrollTop + clientHeight >= scrollHeight - 5) { loadMore(); console.log(page); } } }) var page = 1; function loadMore() { setTimeout(function () { page++; // console.log(page); scroll_bottom_load_data(page); return page }, 500); } function loadMore_m() { // console.log(page); setTimeout(function () { page++; // console.log(page); scroll_bottom_load_data(page); return page }, 500); } // function loadMore_m() { // // console.log(page); // setTimeout(function () { // page++; // // console.log(page); // scroll_bottom_load_data(page); // return page // }, 500); // }