Includes requesting permissions and adding a basic service worker as well as re-working and restructuring a bunch of the existing logic for parsing URL parameters, sending data and adding another form field
		
			
				
	
	
		
			80 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
	<head>
 | 
						|
		<title>FTracker</title>
 | 
						|
		<meta charset="utf-8">
 | 
						|
		<meta name="theme-color" content="#c50e1f">
 | 
						|
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 | 
						|
		<link href="style.css" rel="stylesheet" type="text/css">
 | 
						|
		<script>
 | 
						|
			// 1st script, prepares values needed for writing document
 | 
						|
			var cbt = {
 | 
						|
				'arrival': 'I have read and will adhere to the <a href="/guidelines" target="_blank">protection guidelines</a>',
 | 
						|
				'departure': 'I have cleaned my workspace'
 | 
						|
			}
 | 
						|
			var testCheckBox = '<label class="checkbox"><input type="checkbox" name="tested" id="tested"><span>I have been tested negative for COVID in the last 24 hours</span></label>'
 | 
						|
			var editTimeBox = '<label>Departure Date/Time:<input type="datetime-local" name="datetime" id="datetime" required></label>'
 | 
						|
			function getParams() {
 | 
						|
				var qparams = document.location.search.substr(1)
 | 
						|
				if (qparams == "") return {}
 | 
						|
				qparams = qparams.split('&')
 | 
						|
				var qps = {}
 | 
						|
				for (var qparam of qparams) {
 | 
						|
					var vals = qparam.split('=')
 | 
						|
					qps[vals[0]] = vals[1] || null
 | 
						|
				}
 | 
						|
				// Backwards compat
 | 
						|
				if (qps.arrival)   {qps.action = 'arrival';   qps.room = qps.arrival}
 | 
						|
				if (qps.departure) {qps.action = 'departure'; qps.room = qps.departure}
 | 
						|
				return qps
 | 
						|
			}
 | 
						|
			var qp = getParams()
 | 
						|
		</script>
 | 
						|
	</head>
 | 
						|
	<body>
 | 
						|
		<h1><script>
 | 
						|
			document.write(qp.action ? (qp.action + "<br>Room " + qp.room) : 'FTracker<br>V1')
 | 
						|
		</script></h1>
 | 
						|
		<div id="startpage">
 | 
						|
			This is a web app to track which people
 | 
						|
			were in the same rooms at which times in order to backtrace
 | 
						|
			potential viral infections.<br><br>
 | 
						|
			If you've reached this page that either means your're
 | 
						|
			testing things or something has gone quite wrong with the\
 | 
						|
			URL.<br>
 | 
						|
			In the former case: Yay it works! In the latter you should
 | 
						|
			probably contact an admin or a dev nearby :(<br><br>
 | 
						|
			Here are a few links for testing:<br>
 | 
						|
			<a href="/view">View Data</a>,
 | 
						|
			<a href="/QRgen">Door Sign Generator</a>,
 | 
						|
			<a href="/?arrival=42">Test Arrival</a>,
 | 
						|
			<a href="/?departure=42">Test Departure</a><br><br>
 | 
						|
			© 2020 made by <a target="_blank" href="mailto:o.winkels@fasttube.de">Oskar</a>
 | 
						|
			for <a target="_blank" href="//fasttube.de">FaSTTUBe</a>.<br>
 | 
						|
			For source code & licensing see <a href="//git.fasttube.de/FaSTTUBe/ftracker">git repo</a>
 | 
						|
		</div>
 | 
						|
		<form id="mainform" style="display: none">
 | 
						|
			<label>
 | 
						|
				Full Name:<br>
 | 
						|
				<input type="text" name="name" id="name" placeholder="John Doe" required>
 | 
						|
			</label>
 | 
						|
			<script>
 | 
						|
				if (qp.edittime && qp.edittime == 1)
 | 
						|
					document.write(editTimeBox)
 | 
						|
			</script>
 | 
						|
			<label class="checkbox">
 | 
						|
				<input type="checkbox" name="agree" id="agree" required>
 | 
						|
				<span><script>
 | 
						|
					document.write(qp ? cbt[qp.action] : '')
 | 
						|
				</script></span>
 | 
						|
			</label>
 | 
						|
			<script>
 | 
						|
				if (qp.action && qp.action == 'arrival')
 | 
						|
					document.write(testCheckBox)
 | 
						|
			</script>
 | 
						|
			<input type="submit">
 | 
						|
		</form>
 | 
						|
		<script src="main.js"></script>
 | 
						|
	</body>
 | 
						|
</html>
 |