fgc.otherpages.js
8.12 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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;
////var current_url = base_url+ "/" + l.pathname.split('/')[1];
////console.log(current_url);
// //console.log(base_url);
// //check page survey-form load
//// if(document.cookie.indexOf("no") == -1) /* B�? dòng này thì nó hiện thông báo liên tục mỗi khi mở web lên rất là phi�?n */
//// {
//// document.cookie = "survey=no";
//// /*do some thing*/
//// }
// var check_exit_page = a('#survey-form').length;
// if(a('.page-template-free-sample-survey-form-php #gform_submit_button_2').length>0){
// var cookieName = 'firstPageLoad';
// var cookieValue = 1;
// console.log(a.cookie('mycookie'));
// a('.page-template-free-sample-survey-form-php').on("click",'#gform_submit_button_2',function(e){
// var check_error=a('#gform_wrapper_2 #gform_2 .validation_error').length;
// var check_exit_page = a('#survey-form').length;
// console.log(check_error);
// //check cookies
// if(check_error <= 0 ){//ko co loi
// console.log('ko co loi');
// if(document.cookie.indexOf('mycookie')==-1) {
// // cookie doesn't exist, create it now
// document.cookie = 'mycookie=1';
// }
// }else{//co loi and have cookies then don't submit
// if((document.cookie.indexOf('mycookie')!=-1)) {
// return true;
// }
// // cookie exist, create it now
//
// }
//
// if((check_error <= 0 ) && (document.cookie.indexOf('mycookie')!=-1)){//ko loi va co cookie thi redirect thank page
// window.location.href = base_url+'/thanks/';
// }
//
// if((check_error > 0 ) && (document.cookie.indexOf('mycookie')!=-1)){//ko loi va co cookie thi redirect thank page
// window.location.href = base_url+'/thanks/';
// }
//
// });
// }
if(a('.page-template-our-drink-php').length>0 && a.urlParam('submit')=='1'){
a.cookie("thank_survey_form", 1, {expires: 360, path: '/'});
}
//a('.page-template-free-sample-survey-form-php').on("click",'#gform_submit_button_2',function(e){
// if (typeof a.cookie('thank_survey_form') !== 'undefined') {
// e.preventDefault();
// window.location.href = '/thanks/';
// }
//
//});
});
jQuery.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
if (results==null){
return null;
}
else{
return results[1] || 0;
}
}