tourTip.js
7.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
if(! window['wordfenceExt']){
window['wordfenceExt'] = {
nonce: false,
loadingCount: 0,
init: function(){
this.nonce = WordfenceAdminVars.firstNonce;
},
showLoading: function(){
this.loadingCount++;
if(this.loadingCount == 1){
jQuery('<div style="padding: 2px 8px 2px 24px; z-index: 100000; position: fixed; right: 2px; bottom: 2px; border: 1px solid #000; background-color: #F00; color: #FFF; font-size: 12px; font-weight: bold; font-family: Arial; text-align: center;" id="wordfenceWorking">Wordfence is working...</div>').appendTo('body');
}
},
removeLoading: function(){
this.loadingCount--;
if(this.loadingCount == 0){
jQuery('#wordfenceWorking').remove();
}
},
autoUpdateChoice: function(choice){
this.ajax('wordfence_autoUpdateChoice', {
choice: choice
},
function(res){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); },
function(){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); }
);
},
adminEmailChoice: function(choice) {
this.ajax('wordfence_adminEmailChoice', {
choice: choice
},
function(res){ jQuery('#wordfenceAdminEmailWarning').fadeOut(); },
function(){ jQuery('#wordfenceAdminEmailWarning').fadeOut(); }
);
},
suPHPWAFUpdateChoice: function(choice) {
this.ajax('wordfence_suPHPWAFUpdateChoice', {
choice: choice
},
function(res){ jQuery('#wordfenceSuPHPUpdateWarning').fadeOut(); },
function(){ jQuery('#wordfenceSuPHPUpdateWarning').fadeOut(); }
);
},
misconfiguredHowGetIPsChoice : function(choice) {
this.ajax('wordfence_misconfiguredHowGetIPsChoice', {
choice: choice
},
function(res){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); },
function(){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); }
);
},
ajax: function(action, data, cb, cbErr, noLoading){
if(typeof(data) == 'string'){
if(data.length > 0){
data += '&';
}
data += 'action=' + action + '&nonce=' + this.nonce;
} else if(typeof(data) == 'object'){
data['action'] = action;
data['nonce'] = this.nonce;
}
if(! cbErr){
cbErr = function(){};
}
var self = this;
if(! noLoading){
this.showLoading();
}
jQuery.ajax({
type: 'POST',
url: WordfenceAdminVars.ajaxURL,
dataType: "json",
data: data,
success: function(json){
if(! noLoading){
self.removeLoading();
}
if(json && json.nonce){
self.nonce = json.nonce;
}
cb(json);
},
error: function(){
if(! noLoading){
self.removeLoading();
}
cbErr();
}
});
}
};
}
jQuery(function(){
wordfenceExt.init();
});
if(! window['wordfenceTour']){
window['wordfenceTour'] = {
wfClearEmailField: function(){
if(jQuery('#wfListEmail').val() == "Enter your email"){
jQuery('#wfListEmail').val('');
}
},
processEmailClick: function(evt){
var email = jQuery('#wfListEmail').val();
if(! /[^\@]+\@[^\.]+\.[^\.]+/.test(email)){
alert("Please enter a valid email address.");
return false;
}
jQuery.ajax({
type: 'POST',
url: WordfenceAdminVars.ajaxURL,
dataType: "json",
data: {
nonce: WordfenceAdminVars.firstNonce,
email: email,
action: 'wordfence_updateAlertEmail'
},
success: function(json){
if(json.ok){
jQuery('#wordfenceEmailDiv').html('<div style="color: #0A0;">Your admin alert email address has been set to ' + jQuery('<div/>').text(json.email).html() + '.</div>');
} else if(json.err){
alert(json.err);
}
},
error: function(){
}
});
if(jQuery('#wfJoinListCheck').is(':checked')){
return true;
} else {
try {
if(evt.preventDefault) evt.preventDefault();
evt.returnValue = false;
} catch(e){}
return false;
}
}
};
}
jQuery(function(){
if(WordfenceAdminVars.tourClosed != '1' && WordfenceAdminVars.welcomeClosed != '1'){
var formHTML = '<div style="padding: 0 5px 0 15px;" id="wordfenceEmailDiv"><form target="_new" style="display: inline;" method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl" ><div style="display: none;"><input type="hidden" name="meta_web_form_id" value="1428034071" /><input type="hidden" name="meta_split_id" value="" /><input type="hidden" name="listname" value="wordfence" /><input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="redirect_ae9f0882518768f447c80ea8f3b7afde" /><input type="hidden" name="meta_adtracking" value="widgetForm" /><input type="hidden" name="meta_message" value="1" /><input type="hidden" name="meta_required" value="email" /><input type="hidden" name="meta_tooltip" value="" /></div><input class="text" id="wfListEmail" type="text" name="email" value="Enter your email" tabindex="500" onclick="wordfenceTour.wfClearEmailField(); return false;" /><input name="submit" type="submit" value="Get Alerted" tabindex="501" onclick="var evt = event || window.event; try { return wordfenceTour.processEmailClick(evt); } catch(err){ evt.returnValue = false; evt.preventDefault(); }" /><div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=jCxMHAzMLAzsjA==" alt="" /></div><div style="padding: 5px; font-size: 10px;"><input type="checkbox" id="wfJoinListCheck" value="1" checked /><span style="font-size: 10px;">Also join our WordPress Security email list to receive WordPress Security Alerts and Wordfence news.</span></div></form></div>';
var elem = '#toplevel_page_Wordfence';
jQuery(elem).pointer({
close: function(){},
content: "<h3>Congratulations!</h3><p>You've just installed Wordfence! Start by entering the administrator email address where you would like to receive security alerts for your site:</p>" +
formHTML +
"<p>Then click \"Start Tour\" to get a quick introduction to how Wordfence protects your site, keeps you off Google's SEO black-list and can even help clean a hacked site.</p>",
pointerWidth: 300,
position: { edge: 'bottom', align: 'left' },
buttons: function(event, t){
var buttonElem = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">Close</a>');
buttonElem.bind('click.pointer', function(){ t.element.pointer('close');
var ajaxData = {
action: 'wordfence_welcomeClosed',
nonce: WordfenceAdminVars.firstNonce
};
jQuery.ajax({
type: 'POST',
url: WordfenceAdminVars.ajaxURL,
dataType: "json",
data: ajaxData,
success: function(json){},
error: function(){}
});
});
return buttonElem;
}
}).pointer('open');
jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">Start Tour</a>');
jQuery('#pointer-primary').click(function(){
var ajaxData = {
action: 'wordfence_welcomeClosed',
nonce: WordfenceAdminVars.firstNonce
};
jQuery.ajax({
type: 'POST',
url: WordfenceAdminVars.ajaxURL,
dataType: "json",
data: ajaxData,
success: function(json){ window.location.href = 'admin.php?page=Wordfence'; },
error: function(){ window.location.href = 'admin.php?page=Wordfence'; }
});
});
}
(function($) {
$('.wf-dismiss-link').on('click', function() {
$('#wf-extended-protection-notice').css({
opacity: .75
});
$.get(this.href, function() {
$('#wf-extended-protection-notice').fadeOut(1000);
});
return false;
});
})(jQuery);
});