index.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  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. renderSec00(result);
  507. renderBanner(result);
  508. renderData(result); // 廣告上方列表
  509. renderEventAd(result); // 廣告輪播
  510. renderTopic(); // 主題企劃
  511. renderDesigner(result); // 推薦設計師
  512. renderTabContent(result); // 最夯設計, 影音實錄, 專欄文章
  513. }).fail((error) => {
  514. console.log('genjson_new error', error);
  515. });
  516. $.ajax({
  517. method: "get",
  518. url: "./hhh_index/json/index-slider.json",
  519. async: false,
  520. dataType: "json",
  521. }).done((data) => {
  522. renderJsonData(data); // 依照空間尋找商品, 依照專長尋找設計師
  523. }).fail((error) => {
  524. console.log('error', error);
  525. });
  526. function renderJsonData(data) {
  527. data.map(e => {
  528. if (e.tab === "依照空間尋找商品") {
  529. let str = "";
  530. for (let i = 0; i < e.data.length; i++) {
  531. let item = e.data[i];
  532. str += `
  533. <div>
  534. <section>
  535. <span class="slide-img">
  536. <a href="${item.url}" target="_blank">
  537. <img class="slide-item img-fluid" src="${item.image}" alt="${item.name}">
  538. <h3>${item.name}</h3>
  539. </a>
  540. </span>
  541. </section>
  542. </div>`
  543. }
  544. $(".space-slider").html(str);
  545. // 輪播設定
  546. $('.space-slider').slick({
  547. infinite: false,
  548. slidesToShow: 4,
  549. slidesToScroll: 1,
  550. variableWidth: false,
  551. prevArrow:
  552. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  553. nextArrow:
  554. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  555. responsive: [
  556. {
  557. breakpoint: 991,
  558. settings: {
  559. slidesToShow: 3,
  560. slidesToScroll: 1
  561. }
  562. },
  563. {
  564. breakpoint: 767,
  565. settings: {
  566. slidesToShow: 2,
  567. slidesToScroll: 1,
  568. }
  569. },
  570. {
  571. breakpoint: 575,
  572. settings: {
  573. slidesToShow: 2,
  574. slidesToScroll: 1,
  575. variableWidth: true,
  576. arrows: false,
  577. }
  578. }
  579. ]
  580. });
  581. } else {
  582. let str = "";
  583. for (let i = 0; i < e.data.length; i++) {
  584. let item = e.data[i];
  585. str += `
  586. <div>
  587. <section>
  588. <span class="slide-img">
  589. <a href="${item.url}" target="_blank">
  590. <img class="slide-item img-fluid" src="${item.image}" alt="${item.name}">
  591. <h3>${item.name}</h3>
  592. </a>
  593. </span>
  594. </section>
  595. </div>`
  596. }
  597. $(".options-slider.designer").html(str);
  598. }
  599. hideSlickArrow();
  600. })
  601. }
  602. let locationUrl = '';
  603. window.innerWidth > 767 ? locationUrl = "https://hhh.com.tw" : locationUrl = "https://m.hhh.com.tw";
  604. // 首頁廣告上方列表
  605. function renderData(data) {
  606. data.map((e) => {
  607. if (e._comment === "加好物商品") {
  608. renderDom("slider-01", e.data);
  609. } else if (e._comment === "首頁photo頁") {
  610. e.data.map((list, index) => {
  611. renderDom(`slider-0${index + 2}`, list.data);
  612. // $(`.slider-0${index + 1}-title`).text(list.tab);
  613. })
  614. }
  615. })
  616. // 輪播設定
  617. $('.options-slider').slick({
  618. infinite: false,
  619. slidesToShow: 6,
  620. slidesToScroll: 6,
  621. variableWidth: false,
  622. prevArrow:
  623. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  624. nextArrow:
  625. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  626. responsive: [
  627. {
  628. breakpoint: 1200,
  629. settings: {
  630. slidesToShow: 5,
  631. slidesToScroll: 5,
  632. }
  633. },
  634. {
  635. breakpoint: 991,
  636. settings: {
  637. slidesToShow: 4,
  638. slidesToScroll: 4
  639. }
  640. },
  641. {
  642. breakpoint: 767,
  643. settings: {
  644. slidesToShow: 3,
  645. slidesToScroll: 1,
  646. }
  647. },
  648. {
  649. breakpoint: 575,
  650. settings: {
  651. slidesToShow: 3,
  652. slidesToScroll: 1,
  653. variableWidth: true,
  654. arrows: false,
  655. }
  656. },
  657. {
  658. breakpoint: 415,
  659. settings: {
  660. slidesToShow: 2,
  661. slidesToScroll: 1,
  662. variableWidth: true,
  663. arrows: false,
  664. }
  665. }
  666. ]
  667. });
  668. hideSlickArrow();
  669. }
  670. function renderDom(sec, data) {
  671. if (sec !== "slider-01") {
  672. data = data.sort((a, b) => a.order - b.order);
  673. let str = "";
  674. for (let i = 0; i < data.length; i++) {
  675. str += `
  676. <div>
  677. <section>
  678. <span class="slide-img">
  679. <a href="${locationUrl + data[i]["url"]}" target="_blank">
  680. <img class="${sec}-${i + 1} slide-item img-fluid" src="${locationUrl + data[i]["image"]}" alt="${data[i]["name"]}">
  681. <h3>${data[i]["name"]}</h3>
  682. </a>
  683. </span>
  684. </section>
  685. </div>`
  686. }
  687. $(`.${sec}`).html(str);
  688. } else {
  689. data = data.sort(() => Math.random() - 0.5); // 隨機排序
  690. data = data.slice(0, 12); // 取前 12 筆
  691. let str = "";
  692. for (let i = 0; i < data.length; i++) {
  693. str += `
  694. <div>
  695. <section>
  696. <span class="slide-img">
  697. <a href="${data[i]["link"]}" target="_blank">
  698. <img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]["imgUrl"]}" alt="${data[i]["title"]}">
  699. <h3>
  700. <strong>${data[i]["title"]}</strong>
  701. </h3>
  702. </a>
  703. </span>
  704. </section>
  705. </div>`
  706. }
  707. $(`.${sec}`).html(str);
  708. }
  709. }
  710. // let timer;
  711. // $(window).resize(function () {
  712. // // 延遲縮放
  713. // window.clearTimeout(timer);
  714. // timer = window.setTimeout(() => {
  715. // renderTopic();
  716. // }, 100);
  717. // })
  718. // 首頁主題企劃
  719. function renderTopic() {
  720. if (result) {
  721. result.map(list => {
  722. if (list._comment === "主題企劃區") {
  723. let webData = [];
  724. let mobileData = [];
  725. list.data.filter(e => {
  726. if (e.tab === "web") {
  727. webData = e.data;
  728. } else {
  729. mobileData = e.data;
  730. }
  731. });
  732. let arr;
  733. let str = "";
  734. // 固定取手機版第一筆
  735. let linkHref = `https://m.hhh.com.tw${mobileData[0].link}`;
  736. window.innerWidth > 767 ? arr = webData : arr = mobileData;
  737. let topicLink = document.querySelector(".topic-content .more-link");
  738. topicLink.setAttribute("href", linkHref);
  739. for (let i = 0; i < arr.length; i++) {
  740. str += `
  741. <div>
  742. <section>
  743. <span class="slide-img">
  744. <a href="${locationUrl + arr[i]["link"]}" target="_blank">
  745. <div class="img-box slide-img"> <img src="${arr[i]["imgUrl"]}" alt="${arr[i]["title"]}" class="img-fluid"></div>
  746. </a>
  747. </span>
  748. <a href="${locationUrl + arr[i]["link"]}" target="_blank">
  749. <h3 class="mt-2 ellipsis-title">${arr[i]["title"]}</h3>
  750. </a>
  751. </section>
  752. </div>`;
  753. }
  754. $('.topic-slider').html(str);
  755. // 輪播設定
  756. $('.topic-slider').slick({
  757. infinite: false,
  758. slidesToShow: 4,
  759. slidesToScroll: 4,
  760. variableWidth: false,
  761. prevArrow:
  762. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  763. nextArrow:
  764. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  765. responsive: [
  766. {
  767. breakpoint: 991,
  768. settings: {
  769. slidesToShow: 2,
  770. slidesToScroll: 2,
  771. }
  772. },
  773. {
  774. breakpoint: 767,
  775. settings: {
  776. slidesToShow: 2,
  777. slidesToScroll: 1,
  778. // variableWidth: true,
  779. // arrows: false,
  780. }
  781. },
  782. {
  783. breakpoint: 575,
  784. settings: {
  785. slidesToShow: 2,
  786. slidesToScroll: 1,
  787. variableWidth: true,
  788. arrows: false,
  789. }
  790. },
  791. {
  792. breakpoint: 415,
  793. settings: {
  794. slidesToShow: 1,
  795. slidesToScroll: 1,
  796. variableWidth: true,
  797. arrows: false,
  798. }
  799. }
  800. ]
  801. });
  802. }
  803. });
  804. }
  805. }
  806. // 按鈕 hover
  807. $(function () {
  808. $('.top-card a, .center-card a')
  809. .on('mouseenter', function (e) {
  810. var parentOffset = $(this).offset(),
  811. relX = e.pageX - parentOffset.left,
  812. relY = e.pageY - parentOffset.top;
  813. $(this).find('span').css({ top: relY, left: relX })
  814. })
  815. .on('mouseout', function (e) {
  816. var parentOffset = $(this).offset(),
  817. relX = e.pageX - parentOffset.left,
  818. relY = e.pageY - parentOffset.top;
  819. $(this).find('span').css({ top: relY, left: relX })
  820. });
  821. });
  822. // 首頁廣告輪播
  823. function renderEventAd(data) {
  824. data.map(list => {
  825. if (list._comment === "活動頁banners區") {
  826. let str = "";
  827. list.data = list.data.sort(() => Math.random() - 0.5); // 隨機排序
  828. for (let i = 0; i < list.data.length; i++) {
  829. str += `
  830. <div>
  831. <a href="${list.data[i]["link"]}" target="_blank">
  832. <img class="slide-item img-fluid" src="${list.data[i]["webp"]}" alt="">
  833. </a>
  834. </div>`
  835. }
  836. $('.ad-content .ad-slider').html(str);
  837. }
  838. });
  839. // 輪播設定
  840. $('.ad-content .ad-slider').slick({
  841. dots: false,
  842. infinite: true,
  843. speed: 300,
  844. arrows: true,
  845. autoplay: true,
  846. autoplaySpeed: 4000,
  847. slidesToShow: 2,
  848. slidesToScroll: 1,
  849. prevArrow:
  850. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  851. nextArrow:
  852. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  853. responsive: [
  854. {
  855. breakpoint: 767,
  856. settings: {
  857. slidesToShow: 1,
  858. slidesToScroll: 1,
  859. }
  860. },
  861. {
  862. breakpoint: 575,
  863. settings: {
  864. slidesToShow: 1,
  865. slidesToScroll: 1,
  866. arrows: false
  867. }
  868. }
  869. ]
  870. });
  871. }
  872. // 隨機對調前後順序(e.g. 5678 1234)
  873. function randomArr(ary, num) {
  874. // 取得隨機整數
  875. let randomVal;
  876. (Math.random() > 0.5) ? randomVal = 1 : randomVal = 0;
  877. let data = [...ary]; // 深拷貝
  878. let list = [];
  879. // index < 拆分的次數
  880. // 如陣列長度為 8 跟 12,拆分次數即為 2 跟 3
  881. // 例如:[8] => [4,4] or [12] => [4,4,4]
  882. for (let index = 0; index < num; index++) {
  883. list.push(data.splice(4, 4));
  884. // list.push(test.splice(4, 4));
  885. }
  886. list = list.sort(() => Math.random() - 0.5); // 隨機排序
  887. let finalData = [];
  888. if (randomVal) {
  889. finalData = data.concat(list);
  890. } else {
  891. finalData = list.concat(data);
  892. }
  893. return finalData.flat(Infinity) // 展開陣列
  894. }
  895. function renderDesigner(data) {
  896. data.map(list => {
  897. if (list._comment === "推薦設計師") {
  898. let randomData = randomArr(list.data, 2);
  899. let str = "";
  900. for (let i = 0; i < randomData.length; i++) {
  901. const item = randomData[i];
  902. str += `
  903. <div>
  904. <section>
  905. <span class="slide-img">
  906. <a href="${locationUrl + item.link}" target="_blank">
  907. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.name}|${item.designers_name}">
  908. <span class="img-border"></span>
  909. </a>
  910. </span>
  911. <a href="${locationUrl + item.link}" target="_blank">
  912. <h3 class="ellipsis-title">
  913. ${item.name}
  914. </h3>
  915. <h3 class="name">
  916. ${item.designers_name}
  917. <small>設計師</small>
  918. </h3>
  919. </a>
  920. </section>
  921. </div>`;
  922. }
  923. $('.designer-slider').html(str);
  924. // 輪播設定
  925. $('.designer-slider').slick({
  926. infinite: false,
  927. slidesToShow: 6,
  928. slidesToScroll: 6,
  929. variableWidth: false,
  930. prevArrow:
  931. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  932. nextArrow:
  933. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  934. responsive: [
  935. {
  936. breakpoint: 1200,
  937. settings: {
  938. slidesToShow: 4,
  939. slidesToScroll: 4,
  940. }
  941. },
  942. {
  943. breakpoint: 767,
  944. settings: {
  945. slidesToShow: 3,
  946. slidesToScroll: 3,
  947. }
  948. },
  949. {
  950. breakpoint: 575,
  951. settings: {
  952. slidesToShow: 2,
  953. slidesToScroll: 1,
  954. variableWidth: true,
  955. arrows: false,
  956. }
  957. },
  958. ]
  959. });
  960. hideSlickArrow();
  961. $(".designer-content h3").hover(
  962. function () {
  963. $(this).parent().prev().children().children('.img-border').css('opacity', '1');
  964. }, function () {
  965. $(this).parent().prev().children().children('.img-border').css('opacity', '0');
  966. }
  967. );
  968. }
  969. });
  970. }
  971. function renderTabContent(data) {
  972. data.map(list => {
  973. if (list._comment === "tab區塊-最夯設計, 影音實錄, 專欄文章") {
  974. list.data.map(item => {
  975. if (item.tab === "編輯精選") {
  976. let randomData = randomArr(item.data, 1);
  977. let str = "";
  978. let tagList = [];
  979. for (let i = 0; i < randomData.length; i++) {
  980. const item = randomData[i];
  981. str += `
  982. <div>
  983. <section>
  984. <span class="slide-img">
  985. <a href="${locationUrl + item.link}" target="_blank">
  986. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.title}">
  987. </a>
  988. </span>
  989. <a href="${locationUrl + item.link}" target="_blank" class="title">
  990. <h3 class="mb-0 ellipsis-title">${item.title}</h3>
  991. </a>
  992. <div class="tab-block tag-list-${i}"></div>
  993. </section>
  994. </div>`;
  995. tagList.push(item.ctag);
  996. }
  997. $('.featured-slider').html(str);
  998. // 輪播設定
  999. $('.featured-slider').slick({
  1000. infinite: false,
  1001. slidesToShow: 4,
  1002. slidesToScroll: 4,
  1003. variableWidth: false,
  1004. prevArrow:
  1005. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1006. nextArrow:
  1007. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1008. responsive: [
  1009. {
  1010. breakpoint: 991,
  1011. settings: {
  1012. slidesToShow: 2,
  1013. slidesToScroll: 2,
  1014. }
  1015. },
  1016. {
  1017. breakpoint: 767,
  1018. settings: {
  1019. slidesToShow: 2,
  1020. slidesToScroll: 2,
  1021. // variableWidth: true,
  1022. // arrows: false,
  1023. }
  1024. },
  1025. {
  1026. breakpoint: 575,
  1027. settings: {
  1028. slidesToShow: 2,
  1029. slidesToScroll: 2,
  1030. variableWidth: true,
  1031. arrows: false,
  1032. }
  1033. },
  1034. {
  1035. breakpoint: 415,
  1036. settings: {
  1037. slidesToShow: 1,
  1038. slidesToScroll: 1,
  1039. variableWidth: true,
  1040. arrows: false,
  1041. }
  1042. }
  1043. ]
  1044. });
  1045. hideSlickArrow(); // 判斷輪播按鈕顯示
  1046. randomTag(randomData, tagList, "featured-content"); // 渲染標籤
  1047. } else if (item.tab === "最夯設計") {
  1048. let randomData = randomArr(item.data, 1);
  1049. let str = "";
  1050. let tagList = [];
  1051. for (let i = 0; i < randomData.length; i++) {
  1052. const item = randomData[i];
  1053. str += `
  1054. <div>
  1055. <section>
  1056. <span class="slide-img">
  1057. <a href="${locationUrl + item.link}" target="_blank">
  1058. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.title}">
  1059. </a>
  1060. <a href="${locationUrl + item.link}" target="_blank" class="designer-item">
  1061. <img class="slide-item img-fluid" src="${item.img_designer}" alt="${item.title_designer}">
  1062. <h2>${item.title_designer}</h2>
  1063. </a>
  1064. <a href="${locationUrl + item.link}" target="_blank" class="title">
  1065. <h3 class="mb-0 ellipsis-title">${item.title}</h3>
  1066. </a>
  1067. </span>
  1068. <div class="tab-block tag-list-${i}"></div>
  1069. </section>
  1070. </div>`;
  1071. tagList.push(item.ctag);
  1072. }
  1073. $('.popular-slider').html(str);
  1074. // 輪播設定
  1075. $('.popular-slider').slick({
  1076. infinite: false,
  1077. slidesToShow: 4,
  1078. slidesToScroll: 4,
  1079. variableWidth: false,
  1080. prevArrow:
  1081. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1082. nextArrow:
  1083. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1084. responsive: [
  1085. {
  1086. breakpoint: 991,
  1087. settings: {
  1088. slidesToShow: 2,
  1089. slidesToScroll: 2,
  1090. }
  1091. },
  1092. {
  1093. breakpoint: 767,
  1094. settings: {
  1095. slidesToShow: 2,
  1096. slidesToScroll: 2,
  1097. // variableWidth: true,
  1098. // arrows: false,
  1099. }
  1100. },
  1101. {
  1102. breakpoint: 575,
  1103. settings: {
  1104. slidesToShow: 2,
  1105. slidesToScroll: 2,
  1106. variableWidth: true,
  1107. arrows: false,
  1108. }
  1109. },
  1110. {
  1111. breakpoint: 415,
  1112. settings: {
  1113. slidesToShow: 1,
  1114. slidesToScroll: 1,
  1115. variableWidth: true,
  1116. arrows: false,
  1117. }
  1118. },
  1119. ]
  1120. });
  1121. hideSlickArrow(); // 判斷輪播按鈕顯示
  1122. randomTag(randomData, tagList, "popular-content"); // 渲染標籤
  1123. } else if (item.tab === "最新影音實錄") {
  1124. let randomData = randomArr(item.data, 1);
  1125. let str = "";
  1126. for (let i = 0; i < randomData.length; i++) {
  1127. const item = randomData[i];
  1128. // <a href="javascript:;" onclick="videoSet('${item.link}','${item.description}')" data-bs-toggle="modal" data-src="${item.link}" data-bs-target="#youtubeModal">
  1129. // <img class="slide-item img-fluid" src="${item.imgUrl}" alt="">
  1130. // </a>
  1131. str += `
  1132. <div>
  1133. <section>
  1134. <span class="slide-img">
  1135. <a href="${item.link}" target="_blank">
  1136. <img class="slide-item img-fluid" src="${item.imgUrl}" alt="${item.description}">
  1137. <span class="play-btn">
  1138. <img class="slide-item img-fluid" src="./hhh_index/images/icon/material-play-circle-outline.svg" alt="">
  1139. </span>
  1140. </a>
  1141. </span>
  1142. <a href="${item.link}" target="_blank" class="title">
  1143. <h3 class="mb-0 mt-3 ellipsis-title">${item.description}</h3>
  1144. </a>
  1145. </section>
  1146. </div>`;
  1147. }
  1148. $('.video-slider').html(str);
  1149. // 輪播設定
  1150. $('.video-slider').slick({
  1151. infinite: false,
  1152. slidesToShow: 4,
  1153. slidesToScroll: 4,
  1154. variableWidth: false,
  1155. prevArrow:
  1156. '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1157. nextArrow:
  1158. '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  1159. responsive: [
  1160. {
  1161. breakpoint: 991,
  1162. settings: {
  1163. slidesToShow: 2,
  1164. slidesToScroll: 2,
  1165. }
  1166. },
  1167. {
  1168. breakpoint: 767,
  1169. settings: {
  1170. slidesToShow: 2,
  1171. slidesToScroll: 2,
  1172. }
  1173. },
  1174. {
  1175. breakpoint: 575,
  1176. settings: {
  1177. slidesToShow: 2,
  1178. slidesToScroll: 1,
  1179. variableWidth: true,
  1180. arrows: false,
  1181. }
  1182. },
  1183. {
  1184. breakpoint: 415,
  1185. settings: {
  1186. slidesToShow: 1,
  1187. slidesToScroll: 1,
  1188. variableWidth: true,
  1189. arrows: false,
  1190. }
  1191. }
  1192. ]
  1193. });
  1194. hideSlickArrow(); // 判斷輪播按鈕顯示
  1195. }
  1196. })
  1197. }
  1198. })
  1199. // hover 事件
  1200. $(".main-content h3").hover(
  1201. function () {
  1202. $(this).parent().parent().addClass('img-scale');
  1203. }, function () {
  1204. $(this).parent().parent().removeClass('img-scale');
  1205. }
  1206. );
  1207. $(".main-content .slide-img").hover(
  1208. function () {
  1209. $(this).parent().parent().find('h3').css('color', '#ee751b');
  1210. }, function () {
  1211. ;
  1212. $(this).parent().parent().find('h3').css('color', '#727272');
  1213. }
  1214. );
  1215. }
  1216. // 參數需帶入(隨機排序清單, 標籤陣列, 外層className)
  1217. function randomTag(randomData, tagList, content) {
  1218. let tagLink;
  1219. if (content === "featured-content") {
  1220. // 編輯精選
  1221. tagLink = "column";
  1222. } else {
  1223. // 最夯設計
  1224. tagLink = "case";
  1225. }
  1226. for (let index = 0; index < tagList.length; index++) {
  1227. const element = tagList[index];
  1228. randomData.map((e, i) => {
  1229. if (i === index) {
  1230. let list = [];
  1231. for (let i = 0; i < element.length; i++) {
  1232. const item = element[i];
  1233. if (item !== "") {
  1234. let tag = `
  1235. <a href=https://hhh.com.tw/search/lists/${tagLink}/${item}-keyword/" target="_blank">
  1236. <h4>${item}</h4>
  1237. </a>
  1238. `;
  1239. list.push(tag);
  1240. }
  1241. }
  1242. $(`.${content} .tag-list-${index}`).html(list);
  1243. }
  1244. })
  1245. }
  1246. }
  1247. function hideSlickArrow() {
  1248. /* 隱藏輪播 disabled 按鈕,後續改為點擊判斷 */
  1249. $('.slick-arrow.slick-disabled').css('display', 'none');
  1250. $('.slick-arrow').click(function () {
  1251. $('.slick-arrow').css('display', 'block');
  1252. $('.slick-arrow.slick-disabled').css('display', 'none');
  1253. });
  1254. }
  1255. // 影音實錄 Modal
  1256. function videoSet(src, title) {
  1257. let url = new URL(src);
  1258. let id = url.searchParams.get('v');
  1259. $("#video").attr('src', `https://www.youtube-nocookie.com/embed/${id}`);
  1260. $("#youtubeModal h2").text(`${title}`);
  1261. }
  1262. // Back to top
  1263. $(window).scroll(function () {
  1264. if ($(this).scrollTop()) {
  1265. $('.btn-box').fadeIn();
  1266. } else {
  1267. $('.btn-box').fadeOut();
  1268. }
  1269. });