(function () { var page = Number($(document).find('[data-products-page-number]').attr('data-products-page-number') || 1); var clickType = 0; var prevPage = function prevPage(obj) { clickType = 1; page -= 1; changeUrl(); }; var nextPage = function nextPage(obj) { clickType = 1; page += 1; changeUrl(); }; var goPage = function goPage(obj, pageNum) { clickType = 1; page = pageNum; changeUrl(); }; window.prevPage = prevPage; window.nextPage = nextPage; window.goPage = goPage; var changeUrl = function changeUrl() { var curWwwPath = window.location.href; var pathName = window.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPath = curWwwPath.substring(0, pos); var queryString = checkedCategory.length > 0 ? '?c=' + checkedCategory.toString() : ''; if (queryString) { queryString = queryString + (clickType ? '&page=' + page : ''); } else { queryString = clickType ? '?page=' + page : ''; } var newUrl = localhostPath + pathName + queryString; window.location.href = newUrl; }; if ($('.swiper-natural-products').length > 0) { var mySwiper = new Swiper('.swiper-natural-products', { navigation: { nextEl: '.swiper-button-next-custom', prevEl: '.swiper-button-prev-custom' }, pagination: { el: '.swiper-pagination-custom', type: 'fraction' } }); } $.each($('.hot-main-tit .icon-angle-right'), function () { $(this).on('click', function () { $(this).parent('.hot-main-tit').toggleClass('btn-toggle'); $(this).parent('.hot-main-tit').parent().find('.list-more').slideToggle(200); }); }); var clearResult = function clearResult() { $('.result-list .close-small').on('click', function () { $('.result-list').html(''); }); }; var categoryType = $(document).find('[data-category-page-type]').attr('data-category-page-type') || ''; var categoryUrl = categoryType === 'modelProducts' ? 'induced-disease-model' : 'NaturalProducts'; $('#sourceSearchValue').on('keypress', function (e) { if (e.keyCode === 13) { var q = $('#sourceSearchValue').val(); if (q.trim() !== '') { $('#sourceSearchValue').removeClass("nonempty_submit"); $('#sourceSearch').attr('disabled', true); searchSource(q); } else { $('#sourceSearchValue').addClass("nonempty_submit"); } } }); $('#sourceSearch').on('click', function () { var q = $('#sourceSearchValue').val(); if (q.trim() !== '') { $('#sourceSearchValue').removeClass("nonempty_submit"); $('#sourceSearch').attr('disabled', true); searchSource(q); } else { $('#sourceSearchValue').addClass("nonempty_submit"); } }); var searchSource = function searchSource(q) { $.ajax({ url: '/otherCategory!searchCategory.shtml?mcenow=' + new Date().getTime(), data: { 'q': q, 'categoryType': categoryType }, cache: false, dataType: 'json', type: "post", success: function success(data) { if (data.success) { var categories = data.categories; if (categories != null && categories.length > 0) { var resultsHtml = '

Results for "' + q + '":

'; $('.result-list').html(resultsHtml); } else { $('.result-list').html('

No Results for "' + q + '":

'); } } else { $('.result-list').html('

No Results for "' + q + '":

'); } }, error: function error(request) { $('.result-list').html('

搜索失败,请稍后再试!

'); }, complete: function complete(XMLHttpRequest, textStatus) { $('#sourceSearch').attr('disabled', false); clearResult(); } }); }; var checkedCategory = []; var getCheckedCategory = function getCheckedCategory() { checkedCategory = []; if ($('.st-checkbox-group').length > 0) { $(".st-checkbox-group input[type='checkbox']:checked").each(function () { if (!checkedCategory.includes($(this).val().trim())) { checkedCategory.push($(this).val().trim()); } }); } else { $("#model-classification label").each(function () { var thisSignImg = $(this).find('img').attr('src'); if (thisSignImg.endsWith('yes1.gif')) { checkedCategory.push($(this).attr('data-category-name')); } }); } }; getCheckedCategory(); $("#model-classification label").on('click', function (e) { e.stopPropagation(); var thisSignImg = $(this).find('img').attr('src'); var flag = thisSignImg.endsWith('yes1.gif') ? 1 : 0; if (flag === 0) { $(this).find('img').attr('src', '/new/images/web/yes1.gif'); checkedCategory.push($(this).attr('data-category-name')); } else { $(this).find('img').attr('src', '/new/images/web/non.gif'); checkedCategory.splice($.inArray($(this).attr('data-category-name'), checkedCategory), 1); } console.log(checkedCategory.join()); clickType = 0; changeUrl(); }); var changeUrl2 = function changeUrl2() { getCheckedCategory(); var curWwwPath = window.location.href; var pathName = window.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPath = curWwwPath.substring(0, pos); var queryString = checkedCategory.length > 0 ? '?sc=' + checkedCategory.join(';') : ''; if (queryString) { queryString = queryString + (clickType ? '&page=' + page : ''); } else { queryString = clickType ? '?page=' + page : ''; } var newUrl = localhostPath + pathName + queryString; window.location.href = newUrl; }; var prevPage2 = function prevPage2(obj) { page -= 1; clickType = 1; changeUrl2(); }; var nextPage2 = function nextPage2(obj) { page += 1; clickType = 1; changeUrl2(); }; var goPage2 = function goPage2(obj, pageNum) { page = pageNum; clickType = 1; changeUrl2(); }; window.prevPage2 = prevPage2; window.nextPage2 = nextPage2; window.goPage2 = goPage2; if ($('.st-checkbox-group').length > 0) { $(".st-checkbox-group input[type='checkbox']").click(function () { page = 1; clickType = 0; changeUrl2(); }); } var $searchText = $('#standardsParam'); $searchText.on('keypress', function (e) { if (e.keyCode === 13) { searchBlog(); } }); $searchText.on('keydown', function (e) { if (e.keyCode === 13) { searchBlog(); } }); $(".btn-search-source").click(function () { searchBlog(); }); var searchBlog = function searchBlog() { var q = $searchText.val(); if (q.trim() == '') { $searchText.addClass("nonempty_submit"); } else { $(".btn-search-source").attr({ "disabled": "disabled" }); $.ajax({ url: '/otherCategory!searchStandardProducts.shtml?mcenow=' + new Date().getTime(), data: { 'q': q }, cache: false, dataType: 'json', type: "post", success: function success(data) { if (data.param !== '') { $searchText.removeClass("nonempty_submit"); window.open('/' + data.param + '.html', '_blank'); $searchText.val(''); } else { $searchText.addClass("nonempty_submit"); } }, error: function error(request) { $searchText.addClass("nonempty_submit"); }, complete: function complete(XMLHttpRequest, textStatus) { $(".btn-search-source").removeAttr("disabled"); } }); } }; })();