123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- let userAgent;
- let isSafari = false;
- let browserName;
- window.onload = function(){
- //window.scrollBy(0, 1);
- /* if(screen.width >= 901){
- window.location.href = "https://www2.hhh.com.tw/";
- } */
- userAgent = navigator.userAgent;
- detectBrowser(userAgent);
- detectDirection ();
- let result;
- }
- let over = document.querySelector('.infoContent__navBlock').offsetTop;
- 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 detectDirection () {
- let height = (window.screen.width * 2) / 3;
-
- $('.sec-02 .slide-item').css('height', `${height}px`);
- let topHeight = (window.screen.width * 30) / 131;
-
- $('.sec-00 .slide-item').css('height', `${topHeight}px`);
- $('.sec-00 .container-fluid').css('height', `${topHeight}px`);
- }
- window.addEventListener('scroll', fixedOnScroll);
- const navBlock = document.querySelector('.infoContent__navBlock');
- function fixedOnScroll() {
- if(window.innerHeight < window.innerWidth){
- } else {
- detectDirection ();
- }
-
- if(window.pageYOffset >= over){
- navBlock.classList.add('tab_sticky');
- } else if(window.pageYOffset < over) {
- navBlock.classList.remove('tab_sticky');
- }
- }
-
- $('.navbar-toggler').click(function(){
- $(".sec-menu").css('display', 'block');
- $(".wholeBody").css('overflow-y', 'hidden');
- $('.sec-menu-block').addClass('slidein');
- $('.sec-menu-block').removeClass('slideout');
- });
-
- $('.navbar-back').click(function(){
- $(".sec-menu").css('display', 'none');
- $(".wholeBody").css('overflow-y', 'scroll');
- $('.sec-menu-block').removeClass('slidein');
- $('.sec-menu-block').addClass('slideout');
- });
-
- $('.subexpand').click(function(){
- $(this).parent().next().toggleClass('show');
- $(this).parent().toggleClass('show');
- });
-
- $('.navbar-search').click(function(){
- $(".sec-search").css('display', 'block');
- $(".wholeBody").css('overflow-y', 'hidden');
- })
-
- $('.navbar-backs').click(function(){
- $(".sec-search").css('display', 'none');
- $(".wholeBody").css('overflow-y', 'scroll');
- });
- $('.navbar-back-fav').click(function(){
- $(".sec-favor").css('display', 'none');
- })
- $('.btn-gotop').click(function () {
- $('html, body').animate({
- scrollTop: 0
- }, 500)
- });
- $(window).scroll(function() {
- if ( $(this).scrollTop() > 500 ){
- $('.fixed-btn').fadeIn(222);
- $('.freeCall').fadeIn(222);
- } else {
- $('.fixed-btn').stop().fadeOut(222);
- $('.freeCall').stop().fadeOut(222);
- }
- }).scroll();
-
- const searchBtn = document.querySelector('.searchBtn');
- const searchBar = document.querySelector('.searchBar');
- const searchHotLink = document.querySelectorAll('.sec-search-hots__link');
- searchBtn.addEventListener('click', search);
- searchBar.addEventListener('keyup', pressSearch);
- function search() {
- if(searchBar.value == '') {
- window.location.href = 'https://m.hhh.com.tw/search/lists/case/';
- } else {
- window.location.href = `https://m.hhh.com.tw/search/lists/case/${searchBar.value}-keyword/`;
- }
- }
- function pressSearch(e) {
- if (e.keyCode === 13) {
- e.preventDefault();
- search();
- }
- }
- searchHotLink.forEach((item, i) => {
- item.addEventListener('click', function() {
- window.location.href = `https://m.hhh.com.tw/search/lists/case/${this.textContent}-keyword/`;
- })
- })
- document.addEventListener('lazybeforeunveil', function(e){
- var bg = e.target.getAttribute('data-bg');
- if(bg){
- e.target.style.backgroundImage = 'url(' + bg + ')';
- }
- });
- $('.mb__infoCard__more').click(function() {
- $(this).hide();
- $('.other').css('display', 'block');
- over = document.querySelector('.infoContent__navBlock').offsetTop;
- })
|