index.js 41 KB

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