Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions website/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,40 @@
</head>

<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

<div class="container">
<div class="pageContent">
<div class="row">
<div class="col-sm-12">
<div id="messageBox"></div>
<div id="firstMessage">
<div id="verify" style="display: none;">
<h1>One Last Step...</h1>
<h4>You need to enter your preferred email.</h4>
<h4>We’ll use the domain of your email address to identify your university or company so you can easily see how you rank against others in your organization. We’ll also email you about bot submission events like compilation errors. You can opt out of these at any time.</h4>
<h4>You need to choose your preferred email.</h4>
<h4>We’ll use the domain of your email address to identify your university or company (using <a href="https://github.com/HaliteChallenge/Halite/blob/master/website/organizationWhitelist.txt"> this whitelist</a>) so you can easily see how you rank against others in your organization. We’ll also email you about bot submission events like compilation errors. You can opt out of these at any time.</h4>
<h4>You have two options:</h4>
<h4><?php include 'includes/email_github_form.php'; ?></h4>
<h4 id="or">Or, choose a custom email:</h4>
<?php include 'includes/email_custom_form.php'; ?>
</div>
<div id="returningMessage">
<div id="change" style="display: none;">
<h1>Email Change</h1>
<h4>Please enter your preferred email.</h4>
<h4>We’ll use the domain of your email address to identify your university or company so you can easily see how you rank against others in your organization. We’ll also email you about bot submission events like compilation errors. You can opt out of these at any time.</h4>
<?php include 'includes/email_custom_form.php'; ?>
</div>

<div id="forms">
<input class="form-control" type="email" placeholder="Email" style="margin-top: 20px; max-width: 400px;" id="firstField">
<input class="form-control" type="email" placeholder="Confirm Email" style="margin-bottom: 10.5px; max-width: 400px;" id="secondField">
<button id="customSubmitButton" class="btn btn-primary">Submit</button>
</div>
<div id="waitMessage" style="display: none;">
<div id="wait" style="display: none;">
<h2>We've sent you a verification email and are waiting for you to click the link in it. This email may land in your spam folder.</h2>
<h4>If you've already verified your email, head to our <a href="index.php">homepage</a>. If you're having problems with registration, please email us at [email protected].</h4>
<h4>If you've already verified your email, head to our <a href="index.php">homepage</a>. If you're having problems with registration, please email us at [email protected] or switch to using your github email: <?php include 'includes/email_custom_form.php'; ?>.</h4>

