index.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381
  1. let userAgent;
  2. let isSafari = false;
  3. let browserName;
  4. // pagination variables
  5. let num_per_page = 9;
  6. let n = 0;
  7. let totalPages = {
  8. intro: 0,
  9. video: 0,
  10. columns: 0,
  11. vr360: 0,
  12. company: 0,
  13. };
  14. window.onload = function () {
  15. hhh_user_api();
  16. // if(screen.width < 900) {
  17. // window.location.href = "../index_designerList_mb.html";
  18. // }
  19. userAgent = navigator.userAgent;
  20. detectBrowser(userAgent);
  21. detectDirection();
  22. let result;
  23. $.ajax({
  24. method: "GET",
  25. url: "./hhh_index/json/realtime.json",
  26. dataType: "json",
  27. }).done(function (msg) {
  28. result = [...msg];
  29. console.log('result', result);
  30. renderSec00(result);
  31. // renderBanner(result);
  32. });
  33. $('#navbar').load('./hhh_index/template/nav-new.html');
  34. $('#footer').load('./hhh_index/template/footer.html');
  35. $('#btn-box').load('./hhh_index/template/button.html');
  36. };
  37. function hhh_user_api_login() {
  38. window.location.href = `https://hhh.com.tw/users`;
  39. }
  40. let user_data = [];
  41. function hhh_user_api() {
  42. $.ajax({
  43. method: "post",
  44. url: "https://hhh.com.tw/adapter/index?http_method=GET&api_url=/base/v1/member/index",
  45. dataType: "json",
  46. }).done(function (msg) {
  47. user_data = msg;
  48. let app_user = "";
  49. console.log('hhh_user_msg', msg);
  50. if (msg.status == "Success") {
  51. app_user += `
  52. <div class="dropdown">
  53. <button class="btn dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false" onclick="hhh_user_api_login()">
  54. <div class="d-flex align-items-center">
  55. <img src="${msg.data["user_avatar"]}" alt="" style="height: 32px; width: 32px;border-radius: 100px;">
  56. <p class="ms-2">${msg.data["name"]}</p>
  57. </div>
  58. </button>
  59. <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
  60. <li><a class="dropdown-item" href="https://hhh.com.tw/users">會員專區</a></li>
  61. </ul>
  62. </div>`;
  63. } else {
  64. app_user += `
  65. <a class="nav-link" href="javascript:;" onclick="hhh_user_api_login()">
  66. <section class="d-flex align-items-center">
  67. <img src="./hhh_index/images/icon/material-people.svg" alt="login" class="me-2" style="padding-top: 2px;" />
  68. <span class="pt-1">登入</span>
  69. </section>
  70. </a>`;
  71. }
  72. $("#app_user").html(app_user);
  73. }).fail(function (err) {
  74. console.log('err', err);
  75. });
  76. }
  77. function detectDirection() {
  78. let height = (window.screen.width * 5) / 12;
  79. $(".sec-02 .slide-item").css("height", `${height}px`);
  80. }
  81. function detectBrowser(agent) {
  82. if (userAgent.match(/chrome|chromium|crios/i)) {
  83. browserName = "chrome";
  84. } else if (userAgent.match(/firefox|fxios/i)) {
  85. browserName = "firefox";
  86. } else if (userAgent.match(/safari/i)) {
  87. browserName = "safari";
  88. } else if (userAgent.match(/opr\//i)) {
  89. browserName = "opera";
  90. } else if (userAgent.match(/edg/i)) {
  91. browserName = "edge";
  92. } else {
  93. browserName = "No browser detection";
  94. }
  95. if (browserName === "safari") {
  96. isSafari = true;
  97. }
  98. }
  99. function renderSec00(data) {
  100. let temp = data[0]["data"];
  101. renderBullet(temp);
  102. renderBannerStr("sec-00-slider", temp);
  103. $(".sec-00-slider").slick({
  104. dots: false,
  105. infinite: true,
  106. speed: 500,
  107. autoplay: true,
  108. autoplaySpeed: 3000,
  109. slidesToScroll: 1,
  110. arrows: false,
  111. prevArrow:
  112. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  113. nextArrow:
  114. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  115. });
  116. $(".sec-00-bullet").removeClass("bullet-active");
  117. $(".sec-00-bullet")
  118. .eq($(".slick-active").data("slick-index"))
  119. .addClass("bullet-active");
  120. $(".sec-00-slider").on("afterChange", function (event, slick, currentSlide) {
  121. $(".sec-00-bullet").removeClass("bullet-active");
  122. $(`.sec-00-bullet.item-${currentSlide}`).addClass("bullet-active");
  123. // $('.sec-00-bullet').eq(currentSlide).addClass("bullet-active");
  124. });
  125. }
  126. function renderBanner(data) {
  127. let temp = data[1]["data"];
  128. // renderBullet(temp);
  129. // renderBannerStr("banner-slider", temp);
  130. let str = "";
  131. let img = "";
  132. if (window.innerWidth < 767) {
  133. // 手機版
  134. img = "imgUrl";
  135. } else {
  136. // 電腦版
  137. img = "Dwebp";
  138. }
  139. for (let i = 0; i < temp.length; i++) {
  140. str += `
  141. <a href="${temp[i]["link"]}" target="_blank">
  142. <section class="info-item">
  143. <span class="logo-img">
  144. <img class="img-${temp[i].logo_icon} ${temp[i].logo_icon === "" ? "d-none" : ""}" src="./hhh_index/images/index/banner_logo/${temp[i].logo_icon}.png">
  145. </span>
  146. <section class="${temp[i].index_char_1 === "" || temp[i].index_char_2_1 === "" || temp[i].index_char_2_2 === "" ? "d-none" : ""}">
  147. <h3>${temp[i].index_char_1}</h3>
  148. <div>
  149. <h2>${temp[i].index_char_2_1}</h2>
  150. <h2>
  151. ${temp[i].index_char_2_2}
  152. <small>${temp[i].index_char_2_3}</small>
  153. </h2>
  154. </div>
  155. </section>
  156. </section>
  157. <img class="banner-slider-${i + 1} slide-item img-fluid" src="${temp[i][`${img}`]}" data-bg="${temp[i][`${img}`]}">
  158. </a>`;
  159. }
  160. $(`.banner-slider`).html(str);
  161. // 輪播設定
  162. $('.banner-slider').slick({
  163. dots: true,
  164. infinite: true,
  165. speed: 300,
  166. arrows: true,
  167. autoplay: true,
  168. autoplaySpeed: 4000,
  169. slidesToShow: 1,
  170. slidesToScroll: 1,
  171. centerMode: true,
  172. variableWidth: true,
  173. prevArrow:
  174. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="color: white;transform: translateY(-10px);"></i></button>',
  175. nextArrow:
  176. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="color: white;transform: translateY(-10px);"></i></button>',
  177. responsive: [
  178. {
  179. breakpoint: 575,
  180. settings: {
  181. dots: false,
  182. arrows: false,
  183. }
  184. }
  185. ]
  186. });
  187. // On before slide change
  188. $('.banner-slider').on('beforeChange', function (event, { slideCount: count }, currentSlide, nextSlide) {
  189. let selectors = [nextSlide, nextSlide - count, nextSlide + count].map(n => `[data-slick-index="${n}"]`).join(', ');
  190. $('.slick-now').removeClass('slick-now');
  191. $(selectors).addClass('slick-now');
  192. });
  193. $('[data-slick-index="0"]').addClass('slick-now');
  194. }
  195. function renderBullet(data) {
  196. let str = "";
  197. for (let i = 0; i < data.length; i++) {
  198. str += `<div class="sec-00-bullet item-${i}"></div>`;
  199. }
  200. $(".sec-00-bulletList").html(str);
  201. }
  202. function renderBannerStr(sec, data) {
  203. let str = "";
  204. for (let i = 0; i < data.length; i++) {
  205. if (data[i]["Dwebp"]) {
  206. str += `
  207. <a href="${data[i]["link"]}">
  208. <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["Dwebp"]}" data-bg="${data[i]["Dwebp"]}">
  209. </a>`;
  210. } else {
  211. str += `
  212. <a href="${data[i]["link"]}">
  213. <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["DimgUrl"]}" data-bg="${data[i]["DimgUrl"]}">
  214. </a>`;
  215. }
  216. }
  217. $(`.${sec}`).html(str);
  218. }
  219. let sticky = document.querySelector(".sec-00").offsetHeight;
  220. window.addEventListener("scroll", fixedOnScroll);
  221. const navbar = document.querySelector(".navbar-main");
  222. function fixedOnScroll() {
  223. if (navbar) {
  224. if (window.pageYOffset >= 344) {
  225. navbar.classList.add("sticky");
  226. } else {
  227. navbar.classList.remove("sticky");
  228. }
  229. }
  230. }
  231. $(window)
  232. .scroll(function () {
  233. if ($(this).scrollTop() > 800) {
  234. $(".fixed-btn").fadeIn(222);
  235. } else {
  236. $(".fixed-btn").stop().fadeOut(222);
  237. }
  238. })
  239. .scroll();
  240. $("#top-btn").click(function () {
  241. $("html, body").animate(
  242. {
  243. scrollTop: 0,
  244. },
  245. 500
  246. );
  247. });
  248. $(".sec-00__close").click(function () {
  249. $(this).css("display", "none");
  250. $(".sec-00").addClass("bannerClose");
  251. //$('.sec-02').css('padding-top', '53px');
  252. sticky = 0;
  253. });
  254. document.addEventListener("lazybeforeunveil", function (e) {
  255. var bg = e.target.getAttribute("data-bg");
  256. if (bg) {
  257. e.target.style.backgroundImage = "url(" + bg + ")";
  258. }
  259. });
  260. function addToFavorite(cid) {
  261. if (user_data.data["uid"] == undefined) {
  262. Swal.fire({
  263. title: "請先登入",
  264. showConfirmButton: false,
  265. });
  266. $.ajax({
  267. url: "https://hhh.com.tw/hhhajax/save_http_referer",
  268. type: "post",
  269. datatype: "json",
  270. data: { http_referer: location.href },
  271. success: function () {
  272. location.href = "/login/index";
  273. },
  274. });
  275. }
  276. $.ajax({
  277. url: `https://hhh.com.tw/favorite/set?type=column&id=${cid}`,
  278. }).done(function (data) {
  279. if (data == 1) {
  280. $(".like").css("display", "block");
  281. $(".like-o").css("display", "none");
  282. } else {
  283. $(".like").css("display", "none");
  284. $(".like-o").css("display", "block");
  285. }
  286. });
  287. }
  288. function putEmail() {
  289. const emailPattern =
  290. /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  291. if ($("#email").val() !== null && emailPattern.test($("#email").val())) {
  292. $("#error").hide();
  293. $("#putEmail_hidden").css("display", "block");
  294. $("#add_email").text($("#email").val());
  295. $("#email").val("");
  296. } else {
  297. $("#error").show();
  298. $("#error").text("email 格式有誤");
  299. }
  300. }
  301. $(".fm-close").click(() => {
  302. $("#putEmail_hidden").css("display", "none");
  303. $("#add_email").text("");
  304. });
  305. $("#putEmail").click(function (event) {
  306. $("#putEmail_hidden").show();
  307. const vm = $("#email").val();
  308. const emailPattern =
  309. /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  310. if (vm.length == 0) {
  311. $("#error").show();
  312. $("#error").text("請輸入Email");
  313. $("#email").addClass("border-revise");
  314. $("#button-fm").addClass("fm-btn-border");
  315. $("#email").focus();
  316. return false;
  317. } else if (!emailPattern.test(vm)) {
  318. $("#error").show();
  319. $("#error").text("email 格式有誤");
  320. $("#email").addClass("border-revise");
  321. $("#button-fm").addClass("fm-btn-border");
  322. $("#email").focus();
  323. return false;
  324. // } else if (vm.length >= 5) {
  325. // $('#error').show();
  326. // $('#error').text('最多一次轉寄 5 封');
  327. // $('#email').addClass('border-revise');
  328. // $('#button-fm').addClass('fm-btn-border');
  329. //
  330. // $('#email').focus();
  331. // return false;
  332. } else {
  333. $("#email").removeClass("border-revise");
  334. $("#button-fm").removeClass("fm-btn-border");
  335. $("#error").hide();
  336. $("#add_email").text($("#email").val());
  337. $("#email").val("");
  338. }
  339. });
  340. $("#doSend").click(function (event) {
  341. stop = 0;
  342. var emailPattern =
  343. /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  344. let this_url = window.location.href;
  345. // 如果 uid 為空代表沒登入(由於此寄信功能需要 uid 故需要先登入)
  346. if (user_data.data["uid"] == undefined) {
  347. $("#error").text("請先登錄/註冊會員帳號");
  348. stop = 1;
  349. } else if ($("#email").val() == "") {
  350. $("#error").text("收件人不得為空");
  351. stop = 1;
  352. } else {
  353. if (!emailPattern.test($("#email").val())) {
  354. $("#error").text("請以 email 格式填寫");
  355. stop = 1;
  356. }
  357. }
  358. if (stop == 0) {
  359. $("#error").text();
  360. $.ajax({
  361. url: "https://hhh.com.tw/adapter/index?http_method=POST&api_url=/base/v1/member/forward",
  362. type: "post",
  363. datatype: "json",
  364. data: {
  365. data: JSON.stringify({
  366. uid: user_data.data["uid"],
  367. sender: user_data.data["email"],
  368. recipient: $("#email").val(),
  369. url: this_url,
  370. subject: $("#title").val(),
  371. content: $("#content").val(),
  372. }),
  373. },
  374. success: function (result) {
  375. $("#forward_modal").modal("hide");
  376. Swal.fire({
  377. title: "發送成功",
  378. showConfirmButton: false,
  379. });
  380. $("#emailModal").modal("hide");
  381. },
  382. });
  383. }
  384. });
  385. /* 手機版輪播進度條 */
  386. $('.banner-slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) { // 頂部輪播
  387. let calc = ((nextSlide) / (slick.slideCount - 1)) * 100;
  388. $('.banner-content .progress')
  389. .css('background-size', calc + '% 100%')
  390. .attr('aria-valuenow', calc);
  391. });
  392. $('.ad-slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) { // 廣告區塊
  393. let calc = ((nextSlide) / (slick.slideCount - 1)) * 100;
  394. $('.ad-content .progress')
  395. .css('background-size', calc + '% 100%')
  396. .attr('aria-valuenow', calc);
  397. });
  398. let optionsSliderList = document.querySelectorAll('.options-slider'); // 廣告上方列表
  399. for (let i = 0; i < optionsSliderList.length; i++) {
  400. let count;
  401. let element;
  402. const progressBar = $(`.progress.item-0${i}`);
  403. const progressBarLabel = $('.slider-label');
  404. if (i === 0) {
  405. count = 2;
  406. element = $(`.space-slider.slider-0${i}`);
  407. } else {
  408. window.innerWidth < 415 ? count = 2 : count = 3;
  409. element = $(`.options-slider.slider-0${i}`);
  410. }
  411. element.on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  412. let calc = ((nextSlide) / (slick.slideCount - count)) * 100;
  413. progressBar
  414. .css('background-size', calc + '% 100%')
  415. .attr('aria-valuenow', calc);
  416. progressBarLabel.text(calc + '% completed');
  417. });
  418. }
  419. let mainSliderList = document.querySelectorAll('.main-content .slider'); // 廣告下方列表
  420. let count;
  421. window.innerWidth < 415 ? count = 1 : count = 2;
  422. for (let i = 0; i < mainSliderList.length; i++) {
  423. let element = $(`.main-content .slider.item-0${i}`);
  424. const progressBar = $(`.main-content .progress.item-0${i}`);
  425. const progressBarLabel = $('.main-content .slider-label');
  426. element.on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  427. let calc = ((nextSlide) / (slick.slideCount - count)) * 100;
  428. progressBar
  429. .css('background-size', calc + '% 100%')
  430. .attr('aria-valuenow', calc);
  431. progressBarLabel.text(calc + '% completed');
  432. });
  433. }
  434. // 廣告彈跳視窗 Modal
  435. (function createModal() {
  436. const newDiv = document.createElement("div");
  437. let str = `
  438. <div class="modal fade" id="adModal" tabindex="-1" aria-labelledby="adModalLabel" aria-hidden="true">
  439. <div class="modal-dialog modal-dialog-centered">
  440. <div class="modal-content">
  441. <div class="modal-header">
  442. <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
  443. </div>
  444. <div class="modal-body p-0">
  445. <a href="https://hhh.com.tw/HHH_NEW/columns_detail/7088.php?utm_source=GS&utm_medium=POPUP2&utm_campaign=15thanniversary_A" target="_blank">
  446. <img src="./hhh_index/images/230215_幸福空間15週年慶_1200x800.jpg" alt="" class="img-fluid">
  447. </a>
  448. </div>
  449. </div>
  450. </div>
  451. </div>`;
  452. newDiv.innerHTML = str;
  453. document.body.appendChild(newDiv);
  454. })();
  455. /* 判斷閒置 */
  456. let defaultNum = 60; // 60 秒
  457. let maxTime = defaultNum;
  458. let intervalId;
  459. let time = maxTime;
  460. $('body').on('keydown mousemove mousedown', function (e) {
  461. maxTime = defaultNum; // Seconds
  462. time = maxTime; // Reset
  463. });
  464. runSetInterval();
  465. function runSetInterval() {
  466. intervalId = setInterval(function () {
  467. time--;
  468. if (time <= 0) {
  469. ShowInvalidLoginMessage();
  470. clearInterval(intervalId);
  471. }
  472. }, 1000)
  473. }
  474. $('#adModal').on('hide.bs.modal', function () {
  475. dialogTimeclose();
  476. runSetInterval();
  477. $('body').addClass('scrollable');
  478. });
  479. function dialogTimeclose() {
  480. time = maxTime;
  481. }
  482. function ShowInvalidLoginMessage() {
  483. $('#adModal').modal('show');
  484. }
  485. /* genjson_new 新版首頁 */
  486. let result;
  487. $.ajax({
  488. method: "get",
  489. url: "./hhh_index/json/data_index.json",
  490. // url: "https://m3.hhh.com.tw:18689/genjson_new?filename=realtime.json",
  491. dataType: "json",
  492. }).done((data) => {
  493. result = [...data];
  494. // 隱藏 loading
  495. $('body').removeClass('unscrollable');
  496. $('.loading-item').addClass('loading-hide');
  497. let ad = localStorage.getItem('ad');
  498. if (!ad) {
  499. localStorage.setItem('ad', true);
  500. $('#adModal').modal('show');
  501. } else {
  502. $('#adModal').modal('hide');
  503. $('body').addClass('scrollable');
  504. }
  505. renderBanner(result);
  506. renderData(result); // 廣告上方列表
  507. renderEventAd(result); // 廣告輪播
  508. renderTopic(); // 主題企劃
  509. renderDesigner(result); // 推薦設計師
  510. renderTabContent(result); // 最夯設計, 影音實錄, 專欄文章
  511. }).fail((error) => {
  512. console.log('genjson_new error', error);
  513. });
  514. $.ajax({
  515. method: "get",
  516. url: "./hhh_index/json/index-slider.json",
  517. async: false,
  518. dataType: "json",
  519. }).done((data) => {
  520. renderJsonData(data); // 依照空間尋找商品, 依照專長尋找設計師
  521. }).fail((error) => {
  522. console.log('error', error);
  523. });
  524. function renderJsonData(data) {
  525. data.map(e => {
  526. if (e.tab === "依照空間尋找商品") {
  527. let str = "";
  528. for (let i = 0; i < e.data.length; i++) {
  529. let item = e.data[i];
  530. str += `
  531. <div>
  532. <section>
  533. <span class="slide-img">
  534. <a href="${item.url}" target="_blank">
  535. <img class="slide-item img-fluid" src="${item.image}" alt="${item.name}">
  536. <h3>${item.name}</h3>
  537. </a>
  538. </span>
  539. </section>
  540. </div>`
  541. }
  542. $(".space-slider").html(str);
  543. // 輪播設定
  544. $('.space-slider').slick({
  545. infinite: false,
  546. slidesToShow: 4,
  547. slidesToScroll: 1,
  548. variableWidth: false,
  549. prevArrow:
  550. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  551. nextArrow:
  552. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  553. responsive: [
  554. {
  555. breakpoint: 991,
  556. settings: {
  557. slidesToShow: 3,
  558. slidesToScroll: 1
  559. }
  560. },
  561. {
  562. breakpoint: 767,
  563. settings: {
  564. slidesToShow: 2,
  565. slidesToScroll: 1,
  566. }
  567. },
  568. {
  569. breakpoint: 575,
  570. settings: {
  571. slidesToShow: 2,
  572. slidesToScroll: 1,
  573. variableWidth: true,
  574. arrows: false,
  575. }
  576. }
  577. ]
  578. });
  579. } else {
  580. let str = "";
  581. for (let i = 0; i < e.data.length; i++) {
  582. let item = e.data[i];
  583. str += `
  584. <div>
  585. <section>
  586. <span class="slide-img">
  587. <a href="${item.url}" target="_blank">
  588. <img class="slide-item img-fluid" src="${item.image}" alt="${item.name}">
  589. <h3>${item.name}</h3>
  590. </a>
  591. </span>
  592. </section>
  593. </div>`
  594. }
  595. $(".options-slider.designer").html(str);
  596. }
  597. hideSlickArrow();
  598. })
  599. }
  600. let locationUrl = '';
  601. window.innerWidth > 767 ? locationUrl = "https://hhh.com.tw" : locationUrl = "https://m.hhh.com.tw";
  602. // 首頁廣告上方列表
  603. function renderData(data) {
  604. data.map((e) => {
  605. if (e._comment === "加好物商品") {
  606. renderDom("slider-01", e.data);
  607. } else if (e._comment === "首頁photo頁") {
  608. e.data.map((list, index) => {
  609. renderDom(`slider-0${index + 2}`, list.data);
  610. // $(`.slider-0${index + 1}-title`).text(list.tab);
  611. })
  612. }
  613. })
  614. // 輪播設定
  615. $('.options-slider').slick({
  616. infinite: false,
  617. slidesToShow: 6,
  618. slidesToScroll: 6,
  619. variableWidth: false,
  620. prevArrow:
  621. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  622. nextArrow:
  623. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  624. responsive: [
  625. {
  626. breakpoint: 1200,
  627. settings: {
  628. slidesToShow: 5,
  629. slidesToScroll: 5,
  630. }
  631. },
  632. {
  633. breakpoint: 991,
  634. settings: {
  635. slidesToShow: 4,
  636. slidesToScroll: 4
  637. }
  638. },
  639. {
  640. breakpoint: 767,
  641. settings: {
  642. slidesToShow: 3,
  643. slidesToScroll: 1,
  644. }
  645. },
  646. {
  647. breakpoint: 575,
  648. settings: {
  649. slidesToShow: 3,
  650. slidesToScroll: 1,
  651. variableWidth: true,
  652. arrows: false,
  653. }
  654. },
  655. {
  656. breakpoint: 415,
  657. settings: {
  658. slidesToShow: 2,
  659. slidesToScroll: 1,
  660. variableWidth: true,
  661. arrows: false,
  662. }
  663. }
  664. ]
  665. });
  666. hideSlickArrow();
  667. }
  668. function renderDom(sec, data) {
  669. if (sec !== "slider-01") {
  670. data = data.sort((a, b) => a.order - b.order);
  671. let str = "";
  672. for (let i = 0; i < data.length; i++) {
  673. str += `
  674. <div>
  675. <section>
  676. <span class="slide-img">
  677. <a href="${locationUrl + data[i]["url"]}" target="_blank">
  678. <img class="${sec}-${i + 1} slide-item img-fluid" src="${locationUrl + data[i]["image"]}" alt="${data[i]["name"]}">
  679. <h3>${data[i]["name"]}</h3>
  680. </a>
  681. </span>
  682. </section>
  683. </div>`
  684. }
  685. $(`.${sec}`).html(str);
  686. } else {
  687. data = data.sort(() => Math.random() - 0.5); // 隨機排序
  688. data = data.slice(0, 12); // 取前 12 筆
  689. let str = "";
  690. for (let i = 0; i < data.length; i++) {
  691. str += `
  692. <div>
  693. <section>
  694. <span class="slide-img">
  695. <a href="${data[i]["link"]}" target="_blank">
  696. <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["imgUrl"]}" alt="${data[i]["title"]}">
  697. <h3>
  698. <strong>${data[i]["title"]}</strong>
  699. </h3>
  700. </a>
  701. </span>
  702. </section>
  703. </div>`
  704. }
  705. $(`.${sec}`).html(str);
  706. }
  707. }
  708. // let timer;
  709. // $(window).resize(function () {
  710. // // 延遲縮放
  711. // window.clearTimeout(timer);
  712. // timer = window.setTimeout(() => {
  713. // renderTopic();
  714. // }, 100);
  715. // })
  716. // 首頁主題企劃
  717. function renderTopic() {
  718. if (result) {
  719. result.map(list => {
  720. if (list._comment === "主題企劃區") {
  721. let webData = [];
  722. let mobileData = [];
  723. list.data.filter(e => {
  724. if (e.tab === "web") {
  725. webData = e.data;
  726. } else {
  727. mobileData = e.data;
  728. }
  729. });
  730. let arr;
  731. let str = "";
  732. // 固定取手機版第一筆
  733. let linkHref = `https://m.hhh.com.tw${mobileData[0].link}`;
  734. window.innerWidth > 767 ? arr = webData : arr = mobileData;
  735. let topicLink = document.querySelector(".topic-content .more-link");
  736. topicLink.setAttribute("href", linkHref);
  737. for (let i = 0; i < arr.length; i++) {
  738. str += `
  739. <div>
  740. <section>
  741. <span class="slide-img">
  742. <a href="${locationUrl + arr[i]["link"]}" target="_blank">
  743. <div class="img-box slide-img"> <img src="${arr[i]["imgUrl"]}" alt="${arr[i]["title"]}" class="img-fluid"></div>
  744. </a>
  745. </span>
  746. <a href="${locationUrl + arr[i]["link"]}" target="_blank">
  747. <h3 class="mt-2 ellipsis-title">${arr[i]["title"]}</h3>
  748. </a>
  749. </section>
  750. </div>`;
  751. }
  752. $('.topic-slider').html(str);
  753. // 輪播設定
  754. $('.topic-slider').slick({
  755. infinite: false,
  756. slidesToShow: 4,
  757. slidesToScroll: 4,
  758. variableWidth: false,
  759. prevArrow:
  760. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  761. nextArrow:
  762. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  763. responsive: [
  764. {
  765. breakpoint: 991,
  766. settings: {
  767. slidesToShow: 2,
  768. slidesToScroll: 2,
  769. }
  770. },
  771. {
  772. breakpoint: 767,
  773. settings: {
  774. slidesToShow: 2,
  775. slidesToScroll: 1,
  776. // variableWidth: true,
  777. // arrows: false,
  778. }
  779. },
  780. {
  781. breakpoint: 575,
  782. settings: {
  783. slidesToShow: 2,
  784. slidesToScroll: 1,
  785. variableWidth: true,
  786. arrows: false,
  787. }
  788. },
  789. {
  790. breakpoint: 415,
  791. settings: {
  792. slidesToShow: 1,
  793. slidesToScroll: 1,
  794. variableWidth: true,
  795. arrows: false,
  796. }
  797. }
  798. ]
  799. });
  800. }
  801. });
  802. }
  803. }
  804. // 按鈕 hover
  805. $(function () {
  806. $('.top-card a, .center-card a')
  807. .on('mouseenter', function (e) {
  808. var parentOffset = $(this).offset(),
  809. relX = e.pageX - parentOffset.left,
  810. relY = e.pageY - parentOffset.top;
  811. $(this).find('span').css({ top: relY, left: relX })
  812. })
  813. .on('mouseout', function (e) {
  814. var parentOffset = $(this).offset(),
  815. relX = e.pageX - parentOffset.left,
  816. relY = e.pageY - parentOffset.top;
  817. $(this).find('span').css({ top: relY, left: relX })
  818. });
  819. });
  820. // 首頁廣告輪播
  821. function renderEventAd(data) {
  822. data.map(list => {
  823. if (list._comment === "活動頁banners區") {
  824. let str = "";
  825. list.data = list.data.sort(() => Math.random() - 0.5); // 隨機排序
  826. for (let i = 0; i < list.data.length; i++) {
  827. str += `
  828. <div>
  829. <a href="${list.data[i]["link"]}" target="_blank">
  830. <img class="slide-item img-fluid" src="${list.data[i]["webp"]}" alt="">
  831. </a>
  832. </div>`
  833. }
  834. $('.ad-content .ad-slider').html(str);
  835. }
  836. });
  837. // 輪播設定
  838. $('.ad-content .ad-slider').slick({
  839. dots: false,
  840. infinite: true,
  841. speed: 300,
  842. arrows: true,
  843. autoplay: true,
  844. autoplaySpeed: 4000,
  845. slidesToShow: 2,
  846. slidesToScroll: 1,
  847. prevArrow:
  848. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  849. nextArrow:
  850. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  851. responsive: [
  852. {
  853. breakpoint: 767,
  854. settings: {
  855. slidesToShow: 1,
  856. slidesToScroll: 1,
  857. }
  858. },
  859. {
  860. breakpoint: 575,
  861. settings: {
  862. slidesToShow: 1,
  863. slidesToScroll: 1,
  864. arrows: false
  865. }
  866. }
  867. ]
  868. });
  869. }
  870. // 隨機對調前後順序(e.g. 5678 1234)
  871. function randomArr(ary, num) {
  872. // 取得隨機整數
  873. let randomVal;
  874. (Math.random() > 0.5) ? randomVal = 1 : randomVal = 0;
  875. let data = [...ary]; // 深拷貝
  876. let list = [];
  877. // index < 拆分的次數
  878. // 如陣列長度為 8 跟 12,拆分次數即為 2 跟 3
  879. // 例如:[8] => [4,4] or [12] => [4,4,4]
  880. for (let index = 0; index < num; index++) {
  881. list.push(data.splice(4, 4));
  882. // list.push(test.splice(4, 4));
  883. }
  884. list = list.sort(() => Math.random() - 0.5); // 隨機排序
  885. let finalData = [];
  886. if (randomVal) {
  887. finalData = data.concat(list);
  888. } else {
  889. finalData = list.concat(data);
  890. }
  891. return finalData.flat(Infinity) // 展開陣列
  892. }
  893. function renderDesigner(data) {
  894. data.map(list => {
  895. if (list._comment === "推薦設計師") {
  896. let randomData = randomArr(list.data, 2);
  897. let str = "";
  898. for (let i = 0; i < randomData.length; i++) {
  899. const item = randomData[i];
  900. str += `
  901. <div>
  902. <section>
  903. <span class="slide-img">
  904. <a href="${locationUrl + item.link}" target="_blank">
  905. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.name}|${item.designers_name}">
  906. <span class="img-border"></span>
  907. </a>
  908. </span>
  909. <a href="${locationUrl + item.link}" target="_blank">
  910. <h3 class="ellipsis-title">
  911. ${item.name}
  912. </h3>
  913. <h3 class="name">
  914. ${item.designers_name}
  915. <small>設計師</small>
  916. </h3>
  917. </a>
  918. </section>
  919. </div>`;
  920. }
  921. $('.designer-slider').html(str);
  922. // 輪播設定
  923. $('.designer-slider').slick({
  924. infinite: false,
  925. slidesToShow: 6,
  926. slidesToScroll: 6,
  927. variableWidth: false,
  928. prevArrow:
  929. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  930. nextArrow:
  931. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  932. responsive: [
  933. {
  934. breakpoint: 1200,
  935. settings: {
  936. slidesToShow: 4,
  937. slidesToScroll: 4,
  938. }
  939. },
  940. {
  941. breakpoint: 767,
  942. settings: {
  943. slidesToShow: 3,
  944. slidesToScroll: 3,
  945. }
  946. },
  947. {
  948. breakpoint: 575,
  949. settings: {
  950. slidesToShow: 2,
  951. slidesToScroll: 1,
  952. variableWidth: true,
  953. arrows: false,
  954. }
  955. },
  956. ]
  957. });
  958. hideSlickArrow();
  959. $(".designer-content h3").hover(
  960. function () {
  961. $(this).parent().prev().children().children('.img-border').css('opacity', '1');
  962. }, function () {
  963. $(this).parent().prev().children().children('.img-border').css('opacity', '0');
  964. }
  965. );
  966. }
  967. });
  968. }
  969. function renderTabContent(data) {
  970. data.map(list => {
  971. if (list._comment === "tab區塊-最夯設計, 影音實錄, 專欄文章") {
  972. list.data.map(item => {
  973. if (item.tab === "編輯精選") {
  974. let randomData = randomArr(item.data, 1);
  975. let str = "";
  976. let tagList = [];
  977. for (let i = 0; i < randomData.length; i++) {
  978. const item = randomData[i];
  979. str += `
  980. <div>
  981. <section>
  982. <span class="slide-img">
  983. <a href="${locationUrl + item.link}" target="_blank">
  984. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.title}">
  985. </a>
  986. </span>
  987. <a href="${locationUrl + item.link}" target="_blank" class="title">
  988. <h3 class="mb-0 ellipsis-title">${item.title}</h3>
  989. </a>
  990. <div class="tab-block tag-list-${i}"></div>
  991. </section>
  992. </div>`;
  993. tagList.push(item.ctag);
  994. }
  995. $('.featured-slider').html(str);
  996. // 輪播設定
  997. $('.featured-slider').slick({
  998. infinite: false,
  999. slidesToShow: 4,
  1000. slidesToScroll: 4,
  1001. variableWidth: false,
  1002. prevArrow:
  1003. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1004. nextArrow:
  1005. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1006. responsive: [
  1007. {
  1008. breakpoint: 991,
  1009. settings: {
  1010. slidesToShow: 2,
  1011. slidesToScroll: 2,
  1012. }
  1013. },
  1014. {
  1015. breakpoint: 767,
  1016. settings: {
  1017. slidesToShow: 2,
  1018. slidesToScroll: 2,
  1019. // variableWidth: true,
  1020. // arrows: false,
  1021. }
  1022. },
  1023. {
  1024. breakpoint: 575,
  1025. settings: {
  1026. slidesToShow: 2,
  1027. slidesToScroll: 2,
  1028. variableWidth: true,
  1029. arrows: false,
  1030. }
  1031. },
  1032. {
  1033. breakpoint: 415,
  1034. settings: {
  1035. slidesToShow: 1,
  1036. slidesToScroll: 1,
  1037. variableWidth: true,
  1038. arrows: false,
  1039. }
  1040. }
  1041. ]
  1042. });
  1043. hideSlickArrow(); // 判斷輪播按鈕顯示
  1044. randomTag(randomData, tagList, "featured-content"); // 渲染標籤
  1045. } else if (item.tab === "最夯設計") {
  1046. let randomData = randomArr(item.data, 1);
  1047. let str = "";
  1048. let tagList = [];
  1049. for (let i = 0; i < randomData.length; i++) {
  1050. const item = randomData[i];
  1051. str += `
  1052. <div>
  1053. <section>
  1054. <span class="slide-img">
  1055. <a href="${locationUrl + item.link}" target="_blank">
  1056. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.title}">
  1057. </a>
  1058. <a href="${locationUrl + item.link}" target="_blank" class="designer-item">
  1059. <img class="slide-item img-fluid" src="${item.img_designer}" alt="${item.title_designer}">
  1060. <h2>${item.title_designer}</h2>
  1061. </a>
  1062. <a href="${locationUrl + item.link}" target="_blank" class="title">
  1063. <h3 class="mb-0 ellipsis-title">${item.title}</h3>
  1064. </a>
  1065. </span>
  1066. <div class="tab-block tag-list-${i}"></div>
  1067. </section>
  1068. </div>`;
  1069. tagList.push(item.ctag);
  1070. }
  1071. $('.popular-slider').html(str);
  1072. // 輪播設定
  1073. $('.popular-slider').slick({
  1074. infinite: false,
  1075. slidesToShow: 4,
  1076. slidesToScroll: 4,
  1077. variableWidth: false,
  1078. prevArrow:
  1079. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1080. nextArrow:
  1081. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1082. responsive: [
  1083. {
  1084. breakpoint: 991,
  1085. settings: {
  1086. slidesToShow: 2,
  1087. slidesToScroll: 2,
  1088. }
  1089. },
  1090. {
  1091. breakpoint: 767,
  1092. settings: {
  1093. slidesToShow: 2,
  1094. slidesToScroll: 2,
  1095. // variableWidth: true,
  1096. // arrows: false,
  1097. }
  1098. },
  1099. {
  1100. breakpoint: 575,
  1101. settings: {
  1102. slidesToShow: 2,
  1103. slidesToScroll: 2,
  1104. variableWidth: true,
  1105. arrows: false,
  1106. }
  1107. },
  1108. {
  1109. breakpoint: 415,
  1110. settings: {
  1111. slidesToShow: 1,
  1112. slidesToScroll: 1,
  1113. variableWidth: true,
  1114. arrows: false,
  1115. }
  1116. },
  1117. ]
  1118. });
  1119. hideSlickArrow(); // 判斷輪播按鈕顯示
  1120. randomTag(randomData, tagList, "popular-content"); // 渲染標籤
  1121. } else if (item.tab === "最新影音實錄") {
  1122. let randomData = randomArr(item.data, 1);
  1123. let str = "";
  1124. for (let i = 0; i < randomData.length; i++) {
  1125. const item = randomData[i];
  1126. // <a href="javascript:;" onclick="videoSet('${item.link}','${item.description}')" data-bs-toggle="modal" data-src="${item.link}" data-bs-target="#youtubeModal">
  1127. // <img class="slide-item img-fluid" src="${item.imgUrl}" alt="">
  1128. // </a>
  1129. str += `
  1130. <div>
  1131. <section>
  1132. <span class="slide-img">
  1133. <a href="${item.link}" target="_blank">
  1134. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.description}">
  1135. <span class="play-btn">
  1136. <img class="slide-item img-fluid" src="./hhh_index/images/icon/material-play-circle-outline.svg" alt="">
  1137. </span>
  1138. </a>
  1139. </span>
  1140. <a href="${item.link}" target="_blank" class="title">
  1141. <h3 class="mb-0 mt-3 ellipsis-title">${item.description}</h3>
  1142. </a>
  1143. </section>
  1144. </div>`;
  1145. }
  1146. $('.video-slider').html(str);
  1147. // 輪播設定
  1148. $('.video-slider').slick({
  1149. infinite: false,
  1150. slidesToShow: 4,
  1151. slidesToScroll: 4,
  1152. variableWidth: false,
  1153. prevArrow:
  1154. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1155. nextArrow:
  1156. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1157. responsive: [
  1158. {
  1159. breakpoint: 991,
  1160. settings: {
  1161. slidesToShow: 2,
  1162. slidesToScroll: 2,
  1163. }
  1164. },
  1165. {
  1166. breakpoint: 767,
  1167. settings: {
  1168. slidesToShow: 2,
  1169. slidesToScroll: 2,
  1170. }
  1171. },
  1172. {
  1173. breakpoint: 575,
  1174. settings: {
  1175. slidesToShow: 2,
  1176. slidesToScroll: 1,
  1177. variableWidth: true,
  1178. arrows: false,
  1179. }
  1180. },
  1181. {
  1182. breakpoint: 415,
  1183. settings: {
  1184. slidesToShow: 1,
  1185. slidesToScroll: 1,
  1186. variableWidth: true,
  1187. arrows: false,
  1188. }
  1189. }
  1190. ]
  1191. });
  1192. hideSlickArrow(); // 判斷輪播按鈕顯示
  1193. }
  1194. })
  1195. }
  1196. })
  1197. // hover 事件
  1198. $(".main-content h3").hover(
  1199. function () {
  1200. $(this).parent().parent().addClass('img-scale');
  1201. }, function () {
  1202. $(this).parent().parent().removeClass('img-scale');
  1203. }
  1204. );
  1205. $(".main-content .slide-img").hover(
  1206. function () {
  1207. $(this).parent().parent().find('h3').css('color', '#ee751b');
  1208. }, function () {
  1209. ;
  1210. $(this).parent().parent().find('h3').css('color', '#727272');
  1211. }
  1212. );
  1213. }
  1214. // 參數需帶入(隨機排序清單, 標籤陣列, 外層className)
  1215. function randomTag(randomData, tagList, content) {
  1216. let tagLink;
  1217. if (content === "featured-content") {
  1218. // 編輯精選
  1219. tagLink = "column";
  1220. } else {
  1221. // 最夯設計
  1222. tagLink = "case";
  1223. }
  1224. for (let index = 0; index < tagList.length; index++) {
  1225. const element = tagList[index];
  1226. randomData.map((e, i) => {
  1227. if (i === index) {
  1228. let list = [];
  1229. for (let i = 0; i < element.length; i++) {
  1230. const item = element[i];
  1231. if (item !== "") {
  1232. let tag = `
  1233. <a href=https://hhh.com.tw/search/lists/${tagLink}/${item}-keyword/" target="_blank">
  1234. <h4>${item}</h4>
  1235. </a>
  1236. `;
  1237. list.push(tag);
  1238. }
  1239. }
  1240. $(`.${content} .tag-list-${index}`).html(list);
  1241. }
  1242. })
  1243. }
  1244. }
  1245. function hideSlickArrow() {
  1246. /* 隱藏輪播 disabled 按鈕,後續改為點擊判斷 */
  1247. $('.slick-arrow.slick-disabled').css('display', 'none');
  1248. $('.slick-arrow').click(function () {
  1249. $('.slick-arrow').css('display', 'block');
  1250. $('.slick-arrow.slick-disabled').css('display', 'none');
  1251. });
  1252. }
  1253. // 影音實錄 Modal
  1254. function videoSet(src, title) {
  1255. let url = new URL(src);
  1256. let id = url.searchParams.get('v');
  1257. $("#video").attr('src', `https://www.youtube-nocookie.com/embed/${id}`);
  1258. $("#youtubeModal h2").text(`${title}`);
  1259. }
  1260. // Back to top
  1261. $(window).scroll(function () {
  1262. if ($(this).scrollTop()) {
  1263. $('.btn-box').fadeIn();
  1264. } else {
  1265. $('.btn-box').fadeOut();
  1266. }
  1267. });