123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- let userAgent;
- let isSafari = false;
- let browserName;
- window.onload = function(){
- // if(screen.width < 900){
- // window.location.href = "https://m3.hhh.com.tw/";
- // }
- userAgent = navigator.userAgent;
- detectBrowser(userAgent);
- detectDirection ();
- let result;
- let matchData;
- $.ajax({
- method: "GET",
- url: "./json/realtime.json",
- dataType: "json",
- }).done(function (msg) {
- // result = [...msg];
- // renderSec00(result);
- // renderSec02(result);
- // renderSec05(result);
- // renderSec06(result);
- // renderSec07(result);
- // renderSec08(result);
- // renderSec09(result);
- // renderSec10(result);
- // //renderSec11(result);
- // renderVideo(result);
- // renderTrending(result);
- });
- $.ajax({
- method: "GET",
- url: "./json/match.json",
- dataType: "json",
- }).done(function (msg) {
- matchData = [...msg];
- renderMatch(matchData);
- });
- }
- function renderMatch(matchData){
- let str = '';
- for(let i = 0; i < matchData.length; i++){
- str += `<div class="row align-items-center py-4 pb-5 justify-content-center text-center container__row" style="border-bottom: 1px solid #B2B2B2;">
- <div class="col-12 mb-4">
- <div class="sec-result__imgfr mx-auto" style="background-image: url('${matchData[i].WorkImg}');"
- onclick="window.open('${matchData[i].DesignerLink}');"></div>
- </div>
- <div class="row">
- <div class="col-6">
- <div class="sec-result__designer mx-auto mb-4" style="background-image: url('${matchData[i].DesignerImg}');">
- </div>
- <button class="btn-match">我有興趣</button>
- </div>
- <div class="col-6">
- <div class="text-start mx-auto">
- <p>${matchData[i].Name} 設計師</p>
- <p class="mb-2">${matchData[i].CompanyName}</p>
- <p>擅長風格 ${matchData[i].Style}</p>
- <p>接案坪數 ${matchData[i].Square}</p>
- <p class="mb-2">接案地區 ${matchData[i].Area}</p>
- <span class="sec-result__consulting"><strong class="sec-result__num">${matchData[i].Consulting}</strong> 人正在諮詢</span>
- </div>
- </div>
- </div>
- </div>
- `
- }
- $('.container__match').html(str);
-
- }
-
- $(document).on("click", ".btn-match", function (event) {
- Swal.fire({
- icon: 'success',
- text: '我們已收到您的訊息,將有幸福經紀人與您聯繫',
- confirmButtonText: '關閉',
- })
- });
- function detectDirection () {
- let height = (window.screen.width * 5) / 12;
- console.log(height);
- $('.sec-02 .slide-item').css('height', `${height}px`);
- }
- function detectBrowser(agent){
- if(userAgent.match(/chrome|chromium|crios/i)){
- browserName = "chrome";
- }else if(userAgent.match(/firefox|fxios/i)){
- browserName = "firefox";
- } else if(userAgent.match(/safari/i)){
- browserName = "safari";
- }else if(userAgent.match(/opr\//i)){
- browserName = "opera";
- } else if(userAgent.match(/edg/i)){
- browserName = "edge";
- }else{
- browserName="No browser detection";
- }
-
- if(browserName === 'safari'){
- isSafari = true;
- }
- console.log(isSafari);
- }
- function renderSec00(data) {
- let temp = data[0]['data'];
- renderBannerStr('sec-00__slider', temp);
- $(".sec-00__slider").slick({
- dots: false,
- speed: 800,
- autoplay: true,
- autoplaySpeed: 5000,
- arrows: true,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: white;transform: translateY(-10px);"></i></button>'
- });
- }
- function renderSec02(data) {
- let temp = data[1]['data'];
- renderBannerStr('sec-02__slider', temp);
- $(".sec-02__slider").slick({
- dots: false,
- autoplay: true,
- arrows: true,
- fade: true,
- autoplaySpeed: 4000,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 33px;color: white;transform: translateY(-10px);"></i></button>'
- });
- }
- function renderBannerStr(sec, data) {
- let str = '';
- for(let i = 0; i < data.length; i++){
- if(data[i]['Dwebp'] && !isSafari) {
- 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>`
- } else {
- 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>`
- }
-
- }
- $(`.${sec}`).html(str);
- }
- function renderSec05(data) {
- let randomIdx = Math.floor(Math.random()*3);
- const ran = $('.sec-05__tabdiv .nav-pills li').eq(randomIdx);
- const ranDiv = $('.sec-05tab-content>div').eq(randomIdx);
- $('.sec-05tab-content>div').hide();
- ranDiv.show();
- ran.addClass('active');
- ran.children().addClass('active');
- $('.sec-05 .morelink').attr('href', $('.sec-05__tabdiv .nav-item-link.active').data('link'));
- let temp = data[2]['data'];
- for(let i = 0; i < temp.length; i++){
- if(temp[i]["tab"] == '最夯設計'){
- let str = '';
- let sub = temp[i]["data"];
- for(let j = 0; j < sub.length; j++){
- str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
- <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
- <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
- <p class="mt-2">${sub[j]['description']}</p>
- </div>`;
- }
- $('#pills-hot-tab .tabpar').html(str);
- }
- if(temp[i]["tab"] == '影音實錄'){
- let str = '';
- let sub = temp[i]["data"];
- for(let j = 0; j < sub.length; j++){
- str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
- <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>
- <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
- <p class="mt-2">${sub[j]['description']}</p>
- </div>`;
- }
- $('#pills-video-tab .tabpar').html(str);
- }
- if(temp[i]["tab"] == '專欄文章'){
- let str = '';
- let sub = temp[i]["data"];
- for(let j = 0; j < sub.length; j++){
- str+= `<div class="tabpar__card" onclick="window.open('${sub[j]['link']}');">
- <div class="tabpar__card__imgfr mb-2" style="background-image: url('${sub[j]['imgUrl']}');" data-bg="${sub[j]['imgUrl']}"></div>
- <h5 class="mb-2 me-2">${sub[j]['title']}</h5>
- <p class="mt-2">${sub[j]['description']}</p>
- </div>`;
- }
- $('#pills-blog-tab .tabpar').html(str);
- }
- }
- const cardText = document.querySelectorAll('.tabpar__card p');
- cardText.forEach((item, i) => {
- let len = item.textContent.length;
- if(len > 18) {
- let str = item.textContent.substring(0, 18) + '...';
- item.textContent = str;
- }
- })
- $('.sec-05__tabdiv .nav-pills button').on('click', function(event){
- event.preventDefault();
- $('.sec-05__tabdiv .nav-pills li').removeClass('active');
- $('.sec-05__tabdiv .nav-pills li button').removeClass('active');
- $(this).addClass('active');
- $(this).parent().addClass('active');
- $('.sec-05tab-content>div').hide();
- var target = $(this).attr('id');
- $(`#pills-tab #${target}`).show();
- $('.sec-05tab-content .tabpar').slick('setPosition');
- });
- $(`.sec-05tab-content .tabpar`).slick({
- arrows: true,
- slidesToShow: 3,
- infinite: false,
- dots: false,
- slidesToScroll: 1,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
- });
- $('.sec-05__tabdiv .nav-item-link').click(function() {
- $('.sec-05 .morelink').attr('href',$('.sec-05__tabdiv .nav-item-link.active').data('link'));
- });
- }
- function renderSec06(data) {
- let temp = data[3]['data'];
- let str = '';
- for(let i = 0; i < temp.length; i++){
- if(temp[i].video == 'true'){
- str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
- <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>
- <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
- <p class="mt-2">${temp[i]['description']}</p>
- </div>`;
- } else {
- str+= `<div class="sec-06__card" onclick="window.open('${temp[i]['link']}');">
- <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>
- <h5 class="mb-2 mt-2">${temp[i]['title']}</h5>
- <p class="mt-2">${temp[i]['description']}</p>
- </div>`;
- }
- }
- $('.sec-06 .sec-06__slider').html(str);
- $('.sec-06__slider').slick({
- arrows: true,
- dots: false,
- speed: 800,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 30px;color: white;"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 30px;color: white;"></i></button>'
- });
- const cardText = document.querySelectorAll('.sec-06__card p');
- cardText.forEach((item, i) => {
- let len = item.textContent.length;
- if(len > 20) {
- let str = item.textContent.substring(0, 40) + '...';
- item.textContent = str;
- }
- });
- }
- function renderSec07(data) {
- let temp = data[5]['data'];
- let str = '';
- for(let i = 0; i < temp.length; i++){
- 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>`
- }
- $(`.sec-07__slider`).html(str);
- $(".sec-07__slider").slick({
- dots: false,
- autoplay: true,
- arrows: false,
- slidesToShow: 4,
- slidesToScroll: 1,
- autoplaySpeed: 7000,
- initialSlide: 0,
- infinite: true,
- });
- }
- function renderSec08(data) {
- let temp = data[4]['data'];
- let str = '';
- for(let i = 0; i < temp.length; i++){
- if(temp[i].video == 'true'){
- str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
- <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>
- <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
- <p class="mb-2 me-2">${temp[i]['description']}</p>
- </div>`;
- } else {
- str+= `<div class="sec-08__slider-${i+1} sec-08__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
- <div class="sec-08__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
- <h5 class="mb-2 me-2">${temp[i]['title']}</h5>
- <p class="mb-2 me-2">${temp[i]['description']}</p>
- </div>`;
- }
- }
- $('.sec-08__slider').html(str);
- $(".sec-08__slider").slick({
- arrows: true,
- slidesToShow: 1,
- infinite: false,
- dots: false,
- slidesToShow: 3,
- centerPadding: '12px',
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
- });
- const cardText = document.querySelectorAll('.sec-08__card p');
- cardText.forEach((item, i) => {
- let len = item.textContent.length;
- if(len > 20) {
- let str = item.textContent.substring(0, 20) + '...';
- item.textContent = str;
- }
- })
- }
- function renderSec09(data) {
- let temp = data[6]['data'];
- let str = '';
- for(let i = 0; i < temp.length; i++){
- if(temp[i].video !== 'false') {
- str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
- <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>
- <p class="sec-09__cardtxt">${temp[i]['title']}</p>
- </div>`
- } else {
- str+= `<div class="sec-09__slider-1 sec-09__card col-12 mx-2" onclick="window.open('${temp[i]['link']}');">
- <div class="sec-09__imgfr mb-2" style="background-image: url('${temp[i]['imgUrl']}');" data-bg="${temp[i]['imgUrl']}"></div>
- <p class="sec-09__cardtxt">${temp[i]['title']}</p>
- </div>`
- }
-
- }
- $('.sec-09__slider').html(str);
- $(".sec-09__slider").slick({
- autoplay: true,
- autoplaySpeed: 7000,
- arrows: true,
- slidesToShow: 4,
- infinite: true,
- dots: false,
- slidesToScroll: 1,
- prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 35px;color: black;"></i></button>',
- nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 35px;color: black;"></i></button>'
- });
- }
- function renderSec10(data) {
- renderRecStr("sec-10", data[7]['data'].slice(0, 6));
- renderRecStr("sec-11", data[8]['data'].slice(0, 6));
- }
- function renderRecStr(sec, data) {
- let str = '';
- for(let i = 0; i < data.length; i++){
- //console.log(data[i]['description'].length);
- if(data[i]['description'].length > 0) {
- data[i]['description'].split(',');
- data[i]['description'] = data[i]['description'].split(',').slice(1).join("");
- }
- if(data[i].video !== 'false') {
- str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
- <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>
- <h5 class="me-2">${data[i]['title']}</h5>
- <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
- </div>`
- } else {
- str+= `<div class="${sec}__card col-4 mb-3" onclick="window.open('${data[i]['link']}');">
- <div class="${sec}__card-img mb-2" style="background-image: url('${data[i]['imgUrl']}');" data-bg="${data[i]['imgUrl']}"></div>
- <h5 class="me-2">${data[i]['title']}</h5>
- <p class="${sec}__cardtxt me-2">${data[i]['description']}</p>
- </div>`
- }
-
- }
- $(`.${sec} .row`).html(str);
- const cardText = document.querySelectorAll(`.${sec}__card p`);
- cardText.forEach((item, i) => {
- let len = item.textContent.length;
- if(len > 18) {
- let str = item.textContent.substring(0, 18) + '...';
- item.textContent = str;
- }
- })
- }
- function renderVideo(data) {
- let temp = data[9];
- console.log(data[9]);
- $('.sec-06__videotxt').text(temp['title']);
- console.log('test');
- $('.sec-06__video__imgfr').css('background-image', `url(https://img.youtube.com/vi/${temp['yt']}/hqdefault.jpg)`);
- $('#videoModal').on('shown.bs.modal', function () {
- $('#videoModal iframe').attr('src', `https://www.youtube.com/embed/${temp['yt']}?controls=0&autoplay=1&enablejsapi=1&origin=https%3A%2F%2Fm.hhh.com.tw&widgetid=1`);
- });
- $('#videoModal').on('hidden.bs.modal', function () {
- $('#videoModal iframe').removeAttr('src');
- });
- }
- function renderTrending(result){
- let temp = result[10]['data'];
- let str = '';
- for(let i = 0; i < temp.length; i++){
- str += `<a class="dropbox__hots__link" href="https://hhh.com.tw/search/lists/case/${temp[i]}-keyword/">${temp[i]}</a>`
- }
- $('.dropbox__hots').html(`<strong class="dropbox__hots__title">熱搜關鍵字:</strong>${str}`);
- }
- function tab2 () {
- if(('.dropbox__tabdiv').length){
- // Show the first tab by default
- $('.dropbox-tab-content>div').hide();
- $('.dropbox-tab-content>div:first').show();
- $('.dropbox__tabdiv .nav-pills li:first').addClass('active');
- $('.dropbox__tabdiv .nav-pills li:first button').addClass('active');
- // Change tab class and display content
- $('.dropbox__tabdiv .nav-pills button').on('click', function(event){
- event.preventDefault();
- $('.dropbox__tabdiv .nav-pills li').removeClass('active');
- $('.dropbox__tabdiv .nav-pills li button').removeClass('active');
- $(this).addClass('active');
- $(this).parent().addClass('active');
- $('.dropbox-tab-content>div').hide();
- var target = $(this).attr('id');
- $(`#pills-tab-2 #${target}`).show();
- });
- }
- }
- tab2();
- window.addEventListener('scroll', fixedOnScroll);
-
- const navbar = document.querySelector('.navbar-main');
-
- function fixedOnScroll() {
-
- }
- $(window).scroll(function() {
- if ( $(this).scrollTop() > 800 ){
- $('.fixed-btn').fadeIn(222);
- } else {
- $('.fixed-btn').stop().fadeOut(222);
- }
- }).scroll();
- $('.btn-gotop').click(function () {
- $('html, body').animate({
- scrollTop: 0
- }, 500)
- });
- $('.navbar-search img').click(function(){
- $('.navbar-search .dropbox').toggleClass('open');
- if($('.navbar-search .dropbox').hasClass('open')) {
- $('.navbar-nav .nav-item>.dropbox').addClass('d-none');
- } else {
- $('.navbar-nav .nav-item>.dropbox').removeClass('d-none');
- }
- });
- $('.sec-00__close').click(function(){
- $(this).css('display', 'none');
- $('.sec-00').addClass('bannerClose');
- //$('.sec-02').css('padding-top', '53px');
- sticky = 0;
- });
- document.addEventListener('lazybeforeunveil', function(e){
- var bg = e.target.getAttribute('data-bg');
- if(bg){
- e.target.style.backgroundImage = 'url(' + bg + ')';
- }
- });
- $('.container_match2').hide();
- $('.match__next').click(function() {
- $('.container_match').fadeOut(0);
- $('.container_match2').fadeIn(500);
- })
- //jQuery time
- var current_fs, next_fs, previous_fs; //fieldsets
- var left, opacity, scale; //fieldset properties which we will animate
- var animating; //flag to prevent quick multi-click glitches
-
- $(".next").click(function(){
- if(animating) return false;
- animating = true;
-
- current_fs = $(this).parent().parent();
- next_fs = $(this).parent().parent().next();
-
- //activate next step on progressbar using the index of next_fs
- $(".form-progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
-
- //show the next fieldset
- next_fs.animate({opacity: 1}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale current_fs down to 80%
- scale = 0 + (1 + now) * .5 ;
- //2. bring next_fs from the right(50%)
- left = (now * 50)+"%";
- //3. increase opacity of next_fs to 1 as it moves in
- opacity = 0 + now;
- next_fs.css({
- 'transform': 'scale('+scale+')',
- });
- next_fs.css({'opacity': opacity});
- },
- duration: 400,
- complete: function(){
- next_fs.show();
- animating = false;
- },
- //this comes from the custom easing plugin
- easing: 'easeInOutBack'
- });
- //hide the current fieldset with style
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale current_fs down to 80%
- scale = 1 - (1 - now) * 0.2;
- //2. bring next_fs from the right(50%)
- left = (now * 50)+"%";
- //3. increase opacity of next_fs to 1 as it moves in
- opacity = 1 - now;
- current_fs.css({
- 'transform': 'scale('+scale+')',
- });
- next_fs.css({'opacity': opacity});
- },
- duration: 400,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
- //this comes from the custom easing plugin
- easing: 'easeInOutBack'
- });
- });
- $('.close').click(function () {
- window.close();
- })
|