var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } return false; }; var page = getUrlParameter('page'); $(document).ready(function() { if (window.location.pathname === '/top-brokers') { if (page) { $("html, body").animate({ scrollTop: "4300px" }); } } }); $(document).ready(function(e) { var timeout; var delay = 600; $('#search').keyup(function(e) { search_value = $(this).val(); $('#itemSearch').removeClass('noFocus'); $('#closebtn').click(function(e) { search_value = ''; $('#search').val(''); $('#itemSearch').html(''); $('#searchbtn').css('opacity', '1'); $('#closebtn').css('opacity', '0'); }); if (search_value !== "") { $('#searchbtn').css('opacity', '0'); if (timeout) { clearTimeout(timeout); } if (search_value === "") { clearTimeout(timeout); } timeout = setTimeout(function() { myFunction(search_value); }, delay); $('#closebtn').css('opacity', '1'); } else { $('#itemSearch').html(''); $('#closebtn').css('opacity', '0'); // $('body').css('overflow', 'auto'); } }); function myFunction(value) { if (value !== "" & value.length >= 2) { $.ajax({ type: 'GET', url: 'https://www.thaiforexreview.com/search', data: { 'search': value }, success: function(data) { $('#itemSearch').html(data); // $('body').css('overflow', 'hidden'); }, error: function(err) { console.log('Error' + err); }, }); $.ajaxSetup({ headers: { 'csrftoken': 'aoSgbnqXwQxIGPr1nRuCaCHltA58H343ftN7p9FN' }, }); } } $('#search').on('click', function() { $('#itemSearch').removeClass('noFocus'); }); $('#searchBroker').on('click', function() { $('#boxBrokerSearch').toggle(); }); $('#boxBrokerSearch').mouseleave(function() { $('#boxBrokerSearch').css('display', 'none'); }) $(document).on('click', function() { $('#itemSearch').addClass('noFocus'); }) }); $('#searchBroker').on('keyup', function() { search_value = $(this).val(); $(".test").each(function() { if ($(this).attr('id').toLowerCase().startsWith(search_value)) { $(this).addClass('show') $(this).removeClass('not-show') } else { $(this).addClass('not-show') $(this).removeClass('show') } }); }); function clearSearch() { if (debounce != null) { debounce.abort(); } $('#search').val(""); $('#itemSearch').html(''); }; $.ajaxSetup({ headers: { 'csrftoken': 'aoSgbnqXwQxIGPr1nRuCaCHltA58H343ftN7p9FN' } }); $(document).ready(function() { $('.one-time').slick({ autoplay: false, dots: true, infinite: true, speed: 2000, slidesToShow: 1, // adaptiveHeight: true, }); $(window).scroll(function(e) { var scrollTop = $(window).scrollTop(); var docHeight = $(document).height(); var winHeight = $(window).height(); var scrollPercent = (scrollTop) / (docHeight - winHeight); var scrollPercentRounded = Math.round(scrollPercent * 100); $('#scrollPercentLabel').css('width', `${scrollPercentRounded}%`); $('#itemSearch').addClass('noFocus'); $('#boxBrokerSearch').addClass('noFocus'); }); });