锘縱ar inquiryurl = "/inquiry.aspx"; var cbsid = []; var page = 1; var isLoad = false; var pageCount = 0; $(function () { delCookie("merge"); $(window).scroll(function () { var scrollTop = $(this).scrollTop(); if (scrollTop > 150) { $("#dv_head_float").show(); } else { $("#dv_head_float").hide(); } }); $("#float_search_btn_hide").click(function () { var kwd = $("#float_search_text").val(); window.location = "/ProductList_EN.aspx?kwd=" + encodeURIComponent(kwd); }) $("#float_search_btn").click(function () { $("#float_search_btn_hide").trigger("click"); }); $("#float_search_text").keyup(function (event) { var which = event.which; if (which == 13) { $("#float_search_btn_hide").trigger("click"); } }); //Set default value //Japan $("#float_search_btn_hide_JP").click(function () { var kwd = $("#float_search_text_JP").val(); window.location = "/ProductList_JP.aspx?kwd=" + encodeURIComponent(kwd); }) $("#float_search_btn_JP").click(function () { $("#float_search_btn_hide_JP").trigger("click"); }); $("#float_search_text_JP").keyup(function (event) { var which = event.which; if (which == 13) { $("#float_search_btn_hide_JP").trigger("click"); } }); //Set default value $("#float_search_text").val(getSearchKeyWord()); $(".search_str").click(function () { location.href = "/StructuredSearch_EN.htm"; }); //Increase paging url $("a[data-page-number]").each(function () { var nm = $(this).attr("data-page-number"); var url = getUrl("page", nm); $(this).attr("href", url); }); $(".Fil_l").on("click", "li", function () { var data = $(this).data(); if ($(this).hasClass("Sel_h")) { $(this).removeClass("Sel_h"); window.location.href = removeUrlSearch("page", removeUrl(data.key)); } else { $(this).addClass("Sel_h"); window.location.href = removeUrlSearch("page", getUrl(data.key, data.name)); } }); $("#bt_delegate_list").click(function () { var cas = $("#bt_delegate_list").attr("data-cas"); var productname = $("#bt_delegate_list").attr("data-productname"); cbnumber = $("#bt_delegate_list").attr("data-cbnumber"); source = $("#bt_delegate_list").attr("data-source") == "" ? "pageleft" : $("#bt_delegate_list").attr("data-source"); location.href = "/InquiryToSupplier.aspx?cas=" + cas + "&n=" + productname + "&cbnumber=" + cbnumber + "&source=" + source; }); $(".Sel_O").click(function (event) { var $target = $(event.target); if ($target.hasClass("Fmore")) { var data = $target.data(); if (data.expend) { var $conditionElement = $(this).parent(); var condition = new Conditions($conditionElement, $target); if (data.expend == "multiple") { condition.multiple(); } else { condition.more(); } } } else if ($target.hasClass("Sel_dx")) { var data = $target.parent().data(); if (data.expend) { var $conditionElement = $(this).parent(); var condition = new Conditions($conditionElement, $target.parent()); if (data.expend == "multiple") { condition.multiple(); } } } else if ($target.get(0).tagName == "INPUT") { var data = $target.data(); if (data.operator) { var $conditionElement = $target.parent(); var condition = new Conditions($conditionElement, $target); if (data.operator == "save") { condition.multipleSearch(); } else { condition.expend(); } } } else if ($target.get(0).tagName == "LI" || $target.get(0).tagName == "A") { var $conditionElement = $(this).parent(); var condition = new Conditions($conditionElement, $target); condition.singSearch($conditionElement, $target); } }); displaySearchConditions(); $(".Sel_Y").on("click", "b[data-key]", function () { var $target = $(this); $target.parent().remove(); window.location.href = removeUrl($target.attr("data-key")); }); var userName = $("#cookie_userName").val(); if (userName != null) { getMyAccount(); } var $Sel = $(".Sel_O"); var cwidth = 0; for (var i = 0; i < $Sel.length; i++) { cwidth = 0; var $curSel = $("#Sel" + i); $curSel.find("li").each(function () { cwidth += $(this).width() + 20; if (cwidth > 730) { $curSel.find("span[data-expend='more']").show(); } else { $curSel.find("span[data-expend='more']").hide(); } }); } $("a[data-source='ch']").attr("href", "/ProductIndex.aspx"); $("a[data-source='en']").attr("href", "/ProductIndex_EN.aspx"); $("a[data-source='jp']").attr("href", "/ProductIndex_JP.aspx"); $("a[data-source='de']").attr("href", "/ProductIndex_DE.aspx"); $("a[data-source='kr']").attr("href", "/ProductIndex_KR.aspx"); bindEvent(); var showPage = $("#showPage").val(); var path = location.href; if (showPage == "False" && path.indexOf("/Manufacturers/") > -1) { loadPage(); } }) //Multi-selection vendor displays selected quantity labels function mergeShow(m) { var $merge = $(".Merge").clone(); $merge.attr("style", "").attr("data-merge", true); $merge.attr("style", ""); $merge.find(".arrow_cho").after("Contact " + cbsid.length + "/5 Suppliers"); $merge.find(".mergebox2").click(function () { setCookie("merge", cbsid.join(","), "d1"); var delegate = $("#bt_delegate_list"); var cas = delegate.attr("data-cas"); var cbnumber = delegate.attr("data-cbnumber"); var productname = delegate.attr("data-productname"); var source = "ProductList_Supplier_Multi"; location.href = "/InquiryToSupplier.aspx?cas=" + cas + "&n=" + encodeURIComponent(productname) + "&cbnumber=" + cbnumber + "&source=" + source; }); m.after($merge); } //Function: Get url address function getUrl(name, value) { var search = window.location.search; value = escape(value); if (search) { var searchs = search.replace(/\?/g, "").split("&"); var repeater = false; for (var i = 0; i < searchs.length; i++) { if (searchs[i].indexOf(name + "=") == 0) { searchs[i] = name + "=" + value; repeater = true; break; } } if (!repeater) { searchs.push(name + "=" + value); } return window.location.href.replace(search, "?" + searchs.join("&")); } else { //http://book.hg.y866.cn/chemistry/Manufacturers/2-3-Bromophenyl-1-3-dioxolane.htm //http://localhost:2755/Manufacturers/2-3-Bromophenyl-1-3-dioxolane-97/2.htm if (window.location.href.split('/').length == 5) { var url = ""; if (value == 1) { url = "/" + window.location.href.split('/')[3] + "/" + window.location.href.split('/')[4].replace('.htm', '') + ".htm"; } else { url = "/" + window.location.href.split('/')[3] + "/" + window.location.href.split('/')[4].replace('.htm', '') + "/" + value + ".htm"; } return url; } else { var url = ""; if (value == 1) { url = "/" + window.location.href.split('/')[3] + "/" + window.location.href.split('/')[4].replace('.htm', '') + ".htm"; } else { url = "/" + window.location.href.split('/')[3] + "/" + window.location.href.split('/')[4].replace('.htm', '') + "/" + value + ".htm"; } return url; } } }; //Function: delete url address function removeUrlSearch(name, url) { var patter = "&" + name + "=[^&#]+"; return url.replace(new RegExp(patter), ""); }; function removeUrl(name, url) { var search = window.location.search; if (search) { var searchs = search.replace(/\?/g, "").split("&"); var index = -1; for (var i = 0; i < searchs.length; i++) { if (searchs[i].indexOf(name + "=") == 0) { index = i; break; } } if (index > -1) { searchs.splice(index, 1); } if (searchs.length > 0) { return window.location.href.replace(search, "?" + searchs.join("&")); } else { return window.location.href.replace(search, ""); } } } //Display query conditions function displaySearchConditions() { var parameters = getSearchParameters(); if (parameters.length == 0) { $(".Sel_Y").hide(); } else { var simepleQuery = ""; for (var i = 0; i < parameters.length; i++) { var parameter = parameters[i]; if (parameter.key != 'left') { $(".Sel_Y ul").append("
  • " + parameter.name + "
  • "); } //Comprehensive search $("li[data-key='" + parameter.key + "']").each(function () { var text = $(this).text(); var name = $(this).attr("data-name").toLocaleLowerCase(); if (name == parameter.value.toLocaleLowerCase()) { $(this).toggleClass("Sel_h"); return false; } }) } } } //Function: Get the query parameter value function getSearchParameters() { var search = window.location.search; var parameters = []; if (search) { var searchs = search.replace(/\?/g, "").split("&"); //Letters or letters + numbers are dynamic query conditions, two letters are fixed queries for (var i = 0; i < searchs.length; i++) { var parameter = searchs[i].split("="); var key = parameter[0]; var name = unescape(parameter[1]).replace("<", "").replace(">", "").replace("script", "").replace(/\|/g, "銆?); var value = name; switch (key) { case "ec": switch (name) { case "1": name = "Bulk"; break; } break; case "st": name = "In Stock"; break; case "hp": name = "Price"; break; case "pt": name = "Bulk"; break; default: name = name.replace("<", "").replace(">", "").replace("script", "").replace(/\|/g, "銆?); break; } var patter = /^(?:cbn|kwd|page)$/i; if (!patter.test(key)) { parameters.push({ key: key, name: name, value: value }); } } } return parameters; } function Conditions(containerElement, targetElement) { var _containerElement = containerElement; var _targetElement = targetElement; this.more = function () { var moreClass = "Sel_more"; _containerElement.toggleClass(moreClass); if (_containerElement.hasClass(moreClass)) { targetElement.parent().html('Lessmultiselect'); } else { targetElement.parent().html('Moremultiselect'); } }, this.multiple = function () { targetElement.parent().hide(); var moreClass = "Sel_more"; if (_containerElement.hasClass(moreClass)) { _containerElement.removeClass(moreClass); targetElement.parent().html('Lessmultiselect'); } _containerElement.toggleClass("Sel_multiple"); }, this.expend = function () { _containerElement.parent().parent().removeClass("Sel_multiple"); _containerElement.prev().show() }, this.multipleSearch = function () { var key, name; var $selected = _containerElement.parent().find(".Sel_h [data-key]"); if ($selected.length == 0) { $selected = _containerElement.parent().find(".Sel_h[data-key]"); } $selected.each(function () { var data = $(this).data(); key = data.key; if (name) { name += "|" + data.name; } else { name = data.name; } }); if (key && name) { window.location.href = removeUrlSearch("page", getUrl(key, name)); } }, this.singSearch = function () { if (_containerElement.hasClass("Sel_multiple")) { targetElement.toggleClass("Sel_h"); //Activate OK button var selectedLength = _containerElement.find(".Sel_h").length; var $save = _containerElement.find(":button[data-operator='save']"); if (selectedLength > 0) { $save.prop("disabled", false); } else { $save.prop("disabled", true); } } else { var data = targetElement.data(); var redirectUrl = getUrl(data.key, data.name); if (redirectUrl.lastIndexOf("#J_Condition") == -1) { var urlStr = redirectUrl.split('?')[0]; var tag = urlStr.lastIndexOf("/") + 1; var mm = urlStr.length - 5; var urlName = urlStr.substring(tag, mm); if (urlName.toUpperCase() == 'PRODUCTLIST_SUPPLIER') { redirectUrl += "&left=" + $("#isShowLeft").val(); } redirectUrl = redirectUrl + "#J_Condition"; } window.location.href = removeUrlSearch("page", redirectUrl); } }; } function getMyAccount() { $.ajax({ url: "/UserProfile/GetMyAccount.ashx", dataType: "json", cache: false, success: function (json) { if (json != 0) { var count = json.InquiryCoutn + json.Quotation; if (count > 0) { $(".UserNo").text(count); $(".UserNo").show(); } else { $(".UserNo").hide(); } } else { $(".UserNo").hide(); } } }); } function getSearchKeyWord() { var search = window.location.search; if (search) { var reg = new RegExp(/kwd=([^&]+)/); var matchs = reg.exec(search); if (matchs != null && matchs.length >= 2) { return decodeURIComponent(matchs[1]).replace("<", "").replace(">", "").replace("script", "").replace("'", "").replace("\"", ""); } } return ""; }; function bindEvent() { $(".pageGo").click(function () { var no = $(".pageNo").val(); if (parseInt(no) > 0) { location.href = getUrl("page", no); } }); $("a[data-field='enterprise']").mouseover(function () { var enterprise = $(this); var number = $(enterprise).attr("data-number"); var security = $(enterprise).find(".Securityopen"); if (security.length > 0) { $(security).css("visibility", "visible"); } else { var shtml = ""; $.post("/Handler/GetEnterpriseImg.ashx", { number: number }, function (result) { if (result.length > 0) { shtml += '
    '; shtml += '

    Enterprise Certification

    '; shtml += '
    '; shtml += '
    '; shtml += '
    '; shtml += '

    verified

    From:' + result[0].InputTime + '

    '; shtml += '
    '; shtml += '
    '; shtml += '
    '; shtml += ' '; shtml += ' '; for (var i = 0; i < result.length; i++) { shtml += ' '; } shtml += ' '; shtml += '
    '; shtml += '
    '; shtml += '
    '; shtml += '
    '; shtml += '
    '; } $(enterprise).append(shtml); $(enterprise).find("input[data-field='enterprise']").unbind("click"); $(enterprise).find("input[data-field='enterprise']").click(function () { location.href = "/EnterpriseCertification_EN_" + number + ".htm"; }); var security = $(enterprise).find(".Securityopen"); (security).css("visibility", "visible"); }, "json"); } }) $("a[data-field='enterprise']").mouseout(function () { var security = $(this).find(".Securityopen"); if (security != null) { $(security).css("visibility", "hidden"); } }) $(":input[data-field='cbsid']").click(function () { if ($(this)[0].checked) { if (cbsid.length >= 5) { alert("Select 5 suppliers at most!") return false; } cbsid.push($(this).attr("data-cbsid")); if (cbsid.length >= 1) { $("div[data-merge='true']").remove(); mergeShow($(this)); } } else { cbsid.removeByValue($(this).attr("data-cbsid")); $("div[data-merge='true']").remove(); if (cbsid.length >= 1) { var lastid = cbsid[cbsid.length - 1]; var lastCheckBox = $(":input:checkbox[data-cbsid='" + lastid + "']"); mergeShow(lastCheckBox); } } }); $(":input[data-field='inquiry']").click(function () { var cas = $("#bt_delegate_list").attr("data-cas"); var cbnumber = $(this).attr("data-cbnumber"); var productname = $(this).attr("data-product-name"); var cbsid = $(this).attr("data-cbsid"); var source = "ProductList_Supplier"; setCookie("merge", cbsid, "d1"); location.href = "/InquiryToSupplier.aspx?cas=" + cas + "&n=" + encodeURIComponent(productname) + "&cbnumber=" + cbnumber + "&source=" + source; }); $("a[data-field='prev']").click(function () { var imgs = $(this).parent().parent().find("img[data-field='img']"); var curr_i = 0; for (var i = 0; i < imgs.length; i++) { if ($(imgs[i]).hasClass("current_i")) { $(imgs[i]).hide(); $(imgs[i]).removeClass("current_i"); curr_i = i; } } if (curr_i == 0) { $(imgs[imgs.length - 1]).show(); $(imgs[imgs.length - 1]).addClass("current_i"); } else { $(imgs[curr_i - 1]).show(); $(imgs[curr_i - 1]).addClass("current_i"); } }) $("a[data-field='next']").click(function () { var imgs = $(this).parent().parent().find("img[data-field='img']"); var curr_i = 0; for (var i = 0; i < imgs.length; i++) { if ($(imgs[i]).hasClass("current_i")) { $(imgs[i]).hide(); $(imgs[i]).removeClass("current_i"); curr_i = i; } } if (curr_i == imgs.length - 1) { $(imgs[0]).show(); $(imgs[0]).addClass("current_i"); } else { $(imgs[curr_i + 1]).show(); $(imgs[curr_i + 1]).addClass("current_i"); } }) } function ChemBookImgPath(path) { path = path.replace("\\", "/"); var array = path.split('/'); var tempi = 0; if (array[0].indexOf("http") > -1) { tempi = 3; } else if (array[0].indexOf(":") > -1) { tempi = 2; } var listPath = []; for (var i = tempi; i < array.length; i++) { var value = array[i]; if (value != "") { listPath.push(value); } } return "http://hg.y866.cn/chemistry/lib/img/" + listPath.join("/"); } function loadPage() { var html = ""; var pages = $("#pages").val(); if (pages > 1) { var prev = parseInt(page) - 1; var next = parseInt(page) + 1; if (prev < 1) { prev = 1; } if (next > pages) { next = pages; } html += `
    `; html += `
    `; html += ` Go to Page
    `; } if (html != "") { $(".pageBox").remove(); $(".Rightbox").after(html); $(".pageBox a").click(function () { page = $(this).attr("data-page-number"); loadProducts(); }); $(".pageGo").click(function () { var no = $(".pageNo").val(); if (parseInt(no) > 0 && parseInt(no) <= pages) { page = no; loadProducts(); } }); } } function loadProducts() { if (isLoad) { return; } if (pageCount > 0 && page > pageCount) { return; } isLoad = true; $.ajax({ type: "GET", contentType: "application/json", url: "/Handler/GetManufacturersProduct.ashx", data: { kwd: $("#keyword1").val(), page: page }, dataType: "json", success: function (result) { isLoad = false; if (result.Products.length > 0) { var html = ""; var product = result.Products; pageCount = result.Pages; for (var i = 0; i < product.length; i++) { html += `
    `; if (product[i].EnterpriseExhibitionBoothID != 0 && product[i].EnterpriseExhibitionBoothName != "") { html += `

    ` + product[i].Supplier.SupplierName + `

    `; } else { html += ` ` + product[i].Supplier.SupplierName + `` } html += `
    `; if (product[i].Supplier.IsGold || (product[i].Supplier.IsPhysical && product[i].Supplier.IsAuthentication) || (product[i].EnterpriseExhibitionBoothID != 0 && product[i].EnterpriseExhibitionBoothName != "") || (product[i].IsGMP) || (product[i].IsManufacturer > 0) || (product[i].ProductThroughTrain)) { html += `
    ` } if (product[i].Supplier.IsGold) { html += `Gold Member`; } if (product[i].Supplier.IsPhysical && product[i].Supplier.AuthenticationSignStatus>0) { html += `Enterprise Certification`; } if (product[i].IsGMP) { html += `GMP`; } if (product[i].IsManufacturer > 0) { html += ``; } if (product[i].Supplier.IsGold || (product[i].Supplier.IsPhysical && product[i].Supplier.IsAuthentication) || (product[i].EnterpriseExhibitionBoothID != 0 && product[i].EnterpriseExhibitionBoothName != "") || (product[i].IsGMP) || (product[i].IsManufacturer > 0) || (product[i].ProductThroughTrain)) { html += `
    `; } html += `
    `; if (product[i].IsShowProductImg && product[i].ChemBookProductOfSourceType == 6 && product[i].ProductImg != "") { html += ``; } else { if (product[i].Supplier.LogoImg != "") { html += ``; } else { html += `
    `; } } html += `
    `; if (product[i].ChemBookProductOfSourceType != 6) { if (product[i].PackAges != null && product[i].PackAges.length > 0) { var UsdPrice = false; for (var j = 0; j < product[i].PackAges.length; j++) { if (product[i].PackAges[j].Currency == "USD") { UsdPrice = true; break; } } html += `
    `; html += `
      `; html += `
    • `; for (var j = 0; j < product[i].PackAges.length; j++) { var packAge = product[i].PackAges[j]; if (packAge.Currency == "USD") { html += `
      ` + packAge.Grade + `$` + packAge.Price + `
      `; } else { html += ``; } } html += `
    • `; html += `
    `; html += `
    `; } } html += `
      `; if (product[i].ChemBookProductOfSourceType == 6) { if (product[i].PackAges != null && product[i].PackAges.length > 0) { var MinPrice = ""; var MaxPrice = ""; if (product[i].PackAges.length > 1) { MinPrice = product[i].PackAges[0].Price; MaxPrice = product[i].PackAges[product[i].PackAges.length - 1].Price; html += `

      $`+ MinPrice + `-` + MaxPrice + ` /`+ product[i].PackAges[0].Grade + `

      `; } else { MinPrice = product[i].PackAges[0].Price; html += `

      $`+ MinPrice + `/` + product[i].PackAges[0].Grade + `

      `; } } } if (product[i].EnglishName != "") { if (product[i].ChemBookProductOfSourceType == 6) { html += `
    • Product Name:` + product[i].EnglishName + `
    • `; } else { html += `
    • Product Name:` + product[i].EnglishName + `
    • `; } } if (product[i].Remark != "") { html += `
    • Products Intro:` + product[i].Remark + `
    • `; } if (product[i].Supplier.Type) { html += `
    • Company Type: ` + product[i].Supplier.Type + `
    • `; } if (product[i].Supplier.SNationality != "") { html += `
    • Country/Region: ` + product[i].Supplier.SNationality.toUpperCase() + `
    • `; } var productStr = ""; if (product[i].Supplier.MainProductOrService != "") { for (var k = 0; k < product[i].Supplier.MainProductOrService.split('锔?).length; k++) { if (product[i].Supplier.MainProductOrService.split('锔?)[k].indexOf('驴') > -1 && product[i].Supplier.MainProductOrService.split('锔?)[k].split('驴')[1].split(',').length > 1) { var KWD = ""; var orderId = ""; var prodEname = ""; var Str = product[i].Supplier.MainProductOrService.split('锔?)[k].split('驴')[1].split(','); var num = Str.length; if (num > 1) { if (Str[num - 1].length > 50) { if (Str[num - 3] != null && Str[num - 3] != "") { KWD = Str[num - 3]; orderId = Str[num - 5]; } else { KWD = Str[num - 2]; orderId = Str[num - 6]; } } else { KWD = Str[num - 1]; orderId = Str[num - 4]; } if (num > 7) { for (var l = 0; l <= num - 7; l++) { prodEname += Str[l] + ","; } } else { prodEname = Str[num - 7]; } } var orderIdInt = 1; if (isNaN(orderId)) { orderIdInt = parseInt(orderId); } if (orderIdInt > 1) { productStr += "" + product[i].Supplier.MainProductOrService.split('锔?)[k].split('驴')[0] + ","; } else { productStr += "" + product[i].Supplier.MainProductOrService.split('锔?)[k].split('驴')[0] + ","; } } else { if (product[i].Supplier.MainProductOrService.split('锔?)[k]) { productStr += product[i].Supplier.MainProductOrService.split('锔?)[k].split('驴')[0] + ","; } } } } productStr = productStr.substring(0, productStr.lastIndexOf(",")); if (productStr != "") { html += `
    • Main Products: ` + productStr + `
    • `; } html += `
    `; } $(".Rightbox").html(""); $(".Rightbox").append(html); $(":input[data-field='cbsid']").unbind("click"); $(":input[data-field='inquiry']").unbind("click"); $("a[data-field='prev']").unbind("click"); $("a[data-field='next']").unbind("click"); $("a[data-field='enterprise']").unbind("mouseover"); $("a[data-field='enterprise']").unbind("mouseout"); bindEvent(); loadPage(); document.documentElement.scrollTop = document.body.scrollTop = 0; } } }) } function ConvertToProductImageEn(img) { if (!img) { return "http://hg.y866.cn/chemistry/lib/img/applet/images/noimg.gif?v=1"; } img = img.replace(/\\/g, "/"); if (img.indexOf("http://hg.y866.cn/chemistry/lib/img") >= 0) { img = img.replace("http://hg.y866.cn/chemistry/lib/img", ""); } if (img.indexOf("ProductImageEN") < 0) { img = "/ProductImageEN/" + img; } img = img.replace(/[/]+/g, "/"); if (img.toLowerCase().indexOf("/large/") < 0 && img.toLowerCase().indexOf("/raw/") < 0 && img.toLowerCase().indexOf("/small/") < 0 && img.toLowerCase().indexOf("http://") < 0) { img = ReplaceAddLargeImg_ProductImageEn(img); } img = ReplaceLargeImg_ProductImageEn(img); if (img.indexOf("http") < 0) { if (img[0] != "/") { img = "/" + img; } img = "http://hg.y866.cn/chemistry/lib/img" + img; } return img; } function ReplaceLargeImg_ProductImageEn(img) { var arr = img.split("/"); arr.splice(arr.length - 2, 1, "Large"); return arr.join("/"); } function ReplaceAddLargeImg_ProductImageEn(img) { var arr = img.split("/"); arr.splice(arr.length - 1, 0, "Large"); return arr.join("/"); }