fgc.otherpage--s.js
6.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
function sendAjaxAddACTag(a) {
jQuery.ajax({
url: "/?action=" + a,
type: "POST",
success: function (a) {
}
})
}
jQuery(document).ready(function (a) {
pathname = window.location.pathname, "/tracked-delivery/" === pathname && jQuery(".button.set-tracked-delivery").click(function () {
addToCartLink = a("#add_to_cart_tracked").text(), jQuery.ajax({
type: "POST",
dataType: "html",
url: "/tracked-delivery/?cancelsubscription=yes",
success: function (a) {
window.location = currentsite + addToCartLink.replace("tracked-delivery/", "")
},
error: function () {
}
})
}), a(".page-template-our-drink").length > 0 && "undefined" != typeof a.cookie("message_free_sample_ac") && ($message_free_sample = a.cookie("message_free_sample_ac"), a("body article").prepend('<div id="message_free_sample">' + $message_free_sample + "</div>"), setTimeout(function () {
a("#message_free_sample").animate({
color: "#f8f7f6"
}, 500)
}, 1e5), a.removeCookie("message_free_sample_ac", {
path: "/"
})), a(".page-template-free-sample").length > 0 && (a("._form_element._field22 select").val("Website Landing Page"), a("body").on("click", "._submit", function () {
$email = a('input[name="email"]').val(), $i = 0;
var b = setInterval(function () {
"" !== a("._form-thank-you").text() && (a("._form-thank-you").html(""), a.ajax({
url: "/?action=getSuccessMessageFreeSampleForm&email=" + $email,
type: "POST",
success: function (b) {
location.href = "/our-drink/"
}
}), clearInterval(b)), $i++, $i > 1e3 && clearInterval(b)
}, 100)
})), a(".page-template-login_page").length > 0 && $isMobile && a('.tvbutton button[name="login"]').tap(function () {
a("html, body").animate({
scrollTop: 0
}, "slow")
}), jQuery("body.page-template-challenge_results").on("click", ".sd-content li .share-icon", function () {
// sendAjaxAddACTag("eventClickToShareChallenge")
}), a("body.home.page").length > 0 && setTimeout(function () {
a(".branding-img-container img").css("width", "60px")
}, 3e3), a(".page-template-free-sample-survey").length > 0 && (a(".entry-header").prepend('<h5 class="shop-step-title">STEP 2 OF 3</h5>'), jQuery(".page-template-free-sample-survey #free-survey-container iframe").on("load", function () {
jQuery("html, body").animate({
scrollTop: 0
}, "slow")
})), a(".page-template-free-sample").length > 0 && (a(".entry-header").prepend('<h5 class="shop-step-title">STEP 3 OF 3</h5>'), a('input[name="loginemail"]').length > 0 && a('input[name="email"]').val(a('input[name="loginemail"]').val()), a('input[name="firstname"]').length > 0 && a('input[name="fullname"]').val(a('input[name="firstname"]').val())), a("#free-sample-page").length > 0 && (a('button[type="submit"]').click(function () {
a("#free-sample-page").find("#checkout_loader_img").removeClass("hide"), a(".entry-content").css("opacity", "0.3")
}), a("._field-wrapper").on("DOMNodeInserted", "._error", function () {
a('input[type="text"]').hasClass("_has_error") && a("html, body").animate({
scrollTop: a("input._has_error").eq(0).offset().top - 25
}, "slow"), a("#free-sample-page").find("#checkout_loader_img").addClass("hide"), a(".entry-content").css("opacity", "1")
}))
/*add by fgc*/
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
function setCookie(name, value, options) {
options = options || {};
var expires = options.expires;
if (typeof expires == "number" && expires) {
var d = new Date();
d.setTime(d.getTime() + expires * 1000);
expires = options.expires = d;
}
if (expires && expires.toUTCString) {
options.expires = expires.toUTCString();
}
value = encodeURIComponent(value);
var updatedCookie = name + "=" + value;
for (var propName in options) {
updatedCookie += "; " + propName;
var propValue = options[propName];
if (propValue !== true) {
updatedCookie += "=" + propValue;
}
}
document.cookie = updatedCookie;
}
function deleteCookie(name) {
setCookie(name, "", {expires: -1})
}
//var l = window.location;
//var base_url = l.protocol + "//" + l.host;
// console.log(base_url);
// if(a('.page-template-free-sample-survey-form-php #gform_submit_button_2').length>0){
// // console.log(getCookie('tvnewsletterSubscribe'))
// a('.page-template-free-sample-survey-form-php').on("click",'#gform_submit_button_2',function(e){
// console.log("fgc"+getCookie('free_sample_survey_form'))
// if(typeof getCookie('free_sample_survey_form') !== "undefined" )
// {
// // alert("ko dc submit")
// console.log("da co cookies");
// e.preventDefault();
// window.location.href = base_url+'/thanks/';
// } else{
// //chua co cookies
// var days = 3650; // emulate never expire
// setCookie('free_sample_survey_form', 'yes', {
// expires: days * 86400,
// path: '/'
// });
// }//endif
// });
// }
var l = window.location;
var base_url = l.protocol + "//" + l.host;
//console.log(base_url);
if(a('.page-template-free-sample-survey-form-php #gform_submit_button_2').length>0){
console.log(getCookie('free_sample_survey_form'))
a('.page-template-free-sample-survey-form-php').on("click",'#gform_submit_button_2',function(e){
console.log("fgc"+getCookie('free_sample_survey_form'));
if(typeof getCookie('free_sample_survey_form') !== "undefined" ){
e.preventDefault();
// alert("ko dc submit")
//a.cookie
// deleteCookie('free_sample_survey_form');
window.location.href = base_url+'/thanks/';
} else{
var days = 3650; // emulate never expire
setCookie('free_sample_survey_form', 'yes', {
expires: days * 86400,
path: '/'
});
}
});
}
});