index-designer.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. let userAgent;
  2. let isSafari = false;
  3. let browserName;
  4. let filter;
  5. const urlParams = new URLSearchParams(window.location.search);
  6. let getfilter = urlParams.get('q');
  7. let cid = urlParams.get('cid');
  8. console.log(getfilter, cid);
  9. $('.likeSee__views').click(function () {
  10. window.location.href = `./index_designerList.html?q=views&cid=${cid}`
  11. $(this).css('color', '#EE7800');
  12. })
  13. $('.likeSee__sort').click(function () {
  14. window.location.href = `./index_designerList.html?cid=${cid}`
  15. $(this).css('color', '#EE7800');
  16. })
  17. function getQuery() {
  18. let query = getfilter;
  19. if (query == 'views') {
  20. filter = 'views';
  21. $('.likeSee__views').css('color', '#EE7800');
  22. } else {
  23. filter = 'dateSort';
  24. $('.likeSee__sort').css('color', '#EE7800');
  25. }
  26. }
  27. getQuery();
  28. // pagination variables
  29. let num_per_page = 100;
  30. let n = 0;
  31. let n_video = 0;
  32. let n_columns = 0;
  33. let totalPages = {
  34. intro: 0,
  35. video: 0,
  36. columns: 0,
  37. vr360: 0,
  38. company: 0,
  39. };
  40. window.onload = function () {
  41. if (screen.width < 600) {
  42. window.location.href = `./index_designerList_mb.html?cid=${cid}`;
  43. }
  44. userAgent = navigator.userAgent;
  45. detectBrowser(userAgent);
  46. detectDirection();
  47. let result;
  48. let designer;
  49. let id = 0;
  50. $.ajax({
  51. method: "GET",
  52. url: "./json/realtime.json",
  53. dataType: "json",
  54. }).done(function (msg) {
  55. result = [...msg];
  56. renderSec00(result);
  57. });
  58. $.ajax({
  59. method: "GET",
  60. // url: `./json/designers-${cid}.json`,
  61. url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=1`,
  62. dataType: "json",
  63. }).done(function (msg) {
  64. designer = [...msg][0];
  65. console.log(designer)
  66. if (filter == 'views') {
  67. designer['Content'][0]['Carddata'].sort(function (a, b) {
  68. return a[filter] > b[filter] ? -1 : 1;
  69. })
  70. } else {
  71. designer['Content'][0]['Carddata'].sort(function (a, b) {
  72. return a[filter] > b[filter] ? 1 : -1;
  73. })
  74. }
  75. console.log(designer['Content'][0]['Carddata']);
  76. renderinfoCard(designer);
  77. renderTab(designer['Content']);
  78. renderTabContent(designer['Content'], designer);
  79. renderModalTitle(designer['CompanyName']);
  80. // $(window).scroll(function () {
  81. // loadMore();
  82. // })
  83. $(window).scroll(function () {
  84. var scrollTop = $(this).scrollTop();
  85. var scrollHeight = $('body').prop("scrollHeight");
  86. var clientHeight = document.documentElement.clientHeight;
  87. let last = document.querySelector('#pills-intro .work__row>div:last-child');
  88. // if (scrollTop + clientHeight >= scrollHeight - 5) {
  89. let bottom = $("body").height() - $(window).height() - 1;
  90. if ($(window).scrollTop() >= bottom) {
  91. loadMoretest();
  92. }
  93. })
  94. });
  95. }
  96. function scroll_bottom_load_data(page) {
  97. $.ajax({
  98. method: "GET",
  99. url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=${page}`,
  100. }).done(function (msg) {
  101. result = [...msg];
  102. let append = '';
  103. let d = result[0].Content[0].Carddata;
  104. // let cardcontent=[]
  105. let nowTab = document.querySelector('.infoContent .tab-pane.show');
  106. if (nowTab === document.querySelector('#pills-intro')) {
  107. for (let j = 0; j < d.length; j++) {
  108. let tagStr = ''
  109. for (let k = 0; k < d[j]['tag'].length; k++) {
  110. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  111. }
  112. append += `<div class="col-lg-6 col-xl-4">
  113. <a href="${d[j]['url']}" target="_blank">
  114. <div class="card">
  115. <div style="overflow: hidden;">
  116. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  117. </div>
  118. </div>
  119. <div class="card-body">
  120. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  121. <p class="card-text mb-0">
  122. ${tagStr}
  123. </p>
  124. </div>
  125. </div>
  126. </a>
  127. </div>`
  128. // var cardcontent2=cardcontent.push.d;
  129. }
  130. if (d.length === 0) {
  131. $('#loading_img').css("display", "none")
  132. }
  133. // console.log(cardcontent2);
  134. $('#pills-intro .work__row').append(append);
  135. }else if (nowTab === document.querySelector('#pills-video')) {
  136. let append = '';
  137. let d = result[0].Content[0].Carddata;
  138. for(let j = 0;j < d.length; j ++) {
  139. let tagStr = ''
  140. for(let k = 0;k < d[j]['tag'].length; k ++) {
  141. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  142. }
  143. append += `<div class="col-lg-6 col-xl-4">
  144. <a href="${d[j]['url']}" target="_blank">
  145. <div class="card">
  146. <div style="overflow: hidden;">
  147. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  148. <img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">
  149. </div>
  150. </div>
  151. <div class="card-body">
  152. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  153. <p class="card-text mb-0">
  154. ${tagStr}
  155. </p>
  156. </div>
  157. </div>
  158. </a>
  159. </div>`
  160. }
  161. if (d.length === 0) {
  162. $('#loading_img').css("display", "none")
  163. }
  164. $('#pills-video .work__row').append(append);
  165. }else if (nowTab === document.querySelector('#pills-columns')) {
  166. let append = '';
  167. let d = result[0].Content[0].Carddata;
  168. for(let j = 0;j < d.length; j ++) {
  169. let tagStr = ''
  170. for(let k = 0;k < d[j]['tag'].length; k ++) {
  171. tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  172. }
  173. append += `<div class="col-lg-6 col-xl-4">
  174. <a href="${d[j]['url']}" target="_blank">
  175. <div class="card">
  176. <div style="overflow: hidden;">
  177. <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  178. </div>
  179. </div>
  180. <div class="card-body">
  181. <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  182. <p class="card-text mb-0">
  183. ${tagStr}
  184. </p>
  185. </div>
  186. </div>
  187. </a>
  188. </div>`
  189. }
  190. $('#pills-columns .work__row').append(append);
  191. }
  192. });
  193. }
  194. var page = 1;
  195. function loadMoretest() {
  196. setTimeout(function () {
  197. // let pageNum = 2;
  198. // if(page<=pageNum){
  199. // pageNum++;
  200. // page++;
  201. // }else{
  202. // }
  203. scroll_bottom_load_data(page);
  204. page++;
  205. return page
  206. }, 500);
  207. }
  208. function loadMore(page) {
  209. var scrollTop = $(this).scrollTop();
  210. var scrollHeight = $('body').prop("scrollHeight");
  211. var clientHeight = document.documentElement.clientHeight;
  212. let nowTab = document.querySelector('.infoContent .tab-pane.show');
  213. if (nowTab === document.querySelector('#pills-intro')) {
  214. let last = document.querySelector('#pills-intro .work__row>div:last-child');
  215. // let pageNum = Math.ceil(totalPages.intro / 12) - 1;
  216. // if (scrollTop + clientHeight >= scrollHeight - 5) {
  217. if ($(this).scrollTop() > last.offsetTop) {
  218. // n=1;
  219. // n ++;
  220. // console.log(n);
  221. // $.ajax({
  222. // method: "GET",
  223. // url: `https://m3.hhh.com.tw:18686/gendesigner?id=${cid}&sort=new&page=${b}`,
  224. // }).done(function (msg) {
  225. // result = [...msg];
  226. // // console.log(result);
  227. // let append = '';
  228. // let d = result[0].Content[0].Carddata;
  229. // for (let j = 0; j < d.length; j++) {
  230. // console.log(d);
  231. // let tagStr = ''
  232. // for (let k = 0; k < d[j]['tag'].length; k++) {
  233. // tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  234. // }
  235. // append += `<div class="col-lg-6 col-xl-4">
  236. // <a href="" target="_blank">
  237. // <div class="card">
  238. // <div style="overflow: hidden;">
  239. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  240. // </div>
  241. // </div>
  242. // <div class="card-body">
  243. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  244. // <p class="card-text mb-0">
  245. // ${tagStr}
  246. // </p>
  247. // </div>
  248. // </div>
  249. // </a>
  250. // </div>`
  251. // }
  252. // $('#pills-intro .work__row').append(append);
  253. // });
  254. }
  255. }
  256. // else if (nowTab === document.querySelector('#pills-video')) {
  257. // let pageNum = Math.ceil(totalPages.video / 9) - 1;
  258. // console.log(totalPages.video);
  259. // let last = document.querySelector('#pills-video .work__row>div:last-child');
  260. // if ($(this).scrollTop() > last.offsetTop) {
  261. // if (n_video >= pageNum) {
  262. // n_video = pageNum;
  263. // console.log('n-video:', n_video);
  264. // console.log('pageNum', pageNum);
  265. // return;
  266. // } else {
  267. // console.log('pass-video');
  268. // n_video++;
  269. // console.log('test');
  270. // let append = '';
  271. // let d = designer['Content'][1].Carddata.slice(9 * n_video, (9 * n_video) + 9);
  272. // for (let j = 0; j < d.length; j++) {
  273. // let tagStr = ''
  274. // for (let k = 0; k < d[j]['tags'].length; k++) {
  275. // tagStr += `<a href="${d[j]['tags'][k]['link']}" class="card__tag" target="_blank">${d[j]['tags'][k]['name']}</a>`
  276. // }
  277. // append += `<div class="col-12 col-lg-6 col-xl-4">
  278. // <a href="" target="_blank">
  279. // <div class="card">
  280. // <div style="overflow: hidden;">
  281. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  282. // <img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">
  283. // </div>
  284. // </div>
  285. // <div class="card-body">
  286. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  287. // <p class="card-text mb-0">
  288. // ${tagStr}
  289. // </p>
  290. // </div>
  291. // </div>
  292. // </a>
  293. // </div>`
  294. // }
  295. // $('#pills-video .work__row').append(append);
  296. // }
  297. // }
  298. // } else if (nowTab === document.querySelector('#pills-columns')) {
  299. // let last = document.querySelector('#pills-columns .work__row>div:last-child');
  300. // let pageNum = Math.ceil(totalPages.columns / 9) - 1;
  301. // if ($(this).scrollTop() > last) {
  302. // if (n_columns >= pageNum) {
  303. // n_columns = pageNum;
  304. // return;
  305. // } else {
  306. // n_columns++;
  307. // console.log('test');
  308. // let append = '';
  309. // let d = designer['Content'][2].Carddata.slice(9 * n_columns, (9 * n_columns) + 9);
  310. // for (let j = 0; j < d.length; j++) {
  311. // let tagStr = ''
  312. // for (let k = 0; k < d[j]['tags'].length; k++) {
  313. // tagStr += `<a href="${d[j]['tags'][k]['link']}" class="card__tag" target="_blank">${d[j]['tags'][k]['name']}</a>`
  314. // }
  315. // append += `<div class="col-lg-6 col-xl-4">
  316. // <a href="" target="_blank">
  317. // <div class="card">
  318. // <div style="overflow: hidden;">
  319. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  320. // </div>
  321. // </div>
  322. // <div class="card-body">
  323. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  324. // <p class="card-text mb-0">
  325. // ${tagStr}
  326. // </p>
  327. // </div>
  328. // </div>
  329. // </a>
  330. // </div>`
  331. // }
  332. // $('#pills-columns .work__row').append(append);
  333. // }
  334. // }
  335. // }
  336. }
  337. function detectDirection() {
  338. let height = (window.screen.width * 5) / 12;
  339. console.log(height);
  340. $('.sec-02 .slide-item').css('height', `${height}px`);
  341. }
  342. function detectBrowser(agent) {
  343. if (userAgent.match(/chrome|chromium|crios/i)) {
  344. browserName = "chrome";
  345. } else if (userAgent.match(/firefox|fxios/i)) {
  346. browserName = "firefox";
  347. } else if (userAgent.match(/safari/i)) {
  348. browserName = "safari";
  349. } else if (userAgent.match(/opr\//i)) {
  350. browserName = "opera";
  351. } else if (userAgent.match(/edg/i)) {
  352. browserName = "edge";
  353. } else {
  354. browserName = "No browser detection";
  355. }
  356. if (browserName === 'safari') {
  357. isSafari = true;
  358. }
  359. console.log(isSafari);
  360. }
  361. function renderSec00(data) {
  362. let temp = data[0]['data'];
  363. renderBullet(temp);
  364. renderBannerStr('sec-00__slider', temp);
  365. $(".sec-00__slider").slick({
  366. dots: false,
  367. speed: 500,
  368. autoplay: true,
  369. autoplaySpeed: 4000,
  370. arrows: true,
  371. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  372. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
  373. });
  374. $('.sec-00__bullet').removeClass('bullet-active');
  375. $('.sec-00__bullet').eq($('.slick-active').data('slick-index')).addClass('bullet-active');
  376. // $('.sec-00__slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  377. // console.log(currentSlide);
  378. // console.log($('.slick-active').data('slick-index'));
  379. // });
  380. $('.sec-00__slider').on('afterChange', function (event, slick, currentSlide) {
  381. // console.log(currentSlide);
  382. // console.log($('.slick-active').data('slick-index'));
  383. $('.sec-00__bullet').removeClass('bullet-active');
  384. $('.sec-00__bullet').eq(currentSlide).addClass('bullet-active');
  385. });
  386. }
  387. function renderBullet(data) {
  388. let str = '';
  389. for (let i = 0; i < data.length; i++) {
  390. str += '<div class="sec-00__bullet"></div>'
  391. }
  392. console.log('bullet');
  393. $('.sec-00__bulletList').html(str);
  394. }
  395. // function renderBannerStr(sec, data) {
  396. // let str = '';
  397. // for(let i = 0; i < data.length; i++){
  398. // if(data[i]['Dwebp'] && !isSafari) {
  399. // str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['Dwebp']}');" data-bg="${data[i]['Dwebp']}"></div>`
  400. // } else {
  401. // str+= `<div class="${sec}-${i+1} slide-item" onclick="window.open('${data[i]['link']}');" style="background-image: url('${data[i]['DimgUrl']}');" data-bg="${data[i]['DimgUrl']}"></div>`
  402. // }
  403. // }
  404. // $(`.${sec}`).html(str);
  405. // }
  406. function renderBannerStr(sec, data) {
  407. let str = '';
  408. for (let i = 0; i < data.length; i++) {
  409. if (data[i]['Dwebp'] && !isSafari) {
  410. str += `<img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]['Dwebp']}" onclick="window.open('${data[i]['link']}');" data-bg="${data[i]['Dwebp']}">`
  411. } else {
  412. str += `<img class="${sec}-${i + 1} slide-item img-fluid" src="${data[i]['DimgUrl']}" onclick="window.open('${data[i]['link']}');" data-bg="${data[i]['DimgUrl']}">`
  413. }
  414. }
  415. $(`.${sec}`).html(str);
  416. }
  417. function renderinfoCard(designer) {
  418. $('.hero__img').attr('src', designer['BannerImg']);
  419. $('.infoCard__avatar').css('backgroundImage', `url(${designer['Designerimg']})`)
  420. $('.infoCard__name').text(designer['DesignerName']);
  421. $('.infoCard__seo').text(designer['Description']);
  422. $('.infoCard__company').text(designer['CompanyName']);
  423. if (designer['Approve'] !== '') {
  424. $('.infoCard__approve').html(designer['Approve']);
  425. }
  426. // Basics
  427. let str = '';
  428. for (let i = 0; i < designer['Basics'].length; i++) {
  429. str += `<aside class="d-flex">
  430. <div class="infoCard__detail__l">
  431. <div>${designer['Basics'][i].title}</div>
  432. </div>
  433. <div class="infoCard__detail__r">
  434. <a href="${designer['Basics'][i].link}">${designer['Basics'][i].data}</a>
  435. </div>
  436. </aside>`
  437. }
  438. $('.infoCard__basics').html(str);
  439. // Branches
  440. let otherStr = '';
  441. for (let i = 0; i < designer['Branches'].length; i++) {
  442. otherStr += `<aside class="d-flex">
  443. <div class="infoCard__detail__l">
  444. <div>分公司地址:</div>
  445. </div>
  446. <div class="infoCard__detail__r">
  447. <a href="${designer['Branches'][i].link}" >${designer['Branches'][i].address}</a>
  448. </div>
  449. </aside>
  450. <aside class="d-flex">
  451. <div class="infoCard__detail__l">
  452. <div>分公司電話:</div>
  453. </div>
  454. <div class="infoCard__detail__r">
  455. <a href="tel:${designer['Branches'][i].tel}" >${designer['Branches'][i].tel}</a>
  456. </div>
  457. </aside>`
  458. if(designer['Branches'][i].fax==""){
  459. otherStr += `<aside class="d-flex">
  460. </aside>
  461. `
  462. }else{
  463. otherStr += `<aside class="d-flex"><div class="infoCard__detail__l">
  464. <div>分公司傳真:</div>
  465. </div>
  466. <div class="infoCard__detail__r">
  467. <a href="fax:${designer['Branches'][i].fax}" >${designer['Branches'][i].fax}</a>
  468. </div> </aside>`
  469. }
  470. }
  471. $('.infoCard__branches').html(otherStr);
  472. let currentURL = window.location.href;
  473. // scMedia
  474. let mediaStr = '';
  475. for (let i = 0; i < designer['scMedia'].length; i++) {
  476. if (i === 4) {
  477. mediaStr += `<span>
  478. <img src="${designer['scMedia'][i].img}" class="dislike" alt="">
  479. <img src="https://hhh.com.tw/assets/images/rv_web/like.svg" class="like" alt="">
  480. </span>`;
  481. } else if (i === 1) {
  482. mediaStr += `<a target="_blank" href="https://social-plugins.line.me/lineit/share?url=${currentURL}}">
  483. <img src="${designer['scMedia'][i].img}" alt="">
  484. </a>`;
  485. } else if (i === 2) {
  486. mediaStr += `<a target="_blank" href="https://www.addtoany.com/ext/wechat/share/#url=url=${currentURL}}">
  487. <img src="${designer['scMedia'][i].img}" alt="">
  488. </a>`;
  489. } else if (i === 3) {
  490. mediaStr += `<span class="send" data-bs-toggle="modal" data-bs-target="#emailModal">
  491. <img src="${designer['scMedia'][i].img}" alt="">
  492. </span>`;
  493. }
  494. else {
  495. mediaStr += `<a target="_blank" href="${designer['scMedia'][i].link}">
  496. <img src="${designer['scMedia'][i].img}" alt="">
  497. </a>`;
  498. }
  499. }
  500. $('.scMedia').html(mediaStr);
  501. document.querySelector('.dislike').addEventListener('click', function () {
  502. $('.dislike').css('display', 'none');
  503. $('.like').css('display', 'block');
  504. })
  505. document.querySelector('.like').addEventListener('click', function () {
  506. $('.dislike').css('display', 'block');
  507. $('.like').css('display', 'none');
  508. })
  509. // term condition
  510. let termStr = '';
  511. for (let i = 0; i < designer['Terms'].length; i++) {
  512. termStr += `<aside class="d-flex">
  513. <div class="infoCard__detail__l">
  514. <div>${designer['Terms'][i].title}</div>
  515. </div>
  516. <div class="infoCard__detail__r">
  517. <div>${designer['Terms'][i].data}</div>
  518. </div>
  519. </aside>`
  520. }
  521. $('.infoCard__terms').html(termStr);
  522. }
  523. function renderTab(content) {
  524. let tabTitleStr = '';
  525. for (let i = 0; i < content.length; i++) {
  526. if (content[i]['Carddata'] == "" & content[i]['info'] == undefined) {
  527. tabTitleStr += ``
  528. } else {
  529. if (i == 0) {
  530. tabTitleStr += `<li class="nav-item p-0 " role="presentation">
  531. <a class="nav-item-link nav-item-active bg-transparent active" id="pills-${content[i]['Tabtag']}-tab"
  532. data-bs-toggle="pill" data-bs-target="#pills-${content[i]['Tabtag']}" type="button" role="tab"
  533. aria-controls="pills-${content[i]['Tabtag']}" aria-selected="false" data-link="https://hhh.com.tw/videos/lists/">${content[i]['Title']}</a>
  534. </li>`
  535. } else if (content[i]['isActive']) {
  536. tabTitleStr += `<li class="nav-item p-0" role="presentation">
  537. <a class="nav-item-link nav-item-active bg-transparent" id="pills-${content[i]['Tabtag']}-tab"
  538. data-bs-toggle="pill" data-bs-target="#pills-${content[i]['Tabtag']}" type="button" role="tab"
  539. aria-controls="pills-${content[i]['Tabtag']}" aria-selected="false" data-link="https://hhh.com.tw/videos/lists/">${content[i]['Title']}</a>
  540. </li>`
  541. }
  542. }
  543. }
  544. $('#pills-tab').html(tabTitleStr);
  545. $('.pill-aside').html(tabTitleStr);
  546. }
  547. function renderCard(content, i = 0) {
  548. let cardData = '';
  549. let data = content[i];
  550. for (let j = 0; j < data.length; j++) {
  551. let tagStr = '';
  552. for (let k = 0; k < data[i]['tags'].length; k++) {
  553. tagStr += `<a href="${data[i]['tags'][k]['link']}" class="card__tag" target="_blank">${data[i]['tags'][k]['name']}</a>`
  554. }
  555. cardData += `<div class="col-md-4">
  556. <a href="" target="_blank">
  557. <div class="card">
  558. <div class="card__bgImg" style="background-image: url(${data[i]['imgURL']});"></div>
  559. <div class="card-body">
  560. <h5 class="card-title card__title mt-0">${data[i]['title']}</h5>
  561. <p class="card-text mb-0">
  562. ${tagStr}
  563. </p>
  564. </div>
  565. </div>
  566. </a>
  567. </div>`
  568. $('#pills-intro .work__row').append(cardData);
  569. }
  570. }
  571. function renderTabContent(content, meta) {
  572. let tabStr = '';
  573. for (let i = 0; i < content.length; i++) {
  574. let cardData = ''
  575. if (content[i].info) {
  576. for (let j = 0; j < content[i].info.length; j++) {
  577. cardData += `<div class="company__block">
  578. <h4 class="company__title">${content[i].info[j].title}</h4>
  579. <div class="company__text">
  580. ${content[i].info[j].data}
  581. </div>
  582. </div>`
  583. }
  584. tabStr += `<div class="tab-pane fade " id="pills-${content[i]['Tabtag']}" role="tabpanel"
  585. aria-labelledby="pills-${content[i]['Tabtag']}-tab">
  586. <div class="row justfy-content-between">
  587. <div class="col-md-8">
  588. <article class="company__article">
  589. ${cardData}
  590. </article>
  591. </div>
  592. <div class="col-md-4 fb__block">
  593. <div id="fb-container">
  594. <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">
  595. <blockquote cite="${meta['FB_link']}" class="fb-xfbml-parse-ignore">
  596. <a href="${meta['FB_link']}">${meta['CompanyName']}</a>
  597. </blockquote>
  598. </div>
  599. </div>
  600. </div>
  601. </div>
  602. <script async defer crossorigin="anonymous" src="https://connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v9.0" nonce="7TsDzQN7"></script>
  603. `
  604. // $('#loading_img').css("display", "none")
  605. }
  606. else {
  607. // for (let j = 0; j < (content[i].Carddata.length < num_per_page ? content[i].Carddata.length : num_per_page); j++) {
  608. for (let j = 0; j < content[i].Carddata.length; j++) {
  609. let tagStr = '';
  610. for (let k = 0; k < content[i].Carddata[j].tag.length; k++) {
  611. tagStr += `<a href="${content[i].Carddata[j].tag[k]['link']}" class="card__tag" target="_blank">${content[i].Carddata[j].tag[k]['name']}</a>`
  612. }
  613. cardData += `<div class="col-12 col-lg-6 col-xl-4">
  614. <a href="${content[i].Carddata[j]['url']}" target="_blank">
  615. <div class="card">
  616. <div style="overflow: hidden;">
  617. <div class="card__bgImg" style="background-image: url(${content[i].Carddata[j]['imgURL']});">
  618. </div>
  619. </div>
  620. <div class="card-body">
  621. <h5 class="card-title card__title mt-0">${content[i].Carddata[j]['title']}</h5>
  622. <p class="card-text mb-0">
  623. ${tagStr}
  624. </p>
  625. </div>
  626. </div>
  627. </a>
  628. </div>`
  629. }
  630. tabStr += `<div class="tab-pane fade " id="pills-${content[i]['Tabtag']}" role="tabpanel"
  631. aria-labelledby="pills-${content[i]['Tabtag']}-tab">
  632. <div class="row work__row">
  633. ${cardData}
  634. </div>
  635. </div>`
  636. let key = content[i]['Tabtag'];
  637. totalPages[key] = content[i].Carddata.length;
  638. }
  639. }
  640. // console.log(tabStr);
  641. // console.log(totalPages);
  642. $('#pills-tabContent').html(tabStr);
  643. // $('#pills-tabContent').append('<div style="padding: 40px;"></div>');
  644. $("#pills-intro").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  645. <div id="loading_img">
  646. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  647. viewBox="0 0 40 41.965">
  648. <defs>
  649. <style>
  650. .a {
  651. fill: #ee751b;
  652. }
  653. </style>
  654. </defs>
  655. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  656. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  657. transform="translate(18.05 36.099)" />
  658. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  659. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  660. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  661. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  662. <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"
  663. transform="translate(1.403 11.424)" />
  664. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  665. transform="translate(31.603 8.434)" />
  666. </svg>
  667. </div>
  668. </div>`)
  669. $("#pills-video").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  670. <div id="loading_img">
  671. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  672. viewBox="0 0 40 41.965">
  673. <defs>
  674. <style>
  675. .a {
  676. fill: #ee751b;
  677. }
  678. </style>
  679. </defs>
  680. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  681. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  682. transform="translate(18.05 36.099)" />
  683. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  684. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  685. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  686. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  687. <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"
  688. transform="translate(1.403 11.424)" />
  689. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  690. transform="translate(31.603 8.434)" />
  691. </svg>
  692. </div>
  693. </div>`)
  694. $("#pills-columns").append(` <div class="d-flex justify-content-center py-1 py-md-5">
  695. <div id="loading_img">
  696. <svg class="loading-move" xmlns="http://www.w3.org/2000/svg" width="40" height="41.965"
  697. viewBox="0 0 40 41.965">
  698. <defs>
  699. <style>
  700. .a {
  701. fill: #ee751b;
  702. }
  703. </style>
  704. </defs>
  705. <circle class="a" cx="4.89" cy="4.89" r="4.89" transform="translate(16.094)" />
  706. <ellipse class="a" cx="2.933" cy="2.933" rx="2.933" ry="2.933"
  707. transform="translate(18.05 36.099)" />
  708. <ellipse class="a" cx="4.401" cy="4.401" rx="4.401" ry="4.401" transform="translate(4.487 5.464)" />
  709. <circle class="a" cx="2.445" cy="2.445" r="2.445" transform="translate(30.626 31.609)" />
  710. <ellipse class="a" cx="3.911" cy="3.911" rx="3.911" ry="3.911" transform="translate(0 18.056)" />
  711. <circle class="a" cx="1.955" cy="1.955" r="1.955" transform="translate(36.091 20.01)" />
  712. <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"
  713. transform="translate(1.403 11.424)" />
  714. <ellipse class="a" cx="1.466" cy="1.466" rx="1.466" ry="1.466"
  715. transform="translate(31.603 8.434)" />
  716. </svg>
  717. </div>
  718. </div>`)
  719. $('#pills-intro').addClass('active');
  720. $('#pills-intro').addClass('show');
  721. $('#pills-video .card__bgImg').append('<img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">')
  722. $('.infoContent .nav-item-link').click(checkTab);
  723. checkTab();
  724. }
  725. function renderFB(data) {
  726. let str = '';
  727. for (let i = 0; i < data.length; i++) {
  728. }
  729. $('.fb__block').html(str);
  730. }
  731. function checkTab() {
  732. if ($('#pills-intro-tab').hasClass('active')) {
  733. $('.likeSee').attr('hidden', false)
  734. } else {
  735. $('.likeSee').attr('hidden', true)
  736. }
  737. }
  738. $(document).on("click", "#pills-tab .nav-item-link", function () {
  739. console.log($(this));
  740. console.log($(this).attr('id'));
  741. let className = $(this).attr('id');
  742. $(`#pills-tab .nav-item-link`).removeClass('active');
  743. $(`#${className}`).addClass('active');
  744. $(`.pill-aside #${className}`).addClass('active');
  745. });
  746. let sticky = document.querySelector('.sec-00').offsetHeight;
  747. window.addEventListener('scroll', fixedOnScroll);
  748. const navbar = document.querySelector('.navbar-main');
  749. function fixedOnScroll() {
  750. if (window.pageYOffset >= 344) {
  751. navbar.classList.add('sticky');
  752. } else {
  753. navbar.classList.remove('sticky');
  754. }
  755. }
  756. $(window).scroll(function () {
  757. if ($(this).scrollTop() > 800) {
  758. $('.fixed-btn').fadeIn(222);
  759. } else {
  760. $('.fixed-btn').stop().fadeOut(222);
  761. }
  762. }).scroll();
  763. // function loadMore(designer) {
  764. // console.log(designer)
  765. // let nowTab = document.querySelector('.infoContent .tab-pane.show');
  766. // if(nowTab === document.querySelector('#pills-intro')) {
  767. // let last = document.querySelector('#pills-intro .work__row>div:last-child');
  768. // let pageNum = Math.ceil(totalPages.intro / 12) - 1;
  769. // if ($(this).scrollTop() > last.offsetTop) {
  770. // if(n >= pageNum) {
  771. // n = pageNum;
  772. // return;
  773. // } else {
  774. // n ++;
  775. // console.log(n);
  776. // let append = '';
  777. // let d = designer['Content'][0].Carddata.slice(12*n, (12*n)+12);
  778. // console.log(d);
  779. // for(let j = 0;j < d.length; j ++) {
  780. // let tagStr = ''
  781. // for(let k = 0;k < d[j]['tag'].length; k ++) {
  782. // tagStr += `<a href="${d[j]['tag'][k]['link']}" class="card__tag" target="_blank">${d[j]['tag'][k]['name']}</a>`
  783. // }
  784. // append += `<div class="col-12 col-lg-6 col-xl-4">
  785. // <a href="${d[j]['url']});" target="_blank">
  786. // <div class="card">
  787. // <div style="overflow: hidden;">
  788. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  789. // </div>
  790. // </div>
  791. // <div class="card-body">
  792. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  793. // <p class="card-text mb-0">
  794. // ${tagStr}
  795. // </p>
  796. // </div>
  797. // </div>
  798. // </a>
  799. // </div>`
  800. // }
  801. // $('#pills-intro .work__row').append(append);
  802. // }
  803. // }
  804. // } else if (nowTab === document.querySelector('#pills-video')) {
  805. // let pageNum = Math.ceil(totalPages.video / 9) - 1;
  806. // console.log(totalPages.video);
  807. // let last = document.querySelector('#pills-video .work__row>div:last-child');
  808. // if ($(this).scrollTop() > last.offsetTop) {
  809. // if(n_video >= pageNum) {
  810. // n_video = pageNum;
  811. // console.log('n-video:', n_video);
  812. // console.log('pageNum', pageNum);
  813. // return;
  814. // } else {
  815. // console.log('pass-video');
  816. // n_video ++;
  817. // console.log('test');
  818. // let append = '';
  819. // let d = designer['Content'][1].Carddata.slice(9*n_video, (9*n_video)+9);
  820. // for(let j = 0;j < d.length; j ++) {
  821. // let tagStr = ''
  822. // for(let k = 0;k < d[j]['tags'].length; k ++) {
  823. // tagStr += `<a href="${d[j]['tags'][k]['link']}" class="card__tag" target="_blank">${d[j]['tags'][k]['name']}</a>`
  824. // }
  825. // append += `<div class="col-12 col-lg-6 col-xl-4">
  826. // <a href="" target="_blank">
  827. // <div class="card">
  828. // <div style="overflow: hidden;">
  829. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  830. // <img src="https://hhh.com.tw/assets/images/rv_web/play.svg" alt="" width="50" height="50">
  831. // </div>
  832. // </div>
  833. // <div class="card-body">
  834. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  835. // <p class="card-text mb-0">
  836. // ${tagStr}
  837. // </p>
  838. // </div>
  839. // </div>
  840. // </a>
  841. // </div>`
  842. // }
  843. // $('#pills-video .work__row').append(append);
  844. // }
  845. // }
  846. // } else if (nowTab === document.querySelector('#pills-columns')) {
  847. // let last = document.querySelector('#pills-columns .work__row>div:last-child');
  848. // let pageNum = Math.ceil(totalPages.columns / 9) - 1;
  849. // if ($(this).scrollTop() > last) {
  850. // if(n_columns >= pageNum) {
  851. // n_columns = pageNum;
  852. // return;
  853. // } else {
  854. // n_columns ++;
  855. // console.log('test');
  856. // let append = '';
  857. // let d = designer['Content'][2].Carddata.slice(9*n_columns, (9*n_columns)+9);
  858. // for(let j = 0;j < d.length; j ++) {
  859. // let tagStr = ''
  860. // for(let k = 0;k < d[j]['tags'].length; k ++) {
  861. // tagStr += `<a href="${d[j]['tags'][k]['link']}" class="card__tag" target="_blank">${d[j]['tags'][k]['name']}</a>`
  862. // }
  863. // append += `<div class="col-lg-6 col-xl-4">
  864. // <a href="" target="_blank">
  865. // <div class="card">
  866. // <div style="overflow: hidden;">
  867. // <div class="card__bgImg" style="background-image: url(${d[j]['imgURL']});">
  868. // </div>
  869. // </div>
  870. // <div class="card-body">
  871. // <h5 class="card-title card__title mt-0">${d[j]['title']}</h5>
  872. // <p class="card-text mb-0">
  873. // ${tagStr}
  874. // </p>
  875. // </div>
  876. // </div>
  877. // </a>
  878. // </div>`
  879. // }
  880. // $('#pills-columns .work__row').append(append);
  881. // }
  882. // }
  883. // }
  884. // }
  885. $('.btn-gotop').click(function () {
  886. $('html, body').animate({
  887. scrollTop: 0
  888. }, 500)
  889. });
  890. $('.sec-00__close').click(function () {
  891. $(this).css('display', 'none');
  892. $('.sec-00').addClass('bannerClose');
  893. //$('.sec-02').css('padding-top', '53px');
  894. sticky = 0;
  895. });
  896. document.addEventListener('lazybeforeunveil', function (e) {
  897. var bg = e.target.getAttribute('data-bg');
  898. if (bg) {
  899. e.target.style.backgroundImage = 'url(' + bg + ')';
  900. }
  901. });
  902. function renderModalTitle(title) {
  903. $('#emailModal #title').val(title);
  904. }
  905. function putEmail() {
  906. 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,}))$/;
  907. if ($('#email').val() !== null && emailPattern.test($('#email').val())) {
  908. $('#error').hide();
  909. $('#putEmail_hidden').css('display', 'block');
  910. $('#add_email').text($('#email').val());
  911. $('#email').val('');
  912. } else {
  913. $('#error').show();
  914. $('#error').text('email 格式有誤');
  915. }
  916. }