This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_list.php
237 lines (221 loc) · 8.47 KB
/
email_list.php
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
if (!logged_in()) {
login_then_redirect_back_here();
}
$user_id = $_SESSION['user_id'] ?? '';
define('TITLE', 'S!zzle - Email List');
require __DIR__.'/header.php';
?>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/create_recruiting.min.css">
<!-- Polymer -->
<script src="/components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="/components/iron-icons/iron-icons.html">
<link rel="import" href="/components/iron-icon/iron-icon.html">
<link rel="import" href="/components/iron-form/iron-form.html">
<link rel="import" href="/components/paper-menu/paper-menu.html">
<link rel="import" href="/components/paper-item/paper-item.html">
<link rel="import" href="/components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="/components/paper-input/paper-input.html">
<link rel="import" href="/components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="/components/paper-styles/paper-styles.html">
<link rel="import" href="/components/paper-card/paper-card.html">
<link rel="import" href="/components/paper-button/paper-button.html">
<link rel="import" href="/components/paper-input/paper-textarea.html">
<link rel="import" href="/components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="/components/paper-dialog/paper-dialog.html">
<style is="custom-style">
.center-column {
margin-top: 100px;
margin-bottom: 500px;
}
paper-card {
display: block;
width: 100%;
background: #424242;
margin-top: 20px;
--paper-card-header-color: white;
--paper-card-header-text: {font-weight: normal;}
}
paper-button {
background: #009688;
color: white;
}
paper-button.dialog-button {
background: #2193ED;
font-size: 14px;
margin-top: 0px;
margin-bottom: 20px;
border: 0px;
}
iron-icon {
margin-right: 10px;
color: #676767;
}
paper-dialog {
--paper-dialog-background-color: #424242;
color: white;
--paper-dialog-title: {font-size: 24px; font-weight: 300; margin-top: 10px}
}
paper-dialog#status-dialog {
--paper-dialog-background-color: #303030;
}
#email-list-dialog {
height: 270px;
width: 500px;
}
#email-list-errors {
text-align: left;
color: rgb(252,84,87);
}
#explanation-text {
text-align: left;
}
paper-input, paper-textarea, paper-dropdown-menu {
--paper-input-container-focus-color: #1094F7;
--paper-input-container-input-color: white
}
</style>
</head>
<body>
<div>
<?php require_once __DIR__.'/navbar.php';?>
</div>
<div class="center-column">
<div id="left-column">
<i id="explanation-text">
Please click below to upload an email list in the form of a text file
with a single email on each line
(<a href="/examples/email_list.txt" download>see example</a>).
Clicking upload more than once will create more than one list.
</i>
<form is="iron-form" id="recruiting-company-form">
<div class="button-container">
<paper-button raised class="bottom-button" onclick="uploadEmailList()">UPLOAD</paper-button>
</div>
</form>
</div>
<div id="right-column" class="pull-right">
<div class="button-container">
<paper-button raised onclick="backToSend('<?php echo $_GET['referrer'] ?? '';?>')">BACK</paper-button>
<paper-button raised onclick="backToSend('<?php echo $_GET['referrer'] ?? '';?>')">CONTINUE</paper-button>
</div>
</div>
<div id="email-list-errors"></div>
</div>
<paper-dialog class="recruiting-dialog" id="email-list-dialog" modal>
<h2>Upload your email list</h2>
<form id="email-list-upload">
<input class="hidden-file-input" type="file" id="select-list-file" name="listFile" />
<paper-input id="email-list-name" label="List Name" name="listName" autofocus></paper-input>
<paper-input id="email-list-file" label="File Name" name="fileName" onclick="fireHiddenFileInput('#select-list-file')"></paper-input>
</form>
<div class="buttons">
<paper-button class="dialog-button" onclick="saveEmailList()">UPLOAD</paper-button>
<paper-button dialog-dismiss class="dialog-button" onclick="cancelEmailListUpload()">Cancel</paper-button>
</div>
</paper-dialog>
<paper-dialog class="recruiting-dialog" id="validation-dialog" modal>
<h2>Problem...</h2>
<p id="validation-message">No message supplied</p>
<div class="buttons">
<paper-button dialog-dismiss class="dialog-button" id="validation-button">OK</paper-button>
</div>
</paper-dialog>
<paper-dialog class="recruiting-dialog" id="status-dialog">
<p id="status-message">No message supplied</p>
</paper-dialog>
<?php require_once __DIR__.'/footer.php';?>
<!-- JavaScript -->
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>
/**
* Opens the Email List Dialog
*/
function uploadEmailList() {
$('#email-list-dialog')[0].open();
}
/**
* Closes the Email List Dialog
*/
function cancelEmailListUpload() {
$('#email-list-errors').html('');
$('#email-list-dialog')[0].close();
}
/**
* Attempts to upload the email list to the ajax endpoint & closes dialog
*/
function saveEmailList() {
$('#email-list-errors').html('Processing...');
var formData = new FormData($('#email-list-upload')[0]);
$.ajax({
url: '/ajax/email/list/upload/',
type: 'post',
/*data: {
listName: $('#email-list-name').val(),
fileName: $('#select-list-file').val(),
},*/
data: formData,
dataType: 'json',
headers: {
"X-FILENAME": $('#select-list-file').val(),
},
success: function(data, textStatus){
var message = data.data.message+'<br />';
if(data.success === 'true') {
$('#email-list-errors').css('color','white');
} else {
if (data.data.errors.length) {
message += '<strong>Errors:</strong><br />';
$.each(data.data.errors, function(index, error) {
message += error+'<br />';
})
}
}
$('#email-list-errors').html(message);
},
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
}).fail(function() {
$('#email-list-errors').html('Uploading email list failed.');
});
$('#email-list-dialog')[0].close();
}
/**
* Redirects user back to token send page from email list edit page
*
* @param {String} longId The long_id of the token
*/
function backToSend(longId) {
window.location = '/send_recruiting?id='+longId;
}
/**
* Registers click on hidden file input.
*
* @param {String} identifier The jQuery identifier to click
*/
function fireHiddenFileInput(identifier) {
$(identifier).trigger('click');
}
$( document ).ready(function() {
$('#select-list-file').change(function() {
var filename = $('#select-list-file').val().replace('C:\\fakepath\\', '');
if ($('#select-list-file:file')[0].files[0].type !== "text/plain") {
$('#email-list-file label').html('<font color="red">Please choose a text file</font>');
$('#upload-file').val('');
} else {
$('#email-list-file label').html('File Name');
$('#email-list-file').val(filename);
}
});
});
</script>
</body>
</html>