index.js 40 KB

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