forked from aaronlifshin/homepage_redesign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_email_prefs.html
107 lines (83 loc) · 3.52 KB
/
change_email_prefs.html
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
---
layout: default
title: MAYDAY.US - Change Email Preferences
omit_title_suffix: true
cssid: change_email_prefs
---
{% capture subhead %}
{% endcapture %}
{% capture pageid %}
Change Email Preferences
{% endcapture %}
{% capture content %}
<!--
User's email address: id="user_email_address"
Form Name: name="changeEmailPrefs"
action: changeEmailPrefs();
Field: "fundraiseok" - values are Yes and No.
-->
<h1>Change e-mail preferences</h1>
<p>Here, you will be able to change your e-mail preferences to opt-in or opt-out of fundraising e-mails. For more information on our policy, check out <a href="/2014/07/30/EmailFundraising/">our blog post on email fundraising</a>.</p>
<p>Your E-Mail Address: <span id="user_email_address" style="text-weight:bold;">Email</span></p>
<form id="changeEmailPrefs" action="javascript:;" method="get">
<input style="vertical-align: baseline;" type="radio" name="fundraiseok" value="Yes"><label><strong> Send Me All E-mails Including Fundraising E-mails</strong></label><br />
I want to receive them and help out some more as we hit crucial milestones in our campaign leading up to Election Day. </span><br><BR>
<input style="vertical-align: baseline;" type="radio" name="fundraiseok" value="No"><label><strong> Do Not Send Me Fundraising E-mails</strong></label><br />
I'm just interested in how I can help out non-financially at this stage, as well as getting news and updates from the campaign. If I need to donate, I'm pretty sure I'll remember the "Mayday.US" address, after all. </span>
<BR><BR>
<input type="submit" value="Submit">
</form>
{% endcapture %}
{% include subpage_nomarkdown.html %}
<script>
function post_to_url(path, params, method) {
method = method || "POST"; // Set method to post by default, if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for (var key in params) {
if (params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function changeEmailPrefs() {
var preference = $("input:radio[name=fundraiseok]:checked").val() || null;
if (preference) {
var params = {
'email':userEmail,
'MERGE13':preference,
'redirect':'https://mayday.us/change_email_prefs_thanks/',
'source':'changePrefs'
};
post_to_url("https://pledge.mayday.us/r/subscribe", params);
} else {
alert('Please select a preference.');
}
}
var userEmail = null;
// $('#emailAddress').text('(At ' + email + ')');
$(document).ready( function() {
userEmail = getParameterByName('email') || null;
$('#changeEmailPrefs').submit(changeEmailPrefs);
if (userEmail) {
$('#user_email_address').text(userEmail);
} else {
alert('No email provided, looks like you followed a bad link and this form will not work');
}
});
</script>