index-list-mb.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. let userAgent;
  2. let isSafari = false;
  3. let browserName;
  4. // pagination variables
  5. let num_per_page = 10;
  6. let n = 0;
  7. let n_video = 0;
  8. let n_columns = 0;
  9. let totalPages = {
  10. intro: 0,
  11. video: 0,
  12. columns: 0,
  13. vr360: 0,
  14. company: 0,
  15. };
  16. let filter;
  17. const urlParams = new URLSearchParams(window.location.search);
  18. let getfilter = urlParams.get('q');
  19. let cid = urlParams.get('cid');
  20. console.log(getfilter, cid);
  21. $('.likeSee__views').click(function () {
  22. window.location.href = `./index_designerList_mb.html?q=views&cid=${cid}`
  23. $(this).css('color', '#EE7800');
  24. })
  25. $('.likeSee__sort').click(function () {
  26. window.location.href = `./index_designerList_mb.html?cid=${cid}`
  27. $(this).css('color', '#EE7800');
  28. })
  29. function getpathId() {
  30. let query = window.location.search.split('?').pop();
  31. return query.split('=')[1];
  32. }
  33. function getQuery() {
  34. let query = getfilter;
  35. console.log(query);
  36. if (query == 'views') {
  37. filter = 'views';
  38. $('.likeSee__views').css('color', '#EE7800');
  39. } else {
  40. filter = 'dateSort';
  41. $('.likeSee__sort').css('color', '#EE7800');
  42. }
  43. }
  44. window.onload = function () {
  45. //window.scrollBy(0, 1);
  46. if (screen.width >= 901) {
  47. window.location.href = `./index_designerList.html?cid=${cid}`;
  48. }
  49. userAgent = navigator.userAgent;
  50. detectBrowser(userAgent);
  51. detectDirection();
  52. let result;
  53. let designer;
  54. let id = 0;
  55. $.ajax({
  56. method: "GET",
  57. // url: `./json/designers-${cid}.json`,
  58. url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=1`,
  59. dataType: "json",
  60. }).done(function (msg) {
  61. getQuery();
  62. designer = [...msg][id];
  63. console.log(designer['Content']);
  64. if (filter == 'views') {
  65. designer['Content'][0]['Carddata'].sort(function (a, b) {
  66. return a[filter] > b[filter] ? -1 : 1;
  67. })
  68. } else {
  69. designer['Content'][0]['Carddata'].sort(function (a, b) {
  70. return a[filter] > b[filter] ? 1 : -1;
  71. })
  72. }
  73. renderinfoCard(designer);
  74. renderTab(designer['Content']);
  75. renderTabContent(designer['Content'], designer);
  76. renderModalTitle(designer['CompanyName']);
  77. console.log(filter);
  78. console.log(designer['Content'][0]['Carddata']);
  79. $(window).scroll(function () {
  80. let bottom = $("body").height() - $(window).height() - 1;
  81. if ($(window).scrollTop() >= bottom) {
  82. loadMoretest();
  83. }
  84. })
  85. // let bottom = $("body").height() - $(window).height() - 1;
  86. // if ($(window).scrollTop() >= bottom) {
  87. // loadMoretest();
  88. // }
  89. });
  90. }
  91. // var page = 1;
  92. // function loadMoretest() {
  93. // setTimeout(function () {
  94. // scroll_bottom_load_data(page);
  95. // page++;
  96. // return page
  97. // }, 500);
  98. // }
  99. function scroll_bottom_load_data(page) {
  100. $.ajax({
  101. method: "GET",
  102. url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=${page}`,
  103. }).done(function (msg) {
  104. result = [...msg];
  105. let append = '';
  106. let d = result[0].Content[0].Carddata;
  107. // let cardcontent=[]
  108. let nowTab = document.querySelector('.infoContent .tab-pane.show');
  109. if (nowTab === document.querySelector('#pills-intro')) {
  110. for (let j = 0; j < d.length; j++) {
  111. let tagStr = ''
  112. for (let k = 0; k < d[j]['tag'].length; k++) {
  113. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  114. }
  115. append += `<div class="col-6 col-md-4">
  116. <a href="${d[j]['url']}" target="_blank">
  117. <div class="card">
  118. <div style="overflow: hidden;">
  119. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  120. </div>
  121. </div>
  122. <div class="card-body">
  123. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  124. <p class="card-text mb-0">
  125. ${tagStr}
  126. </p>
  127. </div>
  128. </div>
  129. </a>
  130. </div>`
  131. // var cardcontent2=cardcontent.push.d;
  132. }
  133. if (d.length === 0) {
  134. $('#loading_img').css("display", "none")
  135. }
  136. // console.log(cardcontent2);
  137. $('#pills-intro .work__row').append(append);
  138. } else if (nowTab === document.querySelector('#pills-video')) {
  139. let append = '';
  140. let d = result[0].Content[0].Carddata;
  141. for (let j = 0; j < d.length; j++) {
  142. let tagStr = ''
  143. for (let k = 0; k < d[j]['tag'].length; k++) {
  144. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  145. }
  146. append += `<div class="col-6 col-md-4">
  147. <a href="${d[j]['url']}" target="_blank">
  148. <div class="card">
  149. <div style="overflow: hidden;">
  150. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  151. <img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">
  152. </div>
  153. </div>
  154. <div class="card-body">
  155. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  156. <p class="card-text mb-0">
  157. ${tagStr}
  158. </p>
  159. </div>
  160. </div>
  161. </a>
  162. </div>`
  163. }
  164. if (d.length === 0) {
  165. $('#loading_img').css("display", "none")
  166. }
  167. $('#pills-video .work__row').append(append);
  168. } else if (nowTab === document.querySelector('#pills-columns')) {
  169. let append = '';
  170. let d = result[0].Content[0].Carddata;
  171. for (let j = 0; j < d.length; j++) {
  172. let tagStr = ''
  173. for (let k = 0; k < d[j]['tag'].length; k++) {
  174. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  175. }
  176. append += `<div class="col-6 col-md-4">
  177. <a href="${d[j]['url']}" target="_blank">
  178. <div class="card">
  179. <div style="overflow: hidden;">
  180. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  181. </div>
  182. </div>
  183. <div class="card-body">
  184. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  185. <p class="card-text mb-0">
  186. ${tagStr}
  187. </p>
  188. </div>
  189. </div>
  190. </a>
  191. </div>`
  192. }
  193. $('#pills-columns .work__row').append(append);
  194. }
  195. });
  196. }
  197. var page = 1;
  198. function loadMoretest() {
  199. setTimeout(function () {
  200. // let pageNum = 2;
  201. // if(page<=pageNum){
  202. // pageNum++;
  203. // page++;
  204. // }else{
  205. // }
  206. scroll_bottom_load_data(page);
  207. page++;
  208. return page
  209. }, 500);
  210. }
  211. let over = document.querySelector('.infoContent__navBlock').offsetTop;
  212. function detectBrowser(agent) {
  213. if (userAgent.match(/chrome|chromium|crios/i)) {
  214. browserName = "chrome";
  215. } else if (userAgent.match(/firefox|fxios/i)) {
  216. browserName = "firefox";
  217. } else if (userAgent.match(/safari/i)) {
  218. browserName = "safari";
  219. } else if (userAgent.match(/opr\//i)) {
  220. browserName = "opera";
  221. } else if (userAgent.match(/edg/i)) {
  222. browserName = "edge";
  223. } else {
  224. browserName = "No browser detection";
  225. }
  226. if (browserName === 'safari') {
  227. isSafari = true;
  228. }
  229. console.log(isSafari);
  230. }
  231. function detectDirection() {
  232. let height = (window.screen.width * 2) / 3;
  233. $('.sec-02 .slide-item').css('height', `${height}px`);
  234. let topHeight = (window.screen.width * 30) / 131;
  235. $('.sec-00 .slide-item').css('height', `${topHeight}px`);
  236. $('.sec-00 .container-fluid').css('height', `${topHeight}px`);
  237. }
  238. function renderinfoCard(designer) {
  239. $('.mb__hero__bgImg').attr('backgroundImage', `url(${designer['BannerImg']})`);
  240. $('.mb__infoCard__avatar').css('backgroundImage', `url(${designer['Designerimg']})`)
  241. $('.mb__infoCard__name').text(designer['DesignerName']);
  242. $('.mb__infoCard__seo').text(designer['Description']);
  243. $('.mb__infoCard__cmy').text(designer['CompanyName']);
  244. if (designer['Approve'] !== '') {
  245. $('.mb__infoCard__approve').html(designer['Approve']);
  246. }
  247. // Basics
  248. let str = '';
  249. for (let i = 0; i < designer['Basics'].length; i++) {
  250. str += `<aside class="d-flex">
  251. <div class="mb__infoCard__detail__l">
  252. <div>${designer['Basics'][i].title}</div>
  253. </div>
  254. <div class="mb__infoCard__detail__r">
  255. <a href="${designer['Basics'][i].link}">${designer['Basics'][i].data}</a>
  256. </div>
  257. </aside>`
  258. }
  259. $('.mb__infoCard__basics').html(str);
  260. // Branches
  261. let otherStr = '';
  262. for (let i = 0; i < designer['Branches'].length; i++) {
  263. otherStr += `<aside class="d-flex">
  264. <div class="mb__infoCard__detail__l">
  265. <div>分公司地址:</div>
  266. </div>
  267. <div class="mb__infoCard__detail__r">
  268. <a href="${designer['Branches'][i].link}" >${designer['Branches'][i].address}</a>
  269. </div>
  270. </aside>
  271. <aside class="d-flex">
  272. <div class="mb__infoCard__detail__l">
  273. <div>分公司電話:</div>
  274. </div>
  275. <div class="mb__infoCard__detail__r">
  276. <a href="tel:${designer['Branches'][i].tel}" >${designer['Branches'][i].tel}</a>
  277. </div>
  278. </aside>`
  279. if (designer['Branches'][i].fax == "") {
  280. otherStr += `<aside class="d-flex">
  281. </aside>
  282. `
  283. } else {
  284. otherStr += `<aside class="d-flex"><div class="mb__infoCard__detail__l">
  285. <div>分公司傳真:</div>
  286. </div>
  287. <div class="mb__infoCard__detail__r">
  288. <a href="fax:${designer['Branches'][i].fax}" >${designer['Branches'][i].fax}</a>
  289. </div> </aside>`
  290. }
  291. }
  292. $('.mb__infoCard__branches').html(otherStr);
  293. let currentURL = window.location.href;
  294. // scMedia
  295. let mediaStr = '';
  296. for (let i = 0; i < designer['scMedia'].length; i++) {
  297. if (i === 4) {
  298. mediaStr += `<span>
  299. <img src="${designer['scMedia'][i].img}" class="dislike" alt="">
  300. <img src="https://hhh.com.tw/assets/images/rv_web/like.svg" class="like" alt="">
  301. </span>`;
  302. }
  303. else if (i === 1) {
  304. mediaStr += `<a target="_blank" href="https://social-plugins.line.me/lineit/share?url=${currentURL}}">
  305. <img src="${designer['scMedia'][i].img}" alt="">
  306. </a>`;
  307. } else if (i === 2) {
  308. mediaStr += `<a target="_blank" href="https://www.addtoany.com/ext/wechat/share/#url=url=${currentURL}}">
  309. <img src="${designer['scMedia'][i].img}" alt="">
  310. </a>`;
  311. }
  312. else if (i === 3) {
  313. mediaStr += `<span class="send" data-bs-toggle="modal" data-bs-target="#emailModal">
  314. <img src="${designer['scMedia'][i].img}" alt="">
  315. </span>`;
  316. } else {
  317. mediaStr += `<a href="${designer['scMedia'][i].link}">
  318. <img src="${designer['scMedia'][i].img}" alt="">
  319. </a>`;
  320. }
  321. }
  322. $('.scMedia').html(mediaStr);
  323. // document.querySelector('.dislike').addEventListener('click', function() {
  324. // $('.dislike').css('display', 'none');
  325. // $('.like').css('display', 'block');
  326. // })
  327. // document.querySelector('.like').addEventListener('click', function() {
  328. // $('.dislike').css('display', 'block');
  329. // $('.like').css('display', 'none');
  330. // })
  331. // term condition
  332. let termStr = '';
  333. for (let i = 0; i < designer['Terms'].length; i++) {
  334. termStr += `<aside class="d-flex">
  335. <div class="mb__infoCard__detail__l">
  336. <div>${designer['Terms'][i].title}</div>
  337. </div>
  338. <div class="mb__infoCard__detail__r">
  339. <div>${designer['Terms'][i].data}</div>
  340. </div>
  341. </aside>`
  342. }
  343. $('.mb__infoCard__terms').html(termStr);
  344. }
  345. function renderTab(content) {
  346. let tabTitleStr = '';
  347. for (let i = 0; i < content.length; i++) {
  348. if (content[i]['Carddata'] == "" & content[i]['info'] == undefined) {
  349. tabTitleStr += ``
  350. } else {
  351. if (i == 0) {
  352. tabTitleStr += `<li class="nav-item p-0 active" role="presentation">
  353. <a class="nav-item-link nav-item-active bg-transparent active" id="pills-${content[i]['Tabtag']}-tab"
  354. data-bs-toggle="pill" data-bs-target="#pills-${content[i]['Tabtag']}" type="button" role="tab"
  355. aria-controls="pills-${content[i]['Tabtag']}" aria-selected="false" data-link="https://hhh.com.tw/videos/lists/">${content[i]['mb_title']}</a>
  356. </li>`
  357. } else if (content[i]['Display_mb']) {
  358. tabTitleStr += `<li class="nav-item p-0" role="presentation">
  359. <a class="nav-item-link nav-item-active bg-transparent" id="pills-${content[i]['Tabtag']}-tab"
  360. data-bs-toggle="pill" data-bs-target="#pills-${content[i]['Tabtag']}" type="button" role="tab"
  361. aria-controls="pills-${content[i]['Tabtag']}" aria-selected="false" data-link="https://hhh.com.tw/videos/lists/">${content[i]['mb_title']}</a>
  362. </li>`
  363. }
  364. }
  365. }
  366. $('#pills-tab').html(tabTitleStr);
  367. $('.pill-aside').html(tabTitleStr);
  368. }
  369. function renderTabContent(content, meta) {
  370. let tabStr = '';
  371. for (let i = 0; i < content.length; i++) {
  372. let cardData = ''
  373. if (content[i].info) {
  374. for (let j = 0; j < content[i].info.length; j++) {
  375. cardData += `<div class="company__block">
  376. <h4 class="company__title">${content[i].info[j].title}</h4>
  377. <div class="company__text">
  378. ${content[i].info[j].data}
  379. </div>
  380. </div>`
  381. }
  382. tabStr += `<div class="tab-pane fade " id="pills-${content[i]['Tabtag']}" role="tabpanel"
  383. aria-labelledby="pills-${content[i]['Tabtag']}-tab">
  384. <div class="row justfy-content-between">
  385. <div class="col-md-8">
  386. <article class="company__article">
  387. ${cardData}
  388. </article>
  389. </div>
  390. </div>
  391. </div>`
  392. } else {
  393. for (let j = 0; j < (content[i].Carddata.length < num_per_page ? content[i].Carddata.length : num_per_page); j++) {
  394. let tagStr = '';
  395. for (let k = 0; k < content[i].Carddata[j].tag.length; k++) {
  396. tagStr += `<a href="${content[i].Carddata[j].tag[k]['link']}" class="card__tag" target="_blank">${content[i].Carddata[j].tag[k]['name']}</a>`
  397. }
  398. // for(let j = 0;j < content[i].Carddata.length; j ++) {
  399. cardData += `<div class="col-6 col-md-4">
  400. <a href="${content[i].Carddata[j]['url']}" target="_blank">
  401. <div class="card">
  402. <div class="card__bgImg" style="background-image: url(${content[i].Carddata[j]['imgURL']});">
  403. </div>
  404. <div class="card-body">
  405. <h5 class="card-title card__title mt-0">${content[i].Carddata[j]['title']}</h5>
  406. <p class="card-text mb-0">
  407. ${tagStr}
  408. </p>
  409. </div>
  410. </div>
  411. </a>
  412. </div>`
  413. }
  414. if (content[i].Display_mb) {
  415. tabStr += `<div class="tab-pane fade " id="pills-${content[i]['Tabtag']}" role="tabpanel"
  416. aria-labelledby="pills-${content[i]['Tabtag']}-tab">
  417. <div class="row work__row">
  418. ${cardData}
  419. </div>
  420. </div>`
  421. let key = content[i]['Tabtag'];
  422. totalPages[key] = content[i].Carddata.length;
  423. }
  424. }
  425. }
  426. console.log(tabStr);
  427. //console.log(totalPages);
  428. $('#pills-tabContent').html(tabStr);
  429. $('#pills-tabContent').append('<div style="padding: 20px;"></div>');
  430. $("#pills-intro").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  431. <div id="loading_img">
  432. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  433. viewBox="0 0 40 41.965">
  434. <defs>
  435. <style>
  436. .a {
  437. fill: #ee751b;
  438. }
  439. </style>
  440. </defs>
  441. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  442. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  443. transform="translate(18.05 36.099)" />
  444. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  445. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  446. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  447. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  448. <path class="a" d="M5.065,20.213a3.422,3.422,0,1,0,4.839,0A3.419,3.419,0,0,0,5.065,20.213Z"
  449. transform="translate(1.403 11.424)" />
  450. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  451. transform="translate(31.603 8.434)" />
  452. </svg>
  453. </div>
  454. </div>`)
  455. $("#pills-video").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  456. <div id="loading_img">
  457. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  458. viewBox="0 0 40 41.965">
  459. <defs>
  460. <style>
  461. .a {
  462. fill: #ee751b;
  463. }
  464. </style>
  465. </defs>
  466. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  467. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  468. transform="translate(18.05 36.099)" />
  469. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  470. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  471. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  472. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  473. <path class="a" d="M5.065,20.213a3.422,3.422,0,1,0,4.839,0A3.419,3.419,0,0,0,5.065,20.213Z"
  474. transform="translate(1.403 11.424)" />
  475. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  476. transform="translate(31.603 8.434)" />
  477. </svg>
  478. </div>
  479. </div>`)
  480. $("#pills-columns").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  481. <div id="loading_img">
  482. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  483. viewBox="0 0 40 41.965">
  484. <defs>
  485. <style>
  486. .a {
  487. fill: #ee751b;
  488. }
  489. </style>
  490. </defs>
  491. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  492. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  493. transform="translate(18.05 36.099)" />
  494. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  495. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  496. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  497. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  498. <path class="a" d="M5.065,20.213a3.422,3.422,0,1,0,4.839,0A3.419,3.419,0,0,0,5.065,20.213Z"
  499. transform="translate(1.403 11.424)" />
  500. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  501. transform="translate(31.603 8.434)" />
  502. </svg>
  503. </div>
  504. </div>`)
  505. $('#pills-intro').addClass('active');
  506. $('#pills-intro').addClass('show');
  507. $('#pills-video .card__bgImg').append('<img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">')
  508. $('.infoContent .nav-item-link').click(checkTab);
  509. checkTab();
  510. $(`<div id="fb-container" style="width: 320px;" class="mx-auto">
  511. <div class="fb-page" data-href="${meta['FB_link']}" data-tabs="timeline" data-width="320" data-height="700" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true">
  512. <blockquote cite="${meta['FB_link']}" class="fb-xfbml-parse-ignore">
  513. <a href="${meta['FB_link']}">${meta['CompanyName']}</a>
  514. </blockquote>
  515. </div>
  516. </div>
  517. <script async defer crossorigin="anonymous" src="https://connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v9.0" nonce="7TsDzQN7"></script>
  518. `).insertAfter($('.company__article > .company__block:nth-of-type(1)'));
  519. }
  520. window.addEventListener('scroll', fixedOnScroll);
  521. const navBlock = document.querySelector('.infoContent__navBlock');
  522. function fixedOnScroll() {
  523. if (window.innerHeight < window.innerWidth) {
  524. } else {
  525. detectDirection();
  526. }
  527. if (window.pageYOffset >= over) {
  528. navBlock.classList.add('tab_sticky');
  529. } else if (window.pageYOffset < over) {
  530. navBlock.classList.remove('tab_sticky');
  531. }
  532. }
  533. $('.navbar-toggler').click(function () {
  534. $(".sec-menu").css('display', 'block');
  535. $(".wholeBody").css('overflow-y', 'hidden');
  536. $('.sec-menu-block').addClass('slidein');
  537. $('.sec-menu-block').removeClass('slideout');
  538. });
  539. $('.navbar-back').click(function () {
  540. $(".sec-menu").css('display', 'none');
  541. $(".wholeBody").css('overflow-y', 'scroll');
  542. $('.sec-menu-block').removeClass('slidein');
  543. $('.sec-menu-block').addClass('slideout');
  544. });
  545. $('.subexpand').click(function () {
  546. $(this).parent().next().toggleClass('show');
  547. $(this).parent().toggleClass('show');
  548. });
  549. $('.navbar-search').click(function () {
  550. $(".sec-search").css('display', 'block');
  551. $(".wholeBody").css('overflow-y', 'hidden');
  552. })
  553. $('.navbar-backs').click(function () {
  554. $(".sec-search").css('display', 'none');
  555. $(".wholeBody").css('overflow-y', 'scroll');
  556. });
  557. $('.navbar-back-fav').click(function () {
  558. $(".sec-favor").css('display', 'none');
  559. })
  560. $('.btn-gotop').click(function () {
  561. $('html, body').animate({
  562. scrollTop: 0
  563. }, 500)
  564. });
  565. $(window).scroll(function () {
  566. if ($(this).scrollTop() > 500) {
  567. $('.fixed-btn').fadeIn(222);
  568. $('.freeCall').fadeIn(222);
  569. } else {
  570. $('.fixed-btn').stop().fadeOut(222);
  571. $('.freeCall').stop().fadeOut(222);
  572. }
  573. }).scroll();
  574. const searchBtn = document.querySelector('.searchBtn');
  575. const searchBar = document.querySelector('.searchBar');
  576. const searchHotLink = document.querySelectorAll('.sec-search-hots__link');
  577. searchBtn.addEventListener('click', search);
  578. searchBar.addEventListener('keyup', pressSearch);
  579. function search() {
  580. if (searchBar.value == '') {
  581. window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
  582. } else {
  583. window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
  584. }
  585. }
  586. function pressSearch(e) {
  587. if (e.keyCode === 13) {
  588. e.preventDefault();
  589. search();
  590. }
  591. }
  592. searchHotLink.forEach((item, i) => {
  593. item.addEventListener('click', function () {
  594. window.location.href = `https://m.hhh.com.tw/search/lists/case/${this.textContent}-keyword/`;
  595. })
  596. })
  597. document.addEventListener('lazybeforeunveil', function (e) {
  598. var bg = e.target.getAttribute('data-bg');
  599. if (bg) {
  600. e.target.style.backgroundImage = 'url(' + bg + ')';
  601. }
  602. });
  603. $('.mb__infoCard__more').click(function () {
  604. $(this).hide();
  605. $('.other').css('display', 'block');
  606. over = document.querySelector('.infoContent__navBlock').offsetTop;
  607. })
  608. checkTab()
  609. $('.infoContent .nav-item-link').click(checkTab);
  610. function checkTab() {
  611. if ($('#pills-intro-tab').hasClass('active')) {
  612. $('.likeSee').attr('hidden', false)
  613. } else {
  614. $('.likeSee').attr('hidden', true)
  615. }
  616. }
  617. function renderModalTitle(title) {
  618. $('#emailModal #title').val(title);
  619. }
  620. function loadMore(designer) {
  621. let nowTab = document.querySelector('.infoContent .tab-pane.show');
  622. if (nowTab === document.querySelector('#pills-intro')) {
  623. let last = document.querySelector('#pills-intro .work__row>div:last-child');
  624. let pageNum = Math.ceil(totalPages.intro / 10) - 1;
  625. if ($(window).scrollTop() + $(window).height() >= ($(document).height() - 100)) {
  626. console.log('over');
  627. if (n >= pageNum) {
  628. n = pageNum;
  629. return;
  630. } else {
  631. n++;
  632. let append = '';
  633. let d = designer['Content'][0].Carddata.slice(10 * n, (10 * n) + 10);
  634. for (let j = 0; j < d.length; j++) {
  635. append += `<div class="col-6 col-md-4">
  636. <a href="" target="_blank">
  637. <div class="card">
  638. <div style="overflow: hidden;">
  639. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  640. </div>
  641. </div>
  642. <div class="card-body">
  643. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  644. <p class="card-text mb-0">
  645. <a href="" class="card__tag" target="_blank">混搭風</a>
  646. <a href="" class="card__tag" target="_blank">混搭風</a>
  647. <a href="" class="card__tag" target="_blank">混搭風</a>
  648. </p>
  649. </div>
  650. </div>
  651. </a>
  652. </div>`
  653. }
  654. $('#pills-intro .work__row').append(append);
  655. }
  656. }
  657. } else if (nowTab === document.querySelector('#pills-video')) {
  658. let pageNum = Math.ceil(totalPages.video / 10) - 1;
  659. console.log(totalPages.video);
  660. let last = document.querySelector('#pills-video .work__row>div:last-child');
  661. if ($(window).scrollTop() + $(window).height() >= ($(document).height() - 100)) {
  662. if (n_video >= pageNum) {
  663. n_video = pageNum;
  664. console.log('n-video:', n_video);
  665. console.log('pageNum', pageNum);
  666. return;
  667. } else {
  668. console.log('pass-video');
  669. n_video++;
  670. console.log('test');
  671. let append = '';
  672. let d = designer['Content'][1].Carddata.slice(10 * n_video, (10 * n_video) + 10);
  673. for (let j = 0; j < d.length; j++) {
  674. append += `<div class="col-6 col-md-4">
  675. <a href="" target="_blank">
  676. <div class="card">
  677. <div style="overflow: hidden;">
  678. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  679. <img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">
  680. </div>
  681. </div>
  682. <div class="card-body">
  683. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  684. <p class="card-text mb-0">
  685. <a href="" class="card__tag" target="_blank">混搭風</a>
  686. <a href="" class="card__tag" target="_blank">混搭風</a>
  687. <a href="" class="card__tag" target="_blank">混搭風</a>
  688. </p>
  689. </div>
  690. </div>
  691. </a>
  692. </div>`
  693. }
  694. $('#pills-video .work__row').append(append);
  695. }
  696. }
  697. } else if (nowTab === document.querySelector('#pills-columns')) {
  698. let last = document.querySelector('#pills-columns .work__row>div:last-child');
  699. let pageNum = Math.ceil(totalPages.columns / 10) - 1;
  700. if ($(window).scrollTop() + $(window).height() >= ($(document).height() - 100)) {
  701. if (n_columns >= pageNum) {
  702. n_columns = pageNum;
  703. return;
  704. } else {
  705. n_columns++;
  706. console.log('test');
  707. let append = '';
  708. let d = designer['Content'][2].Carddata.slice(10 * n_columns, (10 * n_columns) + 10);
  709. for (let j = 0; j < d.length; j++) {
  710. append += `<div class="col-6 col-md-4">
  711. <a href="" target="_blank">
  712. <div class="card">
  713. <div style="overflow: hidden;">
  714. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  715. </div>
  716. </div>
  717. <div class="card-body">
  718. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  719. <p class="card-text mb-0">
  720. <a href="" class="card__tag" target="_blank">混搭風</a>
  721. <a href="" class="card__tag" target="_blank">混搭風</a>
  722. <a href="" class="card__tag" target="_blank">混搭風</a>
  723. </p>
  724. </div>
  725. </div>
  726. </a>
  727. </div>`
  728. }
  729. $('#pills-columns .work__row').append(append);
  730. }
  731. }
  732. }
  733. }
  734. function putEmail() {
  735. const emailPattern = /^(([^<>()[\]\\.,;:\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,}))$/;
  736. if ($('#email').val() !== null && emailPattern.test($('#email').val())) {
  737. $('#error').hide();
  738. $('#putEmail_hidden').css('display', 'block');
  739. $('#add_email').text($('#email').val());
  740. $('#email').val('');
  741. } else {
  742. $('#error').show();
  743. $('#error').text('email 格式有誤');
  744. }
  745. }
  746. // $(function(){
  747. // var len = 10;
  748. // $(".JQellipsis").each(function(i){
  749. // if($(this).text().length>len){
  750. // $(this).attr("title",$(this).text());
  751. // var text=$(this).text().substring(0,len-1)+"...";
  752. // $(this).text(text);
  753. // }
  754. // });
  755. // });