$.getCookie = function (c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start !== -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end === -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; } $.setCookie = function (c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toGMTString()) + "; path=/;"; } var NPSFrequency = 1; var NPSSent = 0; function NPSShow() { var JsonGetObj = {}; JsonGetObj.ApplicationName = JsonObj.ApplicationName; JsonGetObj.Source = JsonObj.Source; JsonGetObj.Section = JsonObj.Section; if ($.getCookie("NPS" + JsonGetObj.ApplicationName + JsonGetObj.Section) === "" && $.getCookie("NPSPremium" + JsonGetObj.ApplicationName + JsonGetObj.Section) === ""){ $.ajax({ type: "POST", url: "https://nps.publi24.ro/NPS/GetNPS", data: { JsonObj: JSON.stringify(JsonGetObj) }, success: function (data) { $("#nps").html(data.templateDiv); NPSFrequency = data.npsFrequency; if (data.renderNPS) { AfterNPSShow(); } }, error: function (error, status, headers, config) { } }); } } function NPSSend(success_msg, error_msg) { if (NPSSent === 0) { if ($('input[type=radio]:checked').length > 0) { JsonObj.Rating = $('input[type=radio]:checked').val(); JsonObj.Comment = JSON.stringify($('#npscomment').val()); NPSSent = 1; $.ajax({ type: "POST", url: "https://nps.publi24.ro/NPS/InsertNPS", data: { JsonObj: JSON.stringify(JsonObj) }, success: function (data) { $("#nps").html("
" + success_msg + "
"); $.setCookie("NPS" + JsonObj.ApplicationName + JsonObj.Section, 'true', NPSFrequency); AfterNPSSend(); }, error: function (error, status, headers, config) { NPSSent = 0; } }); } else { alert(error_msg); } } }