Explorar el Código

Added submitting message for before test form. Added start button for test form and moved timer.

Alan Lam hace 8 años
padre
commit
7f5ef00446
Se han modificado 2 ficheros con 36 adiciones y 18 borrados
  1. 11 13
      engine/template.php
  2. 25 5
      public/js/app-test.js

+ 11 - 13
engine/template.php

@@ -20,7 +20,7 @@ class Template extends Model {
 		$fields = $json->beforeTest;
 		$fields = $json->beforeTest;
 
 
 		?>
 		?>
-		<form method="post" enctype="multipart/form-data">
+		<form method="post" enctype="multipart/form-data" id="before-test-form">
 
 
 			<div class="alert alert-info">
 			<div class="alert alert-info">
 				<i class="fal fa-fw fa-info-circle"></i>
 				<i class="fal fa-fw fa-info-circle"></i>
@@ -33,14 +33,12 @@ class Template extends Model {
 			}
 			}
 			?>
 			?>
 
 
-			<div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 0px;">
-
-				<button class="btn btn-block btn-success" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Start Test</button>
-				<small data-test-no-internet-text class="form-text text-success">
-					Tap this button just before you enter the venue and wait for the form to submit.
-				</small>
+			<button class="btn btn-primary" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Start Test</button><br />
 
 
+			<div class="d-none mt-3" data-submitting-div>
+				<i class="fal fa-fw fa-pulse fa-spinner"></i> Please wait a moment while the form submits.
 			</div>
 			</div>
+
 		</form>
 		</form>
 		<?php
 		<?php
 	}
 	}
@@ -58,13 +56,13 @@ class Template extends Model {
 			<div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
 			<div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
 
 
 				<div>
 				<div>
-					<button class="btn btn-block btn-danger" type="button" id="test-stop-button">
-						Stop Test<br />
-						<small><span id="test-duration-span">0 min. 0 sec.</span></small>
+					<button class="btn btn-block btn-success" type="button" id="test-start-button">
+						Start Test
+					</button>
+					<button class="btn btn-block btn-danger" type="button" id="test-stop-button" style="display: none;">
+						Stop Test
 					</button>
 					</button>
-					<small data-test-no-internet-text class="form-text text-danger">
-						Tap this button when you are outside of the venue.
-					</small>
+					<small><span id="test-duration-span">0 min. 0 sec.</span></small>
 				</div>
 				</div>
 			</div>
 			</div>
 
 

+ 25 - 5
public/js/app-test.js

@@ -1,18 +1,27 @@
 $(function() {
 $(function() {
+	initialiseBeforeTestForm();
 	initialiseTestForm();
 	initialiseTestForm();
 });
 });
 
 
 var durationInterval = false;
 var durationInterval = false;
 var testStartTime = null;
 var testStartTime = null;
 
 
-function initialiseTestForm() {
+function initialiseBeforeTestForm() {
+	$("#before-test-form").on("submit", function() {
 
 
-	var date = new Date();
-	testStartTime = date.getTime();
+		$(this).find("button").attr("disabled", "");
+		$(this).find("div[data-submitting-div]").removeClass("d-none");
+
+	});
+}
+
+function initialiseTestForm() {
 
 
 	$form = $("#test-form");
 	$form = $("#test-form");
 
 
 	$stopButtonContainer = $("#test-stop-button-container");
 	$stopButtonContainer = $("#test-stop-button-container");
+
+	$startButton = $("#test-start-button");
 	$stopButton = $("#test-stop-button");
 	$stopButton = $("#test-stop-button");
 
 
 	$submitButtonContainer = $("#test-submit-button-container");
 	$submitButtonContainer = $("#test-submit-button-container");
@@ -22,6 +31,19 @@ function initialiseTestForm() {
 
 
 	$submitStatus = $("#test-submit-status");
 	$submitStatus = $("#test-submit-status");
 
 
+	$startButton.on("click", function(event) {
+		event.preventDefault();
+
+		var date = new Date();
+		testStartTime = date.getTime();
+
+		$startButton.hide();
+		$stopButton.show();
+
+		durationInterval = setInterval(updateDurationText, 1000);
+
+	});
+
 	$stopButton.on("click", function(event) {
 	$stopButton.on("click", function(event) {
 
 
 		event.preventDefault();
 		event.preventDefault();
@@ -41,8 +63,6 @@ function initialiseTestForm() {
 
 
 	});
 	});
 
 
-	durationInterval = setInterval(updateDurationText, 1000);
-
 
 
 	$form.on("submit", function(event) {
 	$form.on("submit", function(event) {