Allow giving test result even on retroactive arrivals (Resolves #25)
This commit is contained in:
parent
73241c4116
commit
cb6568ea46
@ -12,6 +12,7 @@
|
|||||||
'arrival': 'I have read and will adhere to the <a href="/guidelines" target="_blank">protection guidelines</a>',
|
'arrival': 'I have read and will adhere to the <a href="/guidelines" target="_blank">protection guidelines</a>',
|
||||||
'departure': 'I have cleaned my workspace'
|
'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>'
|
||||||
function getParams() {
|
function getParams() {
|
||||||
var h = document.location.href
|
var h = document.location.href
|
||||||
var qparam = h.split('?')[1] || null
|
var qparam = h.split('?')[1] || null
|
||||||
@ -66,7 +67,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<script>
|
<script>
|
||||||
if (qp && qp.action == 'arrival')
|
if (qp && qp.action == 'arrival')
|
||||||
document.write('<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>')
|
document.write(testCheckBox)
|
||||||
</script>
|
</script>
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
||||||
|
13
web/main.js
13
web/main.js
@ -51,6 +51,7 @@ function post(url, payload) {
|
|||||||
|
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
handleResponse(res)
|
handleResponse(res)
|
||||||
@ -92,13 +93,17 @@ function handleRequestSubmit(e, json) {
|
|||||||
var input = e.srcElement[0].value
|
var input = e.srcElement[0].value
|
||||||
var iso = new Date(input).toISOString()
|
var iso = new Date(input).toISOString()
|
||||||
|
|
||||||
|
if (e.srcElement.length > 1)
|
||||||
|
tested = e.srcElement[1].checked
|
||||||
|
|
||||||
// POST JSON. See docs/API.md
|
// POST JSON. See docs/API.md
|
||||||
var payload = (json.request == 'arrival') ?
|
var payload = (json.request == 'arrival') ?
|
||||||
{
|
{
|
||||||
'room': qp.room,
|
'room': qp.room,
|
||||||
'name': name,
|
'name': name,
|
||||||
'arrival': iso,
|
'arrival': iso,
|
||||||
'agreetoguidelines': agreed
|
'agreetoguidelines': agreed,
|
||||||
|
'tested': tested
|
||||||
} :
|
} :
|
||||||
{
|
{
|
||||||
'name': name,
|
'name': name,
|
||||||
@ -133,6 +138,7 @@ function handleRequest(res) {
|
|||||||
var aInfo = ''
|
var aInfo = ''
|
||||||
var minD = ''
|
var minD = ''
|
||||||
var doubleT = ''
|
var doubleT = ''
|
||||||
|
var testCheck = ''
|
||||||
if (json.request == 'departure') {
|
if (json.request == 'departure') {
|
||||||
var d = new Date(json.arrival.time)
|
var d = new Date(json.arrival.time)
|
||||||
var dInfo = d.toString('en-GB').split(' ').slice(0,5).join(' ')
|
var dInfo = d.toString('en-GB').split(' ').slice(0,5).join(' ')
|
||||||
@ -141,6 +147,8 @@ function handleRequest(res) {
|
|||||||
if (new Date() - d < 3 * 60 * 1000) {
|
if (new Date() - d < 3 * 60 * 1000) {
|
||||||
doubleT = '<b style="color:red">Your last sign in was less than 3 minutes ago. You might be accidentally trying to sign in twice. If you don\'t intend to log 2 arrivals within the last 3 minutes, please abort below.</b>'
|
doubleT = '<b style="color:red">Your last sign in was less than 3 minutes ago. You might be accidentally trying to sign in twice. If you don\'t intend to log 2 arrivals within the last 3 minutes, please abort below.</b>'
|
||||||
}
|
}
|
||||||
|
} else if (json.request == 'arrival') {
|
||||||
|
testCheck = testCheckBox.replace('have', 'had then');
|
||||||
}
|
}
|
||||||
|
|
||||||
var now = localISOTimeMinutes(new Date())
|
var now = localISOTimeMinutes(new Date())
|
||||||
@ -155,12 +163,13 @@ function handleRequest(res) {
|
|||||||
${aInfo}
|
${aInfo}
|
||||||
</label>
|
</label>
|
||||||
${doubleT}
|
${doubleT}
|
||||||
|
${testCheck}
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
<input type="button" value="Abort" onclick="document.body.innerHTML='<h1>Aborted</h1><form>Nothing was logged.<br>You can close this tab/window now.</form>'">
|
<input type="button" value="Abort" onclick="document.body.innerHTML='<h1>Aborted</h1><form>Nothing was logged.<br>You can close this tab/window now.</form>'">
|
||||||
</form>
|
</form>
|
||||||
</div>`
|
</div>`
|
||||||
|
|
||||||
rform = document.getElementById('reqform')
|
var rform = document.getElementById('reqform')
|
||||||
rform.onsubmit = async function(e) {
|
rform.onsubmit = async function(e) {
|
||||||
await handleRequestSubmit(e, json)
|
await handleRequestSubmit(e, json)
|
||||||
document.querySelector('.request').remove()
|
document.querySelector('.request').remove()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user