index.js 40 KB

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