var isEurope = document.getElementById('isEurope'); var hasCookie = $.cookie("GDPR_cookie"); var iseuCookie = $.cookie('iseu'); var baseUrl = "https://www.playerauctions.com/"; var isEuUrl = baseUrl + 'api/ip/iseu'; var dataResult; //判断是否有iseu cookie存在 如果没有调用api if (iseuCookie == null || iseuCookie == undefined) { $.ajax({ type: 'GET', url: isEuUrl, success: function (data) { dataResult = data.isEU; }, error: function () {} }); } else { dataResult = JSON.parse($.cookie('iseu')).IsEU; } var IsEuropean = dataResult; var CookieSetting; //Disable All function disableAll() { GDPR_false(); display_cookie_session(); hiddenBox(); CookieSetting = "Disable"; sendCookieSet(); } //Allow All function allowAll() { GDPR_true(); display_cookie(); hiddenBox(); CookieSetting = "Allow"; sendCookieSet(); location.reload(); } //Accept cookies function acceptCookies() { GDPR_true(); display_cookie(); hiddenBox(); } //Save Settings function saveSettings() { if (dataResult == true) { if (($('input[id="agreeOne"]').is(":checked"))) { GDPR_true(); display_cookie(); hiddenBox(); CookieSetting = "Allow"; sendCookieSet(); location.reload(); } else { GDPR_false(); display_cookie_session(); hiddenBox(); CookieSetting = "Disable"; sendCookieSet(); } } else { if (($('input[id="agreeOne"]').is(":checked"))) { GDPR_true(); display_cookie(); hiddenBox(); } else { GDPR_false(); display_cookie_session(); hiddenBox(); CookieSetting = "Disable"; sendCookieSet(); location.reload(); } } } //click checked $('input[id="agreeOne"]').click(function () { if ($(this).is(":checked")) { $('input[class="agree-box"]').attr('checked', true); } else { $('input[class="agree-box"]').attr('checked', false); } }); $('input[id="agreeTwo"]').click(function () { if (dataResult == true) { if ($(this).is(":checked")) { GDPR_true(); $('input[class="agree-box"]').attr('checked', true); display_cookie(); location.reload(); CookieSetting = "Allow"; sendCookieSet(); } else { GDPR_false(); $('input[class="agree-box"]').attr('checked', false); display_cookie_session(); CookieSetting = "Disable"; sendCookieSet(); location.reload(); } } else { if ($(this).is(":checked")) { GDPR_true(); $('input[class="agree-box"]').attr('checked', true); display_cookie(); location.reload(); } else { GDPR_false(); $('input[class="agree-box"]').attr('checked', false); display_cookie_session(); CookieSetting = "Disable"; sendCookieSet(); location.reload(); } } }); //hidden popup function hiddenBox() { isEurope.style.display = "none"; } //check box if (hasCookie == "false") { $('input[class="agree-box"]').attr('checked', false); //no removeCookie('_ga', '_gcl_au', '_gid', '_uetvid', '_uetsid'); clearCookie('ai_session', 'ai_user', '__atuvs', '__atuvc'); } else if (hasCookie == "true") { $('input[class="agree-box"]').attr('checked', true); //yes } if ((hasCookie == "false") || (dataResult == true)) { //$('input[class="agree-box"]').attr('checked', false); //no //GDPR_false(); } else if ((hasCookie == "true") || (dataResult == false)) { $('input[class="agree-box"]').attr('checked', true); //yes GDPR_true(); } //send disable function sendCookieSet() { var cookieUrl = baseUrl + 'api/cookie/setting'; $.ajax({ url: cookieUrl, type: "POST", async: false, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data: { "IsEuropean": IsEuropean, "CookieSetting": CookieSetting }, success: function () {},error: function () {} }); } //set Cookie function GDPR_true() { setCookie('GDPR_cookie', 'true', GetCookieDomain()); } function GDPR_false() { document.cookie = 'GDPR_cookie=false' + ";expires=" + '' + ";domain=" + GetCookieDomain() + ";path = /"; } function display_cookie() { setCookie('display_cookie_popup', 'true', GetCookieDomain()); } function display_cookie_session() { document.cookie = 'display_cookie_popup=true' + ";expires=" + '' + ";domain=" + GetCookieDomain() + ";path = /"; } function setCookie(name, value, domain) { var Days = 365*3; var exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";domain=" + domain +";path = /"; } //cross Domain function GetCookieDomain() { var host = location.hostname; var ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; if (ip.test(host) === true || host === 'localhost') return host; var regex = /([^]*).*/; var match = host.match(regex); if (typeof match !== 'undefined' && null !== match) host = match[1]; if (typeof host !== 'undefined' && null !== host) { var strAry = host.split('.'); if (strAry.length > 1) { host = strAry[strAry.length - 2] + '.' + strAry[strAry.length - 1]; } } return '.' + host; } function clickagree(e) { if(!e.keyCode || e.keyCode == "13" || e.keyCode == "32" ) { $(".setting-text").find(".arrow-drop-down").toggleClass("active-down"); if ($(".all-table-con").css("display") == "none") { $(".all-table-con").css("display", "flex"); } else { $(".all-table-con").css("display", "none"); } //change save btn if ($(".saveBtn").css("display") == "none") { $(".defaultBtn").css("display", "none"); $(".saveBtn").css("display", "inline-block"); } else { $(".defaultBtn").css("display", "inline-block"); $(".saveBtn").css("display", "none"); } } } $(".setting-text").on("click", clickagree) $(".setting-text").on("keyup", clickagree ) //click Cookie Settings and Details //click Essential Cookies (Performance and Operations) Details function essentialDetails(e) { if(!e.keyCode || e.keyCode == "13" || e.keyCode == "32" ) { $(this).find(".arrow-drop-down").toggleClass("active-down"); $(".analytics-details").find(".arrow-drop-down").removeClass("active-down"); $(".order-two").toggle(); $(".order-four").hide(); } } $(".essential-details").on("click", essentialDetails); $(".essential-details").on("keyup", essentialDetails); //click Analytics & Marketing Details $(".analytics-details").click(function () { $(this).find(".arrow-drop-down").toggleClass("active-down"); $(".essential-details").find(".arrow-drop-down").removeClass("active-down"); $(".order-four").toggle(); $(".order-two").hide(); }); //removeCookie function removeCookie(...obj) { for (var i = 0; i < obj.length; i++) { $.removeCookie(obj[i], { domain: GetCookieDomain(), path: '/' }); } } function clearCookie(...val) { for (var j = 0; j < val.length; j++) { $.removeCookie(val[j], { path: '/' }); } }