Commit 1df79ae8 authored by Leigh Stoller's avatar Leigh Stoller

Another stab at the signup page.

parent 33c9eafc
......@@ -22,10 +22,7 @@ function (_, sup,
function initialize()
{
window.APT_OPTIONS.initialize(sup);
$('button#reset-form').click(function (event) {
event.preventDefault();
clearForm($('#quickvm_signup_form'));
});
var fields = JSON.parse(_.unescape($('#form-json')[0].textContent));
var errors = JSON.parse(_.unescape($('#error-json')[0].textContent));
renderForm(fields, errors,
......@@ -33,74 +30,25 @@ function (_, sup,
window.APT_OPTIONS.ShowVerifyModal,
window.APT_OPTIONS.this_user);
// Carry this forward.
if (window.APT_OPTIONS.ShowVerifyModal) {
var $jval = (window.APT_OPTIONS.joinproject ? "1" : "0");
$('#quickvm_signup_form').append("<input type='hidden' " +
" id='joinproject' " +
" name='joinproject' " +
" value='jval' />");
}
// But if bound, make sure we have proper tab active.
if (typeof window.APT_OPTIONS.joinproject === 'undefined' ||
!window.APT_OPTIONS.joinproject) {
$("#project_tabs a:last").tab('show');
}
else {
$("#project_tabs a:first").tab('show');
}
/*
* Intercept the submit so we can check to see if the user
* is joining or starting a project. We do this by looking
* to see which of the tabs is active.
*
* XXX Both tabs need the same formfields[pid] entry, but
* it does not work to have two input fields with the same
* name, so yank the input field out of the inactive tab.
*
* Also add the joinproject boolean so the server side knows
* what the user is doing (join or start).
* When switching from start to join, show the hidden fields
* and change the button.
*/
$('button#submit_button').click(function (event) {
if ($('#join_tab').hasClass('active')) {
$('#joinproject').remove();
$('#quickvm_signup_form').append("<input type='hidden' " +
" id='joinproject' " +
" name='joinproject' " +
" value='1' />");
$('#form_start_pid').remove();
$("input[id='startorjoin']").change(function(e){
if ($(this).val() == "join") {
$('#start_project_rollup').addClass("hidden");
$('#submit_button').text("Join Project");
}
else {
$('#joinproject').remove();
$('#quickvm_signup_form').append("<input type='hidden' " +
" id='joinproject' " +
" name='joinproject' " +
" value='0' />");
$('#form_join_pid').remove();
$('#start_project_rollup').removeClass("hidden");
$('#submit_button').text("Start Project");
}
});
/*
* When the user toggles from one tab to the other, change
* the label in the button.
*/
if (window.APT_OPTIONS.this_user) {
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if ($('#join_tab').hasClass('active')) {
$('#submit_button').text("Join Project");
}
else {
$('#submit_button').text("Start Project");
}
});
}
}
function renderForm(formfields, errors, joinproject, showVerify, thisUser)
{
var buttonLabel = calculateButtonLabel(joinproject, thisUser);
var buttonLabel = (joinproject ? "Join Project" : "Start Project");
var about = aboutTemplate({});
var verify = verifyTemplate({
id: 'verify_modal',
......@@ -141,23 +89,6 @@ function (_, sup,
$form.find('input:text, input:password, select, textarea').val('');
}
function calculateButtonLabel(joinproject, thisUser)
{
var result = 'Create Account';
if (thisUser)
{
if (joinproject)
{
result = 'Join Project';
}
else
{
result = 'Create Project';
}
}
return result;
}
function formatter(fieldString, errors)
{
var result = $('<div/>');
......
......@@ -26,7 +26,7 @@ include("defs.php3");
chdir("apt");
include("quickvm_sup.php");
# Do not create anything, just do the checks.
$debug = 1;
$debug = 0;
#
# Get current user.
......@@ -68,22 +68,6 @@ function SPITFORM($formfields, $showverify, $errors)
echo "</script>\n";
echo "<script type='text/javascript'>\n";
# XSS prevention.
# TODO: Leigh These CleanStrings() should be moot. Double check this.
# while (list ($key, $val) = each ($formfields)) {
# echo "\"" . CleanString($key) . "\": \"" . CleanString($val) . "\",\n";
# }
# echo "};\n";
# echo "window.APT_OPTIONS.errors = {\n";
# XSS prevention.
# if ($errors) {
# while (list ($key, $val) = each ($errors)) {
# echo "\"" . CleanString($key) . "\": \"" . CleanString($val) . "\",\n";
# }
# }
# echo "};\n";
if (isset($joinproject)) {
$joinproject = ($joinproject ? "true" : "false");
echo "window.APT_OPTIONS.joinproject = $joinproject;\n";
......@@ -105,7 +89,8 @@ function SPITFORM($formfields, $showverify, $errors)
if (isset($finished) && $finished) {
SPITHEADER(1);
echo "Thank you! Your project application is being considered by the approval committee, and you should hear back within 72 hours.";
echo "Thank you! Stay tuned for email about your request, be sure ".
"to set your spam filter to allow email from '@${OURDOMAIN}'.";
SPITNULLREQUIRE();
SPITFOOTER();
exit(0);
......@@ -127,6 +112,9 @@ if (! isset($create)) {
if (isset($email)) {
$defaults["email"] = CleanString($email);
}
# Default to join
$defaults["startorjoin"] = "join";
$joinproject = 1;
SPITFORM($defaults, 0, $errors);
return;
......@@ -137,6 +125,18 @@ if (! isset($create)) {
#
$errors = array();
#
# Check for start or join right away so we know what we be doing.
#
if (!isset($formfields["startorjoin"]) || $formfields["startorjoin"] == "") {
$errors["error"] = "Neither start or join selected";
SPITFORM($defaults, 0, $errors);
return;
}
if ($formfields["startorjoin"] == "join") {
$joinproject = 1;
}
#
# These fields are required
#
......@@ -400,7 +400,7 @@ elseif ($joinproject) {
TBERROR("Could not add new user to project group $pid", 1);
}
$group->NewMemberNotify($this_user);
header("Location: instantiate.php");
header("Location: signup.php?finished=1");
return;
}
......
<div>
<ul class='nav nav-tabs' id='project_tabs'>
<li class='active'>
<a href='#join_tab' data-toggle='tab'>Join Project</a>
</li>
<li>
<a href='#start_tab' data-toggle='tab'>Start Project</a>
</li>
</ul>
<div class='tab-content'>
<div class='tab-pane active' id='join_tab'>
<input name="formfields[pid]" value="<%- formfields.pid %>"
id="form_join_pid"
class="form-control format-me" data-key="pid"
placeholder="Project Name" type="text">
<div class="form-group" >
<div class="" style='padding-left: 15px; margin-bottom: 7px;'>
<label class="radio-inline" style='margin-right: 10px;'>
<input type="radio" id="startorjoin"
name="formfields[startorjoin]"
value="join"
<% if (formfields.startorjoin == "join") { %>checked<% } %> >
Join Existing Project</label>
<label class="radio-inline" style='margin-left: 0px;'>
<input type="radio" id="startorjoin"
name="formfields[startorjoin]"
value="start"
<% if (formfields.startorjoin == "start") { %>checked<% } %> >
Start New Project</label>
</div>
</div>
<div class='tab-pane' id='start_tab'>
<input name="formfields[pid]" value="<%- formfields.pid %>"
id="form_start_pid"
class="form-control format-me" data-key="pid"
placeholder="Project Name" type="text">
<input name="formfields[proj_title]" value="<%- formfields.proj_title %>"
class="form-control format-me" data-key="proj_title"
placeholder="Project Title (short sentence)" type="text">
<input name="formfields[proj_url]" value="<%- formfields.proj_url %>"
class="form-control format-me" data-key="proj_url"
placeholder="Project Page URL" type="text">
<textarea name="formfields[proj_why]" rows="8"
class="form-control format-me" data-key="proj_why"
placeholder="Project Description (details)"
type="textarea"><%- formfields.proj_why %></textarea>
<input name="formfields[pid]" value="<%- formfields.pid %>"
id="form_join_pid"
class="form-control format-me" data-key="pid"
placeholder="Project Name" type="text">
<div id="start_project_rollup"
<% if (formfields.startorjoin == "join") { %>class=hidden<% } %> >
<input name="formfields[proj_title]"
value="<%- formfields.proj_title %>"
class="form-control format-me" data-key="proj_title"
placeholder="Project Title (short sentence)" type="text">
<input name="formfields[proj_url]" value="<%- formfields.proj_url %>"
class="form-control format-me" data-key="proj_url"
placeholder="Project Page URL" type="text">
<textarea name="formfields[proj_why]" rows="8"
class="form-control format-me" data-key="proj_why"
placeholder="Project Description (details)"
type="textarea"><%- formfields.proj_why %></textarea>
</div>
</div>
</div>
......@@ -39,12 +39,8 @@
</fieldset>
</div>
</div>
<div class='row sidebyside-form'>
<button class='btn btn-primary btn-xs pull-left'
type='button' name='reset' id='reset-form'>
Reset Form
</button>
<button class='btn btn-primary btm-sm pull-right'
<div class='row sidebyside-form'>
<button class='btn btn-primary btn-sm pull-right'
id='submit_button'
type='submit' name='create'><%- button_label %></button>
</div>
......
......@@ -3,14 +3,21 @@
col-md-8 col-md-offset-2
col-sm-10 col-sm-offset-1
col-xs-12 col-xs-offset-0'>
<div class='panel panel-default'>
<div class='panel-body'>
<table class='table table-condensed nospaceafter border-none'>
<tr>
<td id='statusmessage-container' colspan=2 class='border-node'>
<h4 id='statusmessage'></h4>
</td>
</tr>
<div class='panel panel-default' id='status_panel'>
<div class="panel-heading">
<h5>
<a data-toggle="collapse" id="profile_status_toggle"
href="#profile_status_collapse">
<span id='status_message'></span>
<span class="glyphicon glyphicon-chevron-right pull-right"></span>
</a>
</h5>
</div>
<div id="profile_status_collapse"
class="panel-collapse collapse
<% if (status_panel_show) { %>in<% } %>">
<div class='panel-body'>
<table class='table table-condensed nospaceafter border-none'>
<!-- The spinner will start out invisible -->
<tr>
<td colspan=2 class='border-none'>
......@@ -42,35 +49,36 @@
</tr>
<tr>
<td class='border-none'>Expires:</td>
<td class='border-none'>
<td class='border-none' id='instance_expiration'>
<span id='quickvm_expires'><%- sliceExpiresText %></span>
(<span id='quickvm_countdown'></span>)
</td>
</tr>
</table>
<!--
<div class='pull-left'>
<span class='glyphicon glyphicon-question-sign'
style='font-size:24px'></span>
</div>
-->
<div class='pull-right'>
<% if (registered) { %>
<button class='btn btn-xs btn-primary hidden' disabled
id='clone_button' type=button>
Clone</button>
<button class='btn btn-xs btn-primary hidden' disabled
id='snapshot_button' type=button
data-toggle='modal' data-target='#snapshot_modal'>
Snapshot</button>
<% } %>
<button class='btn btn-xs btn-success' disabled
id='extend_button' type=button>
Extend</button>
<button class='btn btn-xs btn-danger' disabled
id='terminate_button' type=button
data-toggle='modal' data-target='#terminate_modal'>
Terminate</button>
</table>
<!--
<div class='pull-left'>
<span class='glyphicon glyphicon-question-sign'
style='font-size:24px'></span>
</div>
-->
<div class='pull-right'>
<% if (registered) { %>
<button class='btn btn-xs btn-primary hidden' disabled
id='clone_button' type=button>
Clone</button>
<button class='btn btn-xs btn-primary hidden' disabled
id='snapshot_button' type=button
data-toggle='modal' data-target='#snapshot_modal'>
Snapshot</button>
<% } %>
<button class='btn btn-xs btn-success' disabled
id='extend_button' type=button>
Extend</button>
<button class='btn btn-xs btn-danger' disabled
id='terminate_button' type=button
data-toggle='modal' data-target='#terminate_modal'>
Terminate</button>
</div>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment