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
2 changes: 0 additions & 2 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
<script src="{{ baseurl }}scripts/selfservice.js"></script>
{% elsif page.thanks %}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"></script>
<script> var remoteUrl = '{{ api }}'; </script>
<script src="{{ baseurl }}scripts/thanks.js"></script>
{% endif %}

Expand Down
3 changes: 1 addition & 2 deletions pages/self-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ <h2 id="riderConfirmedHeader" class="self-service-heading">Rider Confirmed Match

<div class="form-group">
<button class="button button--danger" id="btnCancelRideRequest">Cancel Ride Request</button>
<button class="button button--danger" id="btnCancelRiderMatch">Cancel Rider Match Request</button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merging of the two cancel functions and buttons looks like a very promising refactor. I've probably not got time to check it before the Nov 7 election, and the changes to element ids may stop my automated tests from working. With the limited time and support team numbers, I'd like to keep those tests going if possible. Can we put this change to one side until after Nov 7, please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's update the tests when we merge after Nov 7.

<button class="button button--danger" id="btnCancelMatch">Cancel Match Request</button>
<button class="button button--danger" id="btnCancelDriveOffer">Cancel Drive Offer Request</button>
<button class="button button--danger" id="btnCancelDriverMatch">Cancel Driver Match Request</button>
<button class="button button--danger" id="btnPauseDriverMatch">Pause Notifications</button>
<button class="button" id="btnAcceptDriverMatch">Accept Driver Match Request</button>
</div>
Expand Down
39 changes: 18 additions & 21 deletions pages/thanks-driver.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
<div class="wrapper single-column offset-top">
<div class="bannerbox">
<div class="bannerbox__content">
<h1 id="thanks-header">Thank you</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the id for the h1 element until after Nov 7, please? The automated tests use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's update the tests when we merge after Nov 7.

<span id="sorryHeading" hidden style="display:none">We are sorry</span>

<p id="introPara">for offering a fellow American a ride to claim their vote! Together, our driving volunteers could help shape the outcome of this election.</p>
<span id="sorryPara" hidden style="display:none">It has not been possible to process your request. Please see the information below for more details. We want to help you to volunteer, so please contact our phone support if you cannot resolve this issue yourself.</span>

<div id="responseDetails" hidden style="display:none">
<p>Response code: <b id="responseCode" class="uuid"></b></p>
<p>Response info: <b id="responseText" class="uuid"></b></p>
</div>

<div id="requestSuccessInfo">
<div id="thanks">
<h1>Thank you</h1>
<p>Thanks for offering a fellow American a ride to claim their vote! Together, our driving volunteers could help shape the outcome of this election.</p>
<p>We've sent you a message confirming that we've received your offer.</p>
<p>Your driver offer reference number is: <b class="uuid">ID not loaded, please try again</b>.</p>
<p><strong>If you do not receive a message via email, please check your spam folder.</strong></p>
<p>Your driver offer reference number is: <b class="uuid uuid--large">ID not loaded, please try again</b></p>
<p>Please <strong>keep this reference</strong> in case you need to manage your ride request.</p>
<p>To view or manage your matches, visit our <b><a class="self-service-url" href="../self-service/?type=driver">self-service portal</a></b>.</p>

Expand All @@ -31,16 +23,21 @@ <h2>What happens next?</h2>
<p>Once you have accepted a ride request, we'll send you a message with the rider's contact details. It's then up the you and the rider to arrange when and where you'd like to meet, and any other details of your trip.</p>

<p>Let your friends know!</p>

<ul class="social">
<li role="presentation" class="social__twitter">
<a href="https://twitter.com/intent/tweet" class="twitter-mention-button" data-text="I've signed up to offer a ride to a fellow American on @CarpoolVote. #Election2016 will be close. #CountEveryVote" data-related="" data-url="http://carpoolvote.com" data-show-count="false">Tweet to help others find out about this!</a>
</li>
<li role="presentation" class="social__facebook">
<div class="fb-share-button" data-href="http://carpoolvote.com?v=1" data-layout="button"></div>
</li>
</ul>
</div>

<ul class="social">
<li role="presentation" class="social__twitter">
<a href="https://twitter.com/intent/tweet" class="twitter-mention-button" data-text="I've signed up to offer a ride to a fellow American on @CarpoolVote. #Election2016 will be close. #CountEveryVote" data-related="" data-url="http://carpoolvote.com" data-show-count="false">Tweet to help others find out about this!</a>
</li>
<li role="presentation" class="social__facebook">
<div class="fb-share-button" data-href="http://carpoolvote.com?v=1" data-layout="button"></div>
</li>
</ul>
<div id="sorry" style="display:none">
<h1>We are sorry</h1>
<p>It has not been possible to process your request. Please see the information below for more details. We want to help you to volunteer, so please contact our phone support <a href="tel:5406569388">540-656-9388</a> if you cannot resolve this issue yourself.</p>
</div>
</div>
</div>
</div>
Expand Down
43 changes: 19 additions & 24 deletions pages/thanks-rider.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,35 @@
<div class="wrapper single-column offset-top">
<div class="bannerbox">
<div class="bannerbox__content">
<h1 id="thanks-header">Congratulations</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the id for the h1 element until after Nov 7, please? The automated tests use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's update the tests when we merge after Nov 7.

<span id="sorryHeading" hidden style="display:none">We are sorry</span>

<p id="introPara">
on taking this step to claim your vote! We’ve sent you a message confirming that we’ve received your request.
<br><br>
<em><strong>If you do not receive a message via email, please check your spam folder.</strong></em>
</p>
<span id="sorryPara" hidden style="display:none">It has not been possible to process your request. Please see the information below for more details. We want to help you, so please contact our phone support if you cannot resolve this issue yourself.</span>
<div id="thanks">
<h1>Congratulations</h1>
<p>Congratulations on taking this step to claim your vote! We’ve sent you a message confirming that we’ve received your request.</p>
<p><strong>If you do not receive a message via email, please check your spam folder.</strong></p>

<div id="responseDetails" hidden style="display:none">
<p>Response code: <b id="responseCode" class="uuid"></b></p>
<p>Response info: <b id="responseText" class="uuid"></b></p>
</div>

<div id="requestSuccessInfo">
<p>Your ride request reference number is: <b class="uuid">ID not loaded, please try again</b>.</p>
<p>Your ride request reference number is: <b class="uuid uuid--large">ID not loaded, please try again</b></p>
<p>Please <strong>keep this reference</strong> in case you need to manage your ride request.</p>
<p>To view or manage your ride request, visit our <b><a class="self-service-url" href="../self-service/?type=rider">self-service portal</a></b>.</p>

<h2>What happens next?</h2>
<p>Our system will match you with potential drivers, based on the information you’ve provided. We'll let you know as soon as a driver has accepted your request.</p>
<p>The driver will then get in touch with you through the preferred method of contact you specified on the form. It's then up the you and the driver to arrange when and where you'd like to meet, and any other details of your trip.</p>

<p>Let your friends know!</p>

<ul class="social">
<li role="presentation" class="social__twitter">
<a href="https://twitter.com/intent/tweet" class="twitter-mention-button" data-text="I’ve signed up for a ride to #ClaimMyVote on @CarpoolVote. #Election2016 will be close. #CountEveryVote" data-related="" data-url="http://carpoolvote.com" data-show-count="false">Tweet to help others find out about this!</a>
</li>
<li role="presentation" class="social__facebook">
<div class="fb-share-button" data-href="http://carpoolvote.com?v=1" data-layout="button"></div>
</li>
</ul>
</div>

<ul class="social">
<li role="presentation" class="social__twitter">
<a href="https://twitter.com/intent/tweet" class="twitter-mention-button" data-text="I’ve signed up for a ride to #ClaimMyVote on @CarpoolVote. #Election2016 will be close. #CountEveryVote" data-related="" data-url="http://carpoolvote.com" data-show-count="false">Tweet to help others find out about this!</a>
</li>
<li role="presentation" class="social__facebook">
<div class="fb-share-button" data-href="http://carpoolvote.com?v=1" data-layout="button"></div>
</li>
</ul>
<div id="sorry" style="display:none">
<h1>We are sorry</h1>
<p>It has not been possible to process your request. Please see the information below for more details. We want to help you, so please contact our phone support on <a href="tel:5406569388">540-656-9388</a> if you cannot resolve this issue yourself.</p>
</div>
</div>
</div>
</div>
Expand Down
57 changes: 11 additions & 46 deletions scripts/selfservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ if (data.uuid_rider) {
// Cache jQuery selectors:
var $login = $('#login'),
$manage = $('#manage'),
$info = $('#manage #infoAdmin'),
$info = $manage.find('#infoAdmin'),
$manageLogin = $('#manageLogin'),
$infoLogin = $('#manageLogin #infoLogin')
$infoLogin = $manageLogin.find('#infoLogin')
;


Expand Down Expand Up @@ -68,25 +68,23 @@ $login.validator().on('submit', function(e) {
riderExists();
}

// done in driver exists
//
// $(this).slideUp(300).attr('aria-hidden','true');
// $manage.slideDown(300).attr('aria-hidden','false');
// updateUI();
e.preventDefault();
});

function updateUI(uuid, type, phone) {
// Hide login form and show user info
$login.slideUp(300).attr('aria-hidden','true');
$manage.slideDown(300).attr('aria-hidden','false');

// NOTE: this handling isn't quite correct, so avoid refactoring without full testing
var dataTypeDriver = data.type === 'driver';
var dataTypeRider = data.type === 'rider';

$manage.find('#btnCancelDriveOffer').toggle(dataTypeDriver);
$manage.find('#btnPauseDriverMatch').toggle(dataTypeDriver);
$manage.find('#btnCancelDriverMatch').toggle(dataTypeRider && data.uuid_driver !== undefined && data.score !== 'undefined');
$manage.find('#btnCancelMatch').toggle(data.uuid_driver !== undefined && data.score !== 'undefined');

$manage.find('#btnCancelRideRequest').toggle(dataTypeRider);
$manage.find('#btnCancelRiderMatch').toggle(dataTypeRider && data.uuid_driver !== undefined && data.score !== 'undefined');

$manage.find('#btnAcceptDriverMatch').toggle(dataTypeRider && data.uuid_driver !== undefined && data.score !== 'undefined');
}
Expand All @@ -110,30 +108,14 @@ function updateUIbyRiderStatus (riderStatus) {

$manage
.on('click', '#btnCancelRideRequest', cancelRideRequest)
.on('click', '#btnCancelRiderMatch', cancelRiderMatch)
.on('click', '#btnCancelMatch', cancelMatch)
.on('click', '#btnCancelDriveOffer', cancelDriveOffer)
.on('click', '#btnCancelDriverMatch', cancelDriverMatch)
.on('click', '#btnPauseDriverMatch', pauseDriverMatch)
.on('click', '#btnAcceptDriverMatch', acceptDriverMatch)
.on('click', '#logout', logout);


function cancelRiderMatch() {
if (!window.confirm('This will cancel your ride match. Are you sure you want to proceed?')) {
return;
}
sendAjaxRequest(
{
UUID_driver: data.uuid_driver,
UUID_rider: data.uuid,
Score: data.score,
RiderPhone: data.phone
},
'/cancel-rider-match'
);
}

function cancelDriverMatch() {
function cancelMatch() {
if (!window.confirm('This will cancel your ride match. Are you sure you want to proceed?')) {
return;
}
Expand All @@ -144,7 +126,7 @@ function cancelDriverMatch() {
Score: data.score,
RiderPhone: data.phone
},
'/cancel-driver-match'
'/cancel-' + data.type + '-match'
);
}

Expand Down Expand Up @@ -225,8 +207,6 @@ function driverExists () {
if (keys[0] == "driver_exists" && info === "") {
driverLoggedIn = true;

$(this).slideUp(300).attr('aria-hidden','true');
$manage.slideDown(300).attr('aria-hidden','false');
updateUI();

clearDriverInfo ();
Expand Down Expand Up @@ -619,8 +599,6 @@ function riderExists () {
if (keys[0] == "rider_exists" && info === "") {
riderLoggedIn = true;

$(this).slideUp(300).attr('aria-hidden','true');
$manage.slideDown(300).attr('aria-hidden','false');
updateUI();

clearRiderInfo ();
Expand Down Expand Up @@ -799,20 +777,7 @@ function cancelRideRequest() {
}

function createAPIurl (params, apiRoute) {
var url = "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change might reflect our different coding styles. The tq lib is fantastic for changing the banners on the site for different partners, but I find when I come back to this code after a break, that it is slower for me to work out what is happening from the tq function name (set()) than reading some code. Usually, I have to find the library code and read that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, thanks! I just felt it would help simplify things. The library is already included so I thought, why not use it? The documentation is here: https://github.com/richardwestenra/tiny-query-string#set - it's linked to from the file where the library is included.

I guess the method name isn't as clear as it could've been - what would you have called it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardwestenra This just feels like a coding style thing, to me, which is absolutely fine. My style, in the lack of a framework (not inherently an issue), is just to use the standard browser API throughout this page. For me, that API is widely documented and doesn’t give contributors anything new to learn. Still, there are at least two sides to that debate. My general thoughts are the code should suit whoever is mostly taking ownership of the page. If that will be you, great, go ahead and make use of any libraries that can help.

The name should match the behaviour if possible. I wasn’t sure if there were any side-effects to the lib function, and so issues arise if called twice before a call, etc?


var keys = Object.keys(params);

keys.forEach(function (key, idx) {
if (idx > 0) {
url += "&";
}
url += key + "=" + params[key].toString();
});

url = remoteUrl + apiRoute + "?" + url;

return url;
return tinyQuery.set(params, remoteUrl + apiRoute);
}

function accessCarpoolvoteAPI (url, handlerFunction) {
Expand Down
32 changes: 11 additions & 21 deletions scripts/thanks.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
var data = tinyQuery.getAll();
var queryStringData = tinyQuery.getAll();

var heading = document.getElementById("thanks-header");
var introPara = document.getElementById("introPara");
var successInfo = document.getElementById("requestSuccessInfo");
var responseDetails = document.getElementById("responseDetails");
var responseCode = document.getElementById("responseCode");
var responseText = document.getElementById("responseText");
if (queryStringData.code !== '0') {
$('#thanks').hide();

var headingFailureText = document.getElementById("sorryHeading").innerHTML;
var paraFailureText = document.getElementById("sorryPara").innerHTML;
var responseInfo = ['code', 'info'].filter(function(d) {
return queryStringData[d];
})
.map(function(d) {
return '<p><small>Response ' + d + ': <b>' + queryStringData[d] + '</b></small></p>';
})
.join('');

if (data.code != "0") {
heading.innerHTML = headingFailureText;
introPara.innerHTML = paraFailureText;

successInfo.setAttribute("hidden", "hidden");
successInfo.setAttribute("style", "display:none");

responseDetails.removeAttribute("hidden");
responseDetails.setAttribute("style", "");

responseCode.innerHTML = data.code;
responseText.innerHTML = data.info;
$('#sorry').show().append(responseInfo);
}
7 changes: 7 additions & 0 deletions styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,13 @@ label {
margin-left:5px;
}

/* Thanks page */
.uuid--large {
display: block;
font-size: 1.5em;
margin: 5px 0 20px;
}

/* Self service page */
li.list_button{
list-style-type: none;
Expand Down