</div>
</div>
</div>
</div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="script/general.js"></script>
<script src="script/backend.js"></script>
<script src="script/email.js"></script>
</body>
Expand Down
37 changes: 37 additions & 0 deletions website/includes/email_custom_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script type="text/javascript">
var customEmailForm = {
init: function(submitCallback) {
this.cacheDOM();

this.submitCallback = submitCallback;
this.$submitButton.click(this, this.onClick.bind(this));
this.$firstField.keypress(this, this.keypress.bind(this));
this.$secondField.keypress(this, this.keypress.bind(this));
},
cacheDOM: function() {
this.$firstField = $("#firstField");
this.$secondField = $("#secondField");
this.$messageBox = $("#messageBox");
this.$submitButton = $("#customSubmitButton");
},
render: function() {
this.$emailLoc.html(this.email);
},
onClick: function() {
if(this.$firstField.val() != this.$secondField.val()) {
messageBox.alert("Email Mismatch", "The two emails that you entered do not match.", false);
} else if(this.$firstField.val() == "" || this.$secondField.val() == "") {
messageBox.alert("Empty Fields", "Please fill your email twice in the boxes below.", false);
} else {
messageBox.alert("Success", "We've sent a verification email to "+this.$firstField.val()+".", true);
this.submitCallback(this.$firstField.val());
}
},
keypress: function(e) {
if(e.which == 13) this.onClick();
}
}
</script>
<input class="form-control" type="email" placeholder="Email" style="margin-top: 20px; max-width: 400px;" id="firstField">
<input class="form-control" type="email" placeholder="Confirm Email" style="margin-bottom: 10.5px; max-width: 400px;" id="secondField">
<button id="customSubmitButton" class="btn btn-primary">Submit</button>
24 changes: 24 additions & 0 deletions website/includes/email_github_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script type="text/javascript">
var githubSubmitButton = {
init: function(email, onSubmit) {
email = "[email protected]";
this.cacheDOM();

this.onSubmit = onSubmit;

this.$emailField.html(email);
console.log(this.$emailField);
this.$button.click(this, this.onPress.bind(this));
},
cacheDOM: function() {
this.$emailField = $("#githubEmail");
this.$button = $("#githubEmailButton");
},
onPress: function() {
console.log("press")
messageBox.alert("Success", "You're all set!.", true);
this.onSubmit();
}
}
</script>
<button class="btn btn-primary" id="githubEmailButton"><b>Use your github's email (<span id="githubEmail"></span>) without needing to verify</b></button>
65 changes: 17 additions & 48 deletions website/script/email.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,26 @@
$(function() {
var customEmailForm = {
$firstField: $("#firstField"),
$secondField: $("#secondField"),
$messageBox: $("#messageBox"),
$submitButton: $("#customSubmitButton"),
init: function(submitCallback) {
this.submitCallback = submitCallback;
this.$submitButton.click(this, this.onClick.bind(this));
this.$firstField.keypress(this, this.keypress.bind(this));
this.$secondField.keypress(this, this.keypress.bind(this));
},
render: function() {
this.$emailLoc.html(this.email);
},
onClick: function() {
if(this.$firstField.val() != this.$secondField.val()) {
this.displayMessage("Email Mismatch", "The two emails that you entered do not match.", false);
} else if(this.$firstField.val() == "" || this.$secondField.val() == "") {
this.displayMessage("Empty Fields", "Please fill your email twice in the boxes below.", false);
} else {
this.displayMessage("Success", "We've sent a verification email to "+this.$firstField.val()+".", true);
this.submitCallback(this.$firstField.val());
}
},
keypress: function(e) {
if(e.which == 13) this.onClick();
},
displayMessage: function(title, message, isSuccess) {
this.$messageBox.append($("<div class='alert "+(isSuccess ? "alert-success" : "alert-danger")+" alert-dismissible' role='alert'><button type='button' class='close' id='messageCloseButton' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><strong>"+title+"</strong>&nbsp;&nbsp;"+message+"</div>"))
}
}

function render() {
if(parseInt(user.isEmailGood) == 0) {
if(user.email != null && user.email != undefined) {
$("#waitMessage").css("display", "block");
if(user.email != null && user.email != undefined) { // Waiting for verification
$("#wait").css("display", "block");

$("#forms").css("display", "none");
$("#firstMessage").css("display", "none");
$("#returningMessage").css("display", "none");
} else {
$("#forms").css("display", "block");
$("#firstMessage").css("display", "block");
$("#change").css("display", "none");
$("#verify").css("display", "none");
} else { // Need to pick an email
$("#verify").css("display", "block");

$("#waitMessage").css("display", "none");
$("#returningMessage").css("display", "none");
$("#change").css("display", "none");
$("#wait").css("display", "none");
}
} else {
$("#forms").css("display", "block");
$("#returningMessage").css("display", "block");
} else { // Email change
$("#change").css("display", "block");

$("#waitMessage").css("display", "none");
$("#firstMessage").css("display", "none");
$("#wait").css("display", "none");
$("#verify").css("display", "none");
}
}

var session = getSession();
var session = getSession(); session = {"userID": 4431};
if(session == null) window.location.href = "index.php";
var user = getUser(session['userID']);
if(user == null) window.location.href = "index.php";
Expand All @@ -68,4 +33,8 @@ $(function() {
user.email = email;
render(user);
});
githubSubmitButton.init(user.githubEmail, function() {
validateEmail();
window.location.href = "index.php";
});
});