index_match.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. let userAgent;
  2. let isSafari = false;
  3. let browserName;
  4. window.onload = function(){
  5. if(screen.width < 900){
  6. window.location.href = "https://m3.hhh.com.tw/";
  7. }
  8. userAgent = navigator.userAgent;
  9. detectBrowser(userAgent);
  10. detectDirection ();
  11. let result;
  12. let matchData;
  13. $.ajax({
  14. method: "GET",
  15. url: "./json/realtime.json",
  16. dataType: "json",
  17. }).done(function (msg) {
  18. result = [...msg];
  19. renderSec00(result);
  20. renderSec02(result);
  21. renderSec05(result);
  22. renderSec06(result);
  23. renderSec07(result);
  24. renderSec08(result);
  25. renderSec09(result);
  26. renderSec10(result);
  27. //renderSec11(result);
  28. renderVideo(result);
  29. renderTrending(result);
  30. });
  31. $.ajax({
  32. method: "GET",
  33. url: "./json/match.json",
  34. dataType: "json",
  35. }).done(function (msg) {
  36. matchData = [...msg];
  37. renderMatch(matchData);
  38. });
  39. }
  40. function renderMatch(matchData){
  41. let str = '';
  42. for(let i = 0; i < matchData.length; i++){
  43. str += `<div class="row align-items-center py-3 justify-content-center text-center container__row">
  44. <div class="col">
  45. <div class="sec-match__imgfr mx-auto" style="background-image: url('${matchData[i].WorkImg}');"
  46. onclick="window.open('${matchData[i].DesignerLink}');"></div>
  47. </div>
  48. <div class="col">
  49. <div class="sec-match__designer mx-auto" style="background-image: url('${matchData[i].DesignerImg}');">
  50. </div>
  51. </div>
  52. <div class="col">
  53. <div style="width: 100%;" class="text-start mx-auto">
  54. <p>${matchData[i].Name} 設計師</p>
  55. <p class="mb-2">${matchData[i].CompanyName}</p>
  56. <p>擅長風格 ${matchData[i].CompanyName}</p>
  57. <p>接案坪數 ${matchData[i].Square} </p>
  58. <p>接案地區 ${matchData[i].Area}</p>
  59. </div>
  60. </div>
  61. <div class="col">
  62. <p>${matchData[i].Consulting} 人正在諮詢</p>
  63. </div>
  64. <div class="col">
  65. <button class="btn-match">我有興趣</button>
  66. </div>
  67. </div>`
  68. }
  69. $('.container__match').html(str);
  70. }
  71. $(document).on("click", ".btn-match", function (event) {
  72. Swal.fire({
  73. icon: 'success',
  74. text: '我們已收到您的訊息,將有幸福經紀人與您聯繫',
  75. confirmButtonText: '關閉',
  76. })
  77. });
  78. function detectDirection () {
  79. let height = (window.screen.width * 5) / 12;
  80. console.log(height);
  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. console.log(isSafari);
  101. }
  102. function renderSec00(data) {
  103. let temp = data[0]['data'];
  104. renderBannerStr('sec-00__slider', temp);
  105. $(".sec-00__slider").slick({
  106. dots: false,
  107. speed: 800,
  108. autoplay: true,
  109. autoplaySpeed: 5000,
  110. arrows: true,
  111. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
  112. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
  113. });
  114. }
  115. function renderSec02(data) {
  116. let temp = data[1]['data'];
  117. renderBannerStr('sec-02__slider', temp);
  118. $(".sec-02__slider").slick({
  119. dots: false,
  120. autoplay: true,
  121. arrows: true,
  122. fade: true,
  123. autoplaySpeed: 4000,
  124. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>',
  125. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>'
  126. });
  127. }
  128. function renderBannerStr(sec, data) {
  129. let str = '';
  130. for(let i = 0; i < data.length; i++){
  131. if(data[i]['Dwebp'] && !isSafari) {
  132. 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>`
  133. } else {
  134. 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>`
  135. }
  136. }
  137. $(`.${sec}`).html(str);
  138. }
  139. function renderSec05(data) {
  140. let randomIdx = Math.floor(Math.random()*3);
  141. const ran = $('.sec-05__tabdiv .nav-pills li').eq(randomIdx);
  142. const ranDiv = $('.sec-05tab-content>div').eq(randomIdx);
  143. $('.sec-05tab-content>div').hide();
  144. ranDiv.show();
  145. ran.addClass('active');
  146. ran.children().addClass('active');
  147. $('.sec-05 .morelink').attr('href', $('.sec-05__tabdiv .nav-item-link.active').data('link'));
  148. let temp = data[2]['data'];
  149. for(let i = 0; i < temp.length; i++){
  150. if(temp[i]["tab"] == '最夯設計'){
  151. let str = '';
  152. let sub = temp[i]["data"];
  153. for(let j = 0; j < sub.length; j++){
  154. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  155. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  156. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  157. <p class="mt-2">${sub[j]['description']}</p>
  158. </div>`;
  159. }
  160. $('#pills-hot-tab .tabpar').html(str);
  161. }
  162. if(temp[i]["tab"] == '影音實錄'){
  163. let str = '';
  164. let sub = temp[i]["data"];
  165. for(let j = 0; j < sub.length; j++){
  166. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  167. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"><img data-src="images/Play-Button.webp" alt="" class="tabpar__card__play lazyload"></div>
  168. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  169. <p class="mt-2">${sub[j]['description']}</p>
  170. </div>`;
  171. }
  172. $('#pills-video-tab .tabpar').html(str);
  173. }
  174. if(temp[i]["tab"] == '專欄文章'){
  175. let str = '';
  176. let sub = temp[i]["data"];
  177. for(let j = 0; j < sub.length; j++){
  178. str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
  179. <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
  180. <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
  181. <p class="mt-2">${sub[j]['description']}</p>
  182. </div>`;
  183. }
  184. $('#pills-blog-tab .tabpar').html(str);
  185. }
  186. }
  187. const cardText = document.querySelectorAll('.tabpar__card p');
  188. cardText.forEach((item, i) => {
  189. let len = item.textContent.length;
  190. if(len > 18) {
  191. let str = item.textContent.substring(0, 18) + '...';
  192. item.textContent = str;
  193. }
  194. })
  195. $('.sec-05__tabdiv .nav-pills button').on('click', function(event){
  196. event.preventDefault();
  197. $('.sec-05__tabdiv .nav-pills li').removeClass('active');
  198. $('.sec-05__tabdiv .nav-pills li button').removeClass('active');
  199. $(this).addClass('active');
  200. $(this).parent().addClass('active');
  201. $('.sec-05tab-content>div').hide();
  202. var target = $(this).attr('id');
  203. $(`#pills-tab #${target}`).show();
  204. $('.sec-05tab-content .tabpar').slick('setPosition');
  205. });
  206. $(`.sec-05tab-content .tabpar`).slick({
  207. arrows: true,
  208. slidesToShow: 3,
  209. infinite: false,
  210. dots: false,
  211. slidesToScroll: 1,
  212. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  213. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  214. });
  215. $('.sec-05__tabdiv .nav-item-link').click(function() {
  216. $('.sec-05 .morelink').attr('href',$('.sec-05__tabdiv .nav-item-link.active').data('link'));
  217. });
  218. }
  219. function renderSec06(data) {
  220. let temp = data[3]['data'];
  221. let str = '';
  222. for(let i = 0; i < temp.length; i++){
  223. if(temp[i].video == 'true'){
  224. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  225. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-06__card__play lazyload" data-src="images/Play-Button.webp"></div></div>
  226. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  227. <p class="mt-2">${temp[i]['description']}</p>
  228. </div>`;
  229. } else {
  230. str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
  231. <div class="sec-06__card__outer"><div class="sec-06__card__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div></div>
  232. <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
  233. <p class="mt-2">${temp[i]['description']}</p>
  234. </div>`;
  235. }
  236. }
  237. $('.sec-06 .sec-06__slider').html(str);
  238. $('.sec-06__slider').slick({
  239. arrows: true,
  240. dots: false,
  241. speed: 800,
  242. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 30px;color: white;"></i></button>',
  243. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 30px;color: white;"></i></button>'
  244. });
  245. const cardText = document.querySelectorAll('.sec-06__card p');
  246. cardText.forEach((item, i) => {
  247. let len = item.textContent.length;
  248. if(len > 20) {
  249. let str = item.textContent.substring(0, 40) + '...';
  250. item.textContent = str;
  251. }
  252. });
  253. }
  254. function renderSec07(data) {
  255. let temp = data[5]['data'];
  256. let str = '';
  257. for(let i = 0; i < temp.length; i++){
  258. str+= `<div class="sec-07__slider-${i+1} slide-item" onclick="window.open('${temp[i]['link']}');" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>`
  259. }
  260. $(`.sec-07__slider`).html(str);
  261. $(".sec-07__slider").slick({
  262. dots: false,
  263. autoplay: true,
  264. arrows: false,
  265. slidesToShow: 4,
  266. slidesToScroll: 1,
  267. autoplaySpeed: 7000,
  268. initialSlide: 0,
  269. infinite: true,
  270. });
  271. }
  272. function renderSec08(data) {
  273. let temp = data[4]['data'];
  274. let str = '';
  275. for(let i = 0; i < temp.length; i++){
  276. if(temp[i].video == 'true'){
  277. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  278. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-08__card__play lazyload" data-src="images/Play-Button.webp"></div>
  279. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  280. <p class="mb-2 me-2">${temp[i]['description']}</p>
  281. </div>`;
  282. } else {
  283. str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  284. <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  285. <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
  286. <p class="mb-2 me-2">${temp[i]['description']}</p>
  287. </div>`;
  288. }
  289. }
  290. $('.sec-08__slider').html(str);
  291. $(".sec-08__slider").slick({
  292. arrows: true,
  293. slidesToShow: 1,
  294. infinite: false,
  295. dots: false,
  296. slidesToShow: 3,
  297. centerPadding: '12px',
  298. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  299. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  300. });
  301. const cardText = document.querySelectorAll('.sec-08__card p');
  302. cardText.forEach((item, i) => {
  303. let len = item.textContent.length;
  304. if(len > 20) {
  305. let str = item.textContent.substring(0, 20) + '...';
  306. item.textContent = str;
  307. }
  308. })
  309. }
  310. function renderSec09(data) {
  311. let temp = data[6]['data'];
  312. let str = '';
  313. for(let i = 0; i < temp.length; i++){
  314. if(temp[i].video !== 'false') {
  315. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  316. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"><img class="sec-09__card__play lazyload" data-src="images/Play-Button.webp"></div>
  317. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  318. </div>`
  319. } else {
  320. str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
  321. <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
  322. <p class="sec-09__cardtxt">${temp[i]['title']}</p>
  323. </div>`
  324. }
  325. }
  326. $('.sec-09__slider').html(str);
  327. $(".sec-09__slider").slick({
  328. autoplay: true,
  329. autoplaySpeed: 7000,
  330. arrows: true,
  331. slidesToShow: 4,
  332. infinite: true,
  333. dots: false,
  334. slidesToScroll: 1,
  335. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
  336. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
  337. });
  338. }
  339. function renderSec10(data) {
  340. renderRecStr("sec-10", data[7]['data'].slice(0, 6));
  341. renderRecStr("sec-11", data[8]['data'].slice(0, 6));
  342. }
  343. function renderRecStr(sec, data) {
  344. let str = '';
  345. for(let i = 0; i < data.length; i++){
  346. //console.log(data[i]['description'].length);
  347. if(data[i]['description'].length > 0) {
  348. data[i]['description'].split(',');
  349. data[i]['description'] = data[i]['description'].split(',').slice(1).join("");
  350. }
  351. if(data[i].video !== 'false') {
  352. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  353. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"><img class="${sec}__card__play lazyload" data-src="images/Play-Button.webp"></div>
  354. <h5 class="me-2">${data[i]['title']}</h5>
  355. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  356. </div>`
  357. } else {
  358. str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
  359. <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>
  360. <h5 class="me-2">${data[i]['title']}</h5>
  361. <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
  362. </div>`
  363. }
  364. }
  365. $(`.${sec} .row`).html(str);
  366. const cardText = document.querySelectorAll(`.${sec}__card p`);
  367. cardText.forEach((item, i) => {
  368. let len = item.textContent.length;
  369. if(len > 18) {
  370. let str = item.textContent.substring(0, 18) + '...';
  371. item.textContent = str;
  372. }
  373. })
  374. }
  375. function renderVideo(data) {
  376. let temp = data[9];
  377. console.log(data[9]);
  378. $('.sec-06__videotxt').text(temp['title']);
  379. console.log('test');
  380. $('.sec-06__video__imgfr').css('background-image', `url(https://img.youtube.com/vi/${temp['yt']}/hqdefault.jpg)`);
  381. $('#videoModal').on('shown.bs.modal', function () {
  382. $('#videoModal iframe').attr('src', `https://www.youtube.com/embed/${temp['yt']}?controls=0&autoplay=1&amp;enablejsapi=1&amp;origin=https%3A%2F%2Fm.hhh.com.tw&amp;widgetid=1`);
  383. });
  384. $('#videoModal').on('hidden.bs.modal', function () {
  385. $('#videoModal iframe').removeAttr('src');
  386. });
  387. }
  388. function renderTrending(result){
  389. let temp = result[10]['data'];
  390. let str = '';
  391. for(let i = 0; i < temp.length; i++){
  392. str += `<a class="dropbox__hots__link" href="https://hhh.com.tw/search/lists/case/${temp[i]}-keyword/">${temp[i]}</a>`
  393. }
  394. $('.dropbox__hots').html(`<strong class="dropbox__hots__title">熱搜關鍵字:</strong>${str}`);
  395. }
  396. function tab2 () {
  397. if(('.dropbox__tabdiv').length){
  398. // Show the first tab by default
  399. $('.dropbox-tab-content>div').hide();
  400. $('.dropbox-tab-content>div:first').show();
  401. $('.dropbox__tabdiv .nav-pills li:first').addClass('active');
  402. $('.dropbox__tabdiv .nav-pills li:first button').addClass('active');
  403. // Change tab class and display content
  404. $('.dropbox__tabdiv .nav-pills button').on('click', function(event){
  405. event.preventDefault();
  406. $('.dropbox__tabdiv .nav-pills li').removeClass('active');
  407. $('.dropbox__tabdiv .nav-pills li button').removeClass('active');
  408. $(this).addClass('active');
  409. $(this).parent().addClass('active');
  410. $('.dropbox-tab-content>div').hide();
  411. var target = $(this).attr('id');
  412. $(`#pills-tab-2 #${target}`).show();
  413. });
  414. }
  415. }
  416. tab2();
  417. window.addEventListener('scroll', fixedOnScroll);
  418. const navbar = document.querySelector('.navbar-main');
  419. function fixedOnScroll() {
  420. }
  421. $(window).scroll(function() {
  422. if ( $(this).scrollTop() > 800 ){
  423. $('.fixed-btn').fadeIn(222);
  424. } else {
  425. $('.fixed-btn').stop().fadeOut(222);
  426. }
  427. }).scroll();
  428. $('.btn-gotop').click(function () {
  429. $('html, body').animate({
  430. scrollTop: 0
  431. }, 500)
  432. });
  433. $('.navbar-search img').click(function(){
  434. $('.navbar-search .dropbox').toggleClass('open');
  435. if($('.navbar-search .dropbox').hasClass('open')) {
  436. $('.navbar-nav .nav-item>.dropbox').addClass('d-none');
  437. } else {
  438. $('.navbar-nav .nav-item>.dropbox').removeClass('d-none');
  439. }
  440. });
  441. $('.sec-00__close').click(function(){
  442. $(this).css('display', 'none');
  443. $('.sec-00').addClass('bannerClose');
  444. //$('.sec-02').css('padding-top', '53px');
  445. sticky = 0;
  446. });
  447. // search
  448. const imageSearch = document.querySelector('.image-search');
  449. const imagesSelect = document.querySelectorAll('#pills-img-tab select');
  450. imageSearch.addEventListener("click", function() {
  451. searchQueryStr(imagesSelect, 'photos');
  452. })
  453. const newsSearch = document.querySelector('.news-search');
  454. const newsSelect = document.querySelectorAll('#pills-news-tab select');
  455. newsSearch.addEventListener("click", function() {
  456. searchQueryStr(newsSelect, 'builder');
  457. });
  458. const caseSearch= document.querySelector('.case-search');
  459. const caseSelect = document.querySelectorAll('#pills-case-tab select');
  460. caseSearch.addEventListener("click", function() {
  461. let query = ''
  462. let str = 'https://hhh.com.tw/cases/lists/1-page/new-sort/';
  463. if($('#case-shui').val() == '風水') {
  464. caseSelect.forEach((item, i) => {
  465. if(i < 2) {
  466. if(item.value !== ''){
  467. query += `/${item.value}`;
  468. }
  469. }
  470. });
  471. str = `https://hhh.com.tw/cases/lists${query}/風水-keyword/1-page/`;
  472. window.open(str);
  473. return;
  474. }
  475. caseSelect.forEach((item, i) => {
  476. if(item.value !== ''){
  477. query += `/${item.value}`;
  478. }
  479. });
  480. str = `https://hhh.com.tw/cases/lists${query}/1-page/`;
  481. window.open(str);
  482. })
  483. const designerSearch = document.querySelector('.designer-search');
  484. const designerSelect = document.querySelectorAll('#pills-designer-tab select');
  485. designerSearch.addEventListener("click", function() {
  486. searchQueryStr(designerSelect, 'designers');
  487. })
  488. function searchQueryStr(block, link){
  489. let query = ''
  490. let str = `https://hhh.com.tw/${link}/lists/1-page/`;
  491. block.forEach((item, i) => {
  492. if(item.value !== ''){
  493. query += `/${item.value}`;
  494. }
  495. });
  496. str = `https://hhh.com.tw/${link}/lists${query}/1-page/`;
  497. window.location.href = str;
  498. }
  499. const searchBtn = document.querySelector('.dropbox__searchBar__submit');
  500. const searchBar = document.querySelector('.dropbox__searchBar__input');
  501. searchBtn.addEventListener('click', search);
  502. searchBar.addEventListener('keyup', pressSearch);
  503. function search() {
  504. if(searchBar.value == '') {
  505. window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
  506. } else {
  507. window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
  508. console.log(`https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`)
  509. }
  510. }
  511. function pressSearch(e) {
  512. if (e.keyCode === 13) {
  513. e.preventDefault();
  514. search();
  515. }
  516. }
  517. function todayTV() {
  518. var utc = new Date().toJSON().slice(0,10).replace(/-/g,'-');
  519. window.location.href=`https://hhh.com.tw/program/?tv=gstv&date=${utc}&type=tv`;
  520. }
  521. document.addEventListener('lazybeforeunveil', function(e){
  522. var bg = e.target.getAttribute('data-bg');
  523. if(bg){
  524. e.target.style.backgroundImage = 'url(' + bg + ')';
  525. }
  526. });
  527. $('.container_match2').hide();
  528. $('.match__next').click(function() {
  529. $('.container_match').fadeOut(0);
  530. $('.container_match2').fadeIn(500);
  531. })
  532. // city result
  533. let cityResult;
  534. $.ajax({
  535. method: "GET",
  536. url: "../json/taiwan_districts.json",
  537. dataType: "json",
  538. }).done(function (msg) {
  539. cityResult = [...msg];
  540. let str = '';
  541. for(let i = 0; i < cityResult.length; i++){
  542. str += `<option value="${cityResult[i]['zip']}-city">${cityResult[i]['name']}</option>`;
  543. }
  544. $('#designer-city').html(`<option value="" selected="selected" disabled>所在縣市</option>${str}`);
  545. $('#designer-city').on('change', function() {
  546. let selected = $(this).val().split('-')[0];
  547. let countyStr = '';
  548. for(let i = 0; i < cityResult.length; i++){
  549. if(cityResult[i]['zip'] == selected) {
  550. for(let j = 0; j < cityResult[i]['districts'].length; j++){
  551. countyStr += `<option value="${cityResult[i]['districts'][j]['zip']}-county">${cityResult[i]['districts'][j]['name']}</option>`;
  552. }
  553. }
  554. }
  555. $('#designer-country').html(`<option value="" selected="selected" disabled>所在地區</option>${countyStr}`);
  556. });
  557. });
  558. //jQuery time
  559. var current_fs, next_fs, previous_fs; //fieldsets
  560. var left, opacity, scale; //fieldset properties which we will animate
  561. var animating; //flag to prevent quick multi-click glitches
  562. $(".next").click(function(){
  563. if(animating) return false;
  564. animating = true;
  565. current_fs = $(this).parent().parent();
  566. next_fs = $(this).parent().parent().next();
  567. //activate next step on progressbar using the index of next_fs
  568. $(".form-progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
  569. //show the next fieldset
  570. next_fs.animate({opacity: 1}, {
  571. step: function(now, mx) {
  572. //as the opacity of current_fs reduces to 0 - stored in "now"
  573. //1. scale current_fs down to 80%
  574. scale = 0 + (1 + now) * .5 ;
  575. //2. bring next_fs from the right(50%)
  576. left = (now * 50)+"%";
  577. //3. increase opacity of next_fs to 1 as it moves in
  578. opacity = 0 + now;
  579. next_fs.css({
  580. 'transform': 'scale('+scale+')',
  581. });
  582. next_fs.css({'opacity': opacity});
  583. },
  584. duration: 400,
  585. complete: function(){
  586. next_fs.show();
  587. animating = false;
  588. },
  589. //this comes from the custom easing plugin
  590. easing: 'easeInOutBack'
  591. });
  592. //hide the current fieldset with style
  593. current_fs.animate({opacity: 0}, {
  594. step: function(now, mx) {
  595. //as the opacity of current_fs reduces to 0 - stored in "now"
  596. //1. scale current_fs down to 80%
  597. scale = 1 - (1 - now) * 0.2;
  598. //2. bring next_fs from the right(50%)
  599. left = (now * 50)+"%";
  600. //3. increase opacity of next_fs to 1 as it moves in
  601. opacity = 1 - now;
  602. current_fs.css({
  603. 'transform': 'scale('+scale+')',
  604. });
  605. next_fs.css({'opacity': opacity});
  606. },
  607. duration: 400,
  608. complete: function(){
  609. current_fs.hide();
  610. animating = false;
  611. },
  612. //this comes from the custom easing plugin
  613. easing: 'easeInOutBack'
  614. });
  615. });
  616. $('.close').click(function () {
  617. window.close();
  618. })