index.js 41 KB

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