diff --git a/web/index.html b/web/index.html
index a3148bc..1d4c56f 100644
--- a/web/index.html
+++ b/web/index.html
@@ -13,25 +13,27 @@
'departure': 'I have cleaned my workspace'
}
var testCheckBox = ''
+ var editTimeBox = ''
function getParams() {
- var h = document.location.href
- var qparam = h.split('?')[1] || null
- if (qparam == null)
- return null
- var vals = qparam.split('=')
- if (vals.length < 2 || !cbt.hasOwnProperty(vals[0]))
- return null
- return {
- action: vals[0],
- room: vals[1]
+ 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()
This is a web app to track which people
@@ -56,6 +58,10 @@
Full Name:
+
diff --git a/web/main.js b/web/main.js
index 38d0e83..6e6b6f0 100644
--- a/web/main.js
+++ b/web/main.js
@@ -1,7 +1,9 @@
+var pushServerPublicKey = 'BBwBPYxhogHLU3B1FpxfQNzO3q7qZpmD1n1KaaL8WJbcVmJSHhi1uB-VmvsVjjUHWYCeqKyLT7w-1LBfpIcbbcg'
+
var spage = document.getElementById('startpage')
var mform = document.getElementById('mainform')
-if (qp) {
+if (qp.action) {
spage.style.display = 'none'
mform.style.display = 'block'
}
@@ -12,18 +14,26 @@ if (savedName && qp)
document.getElementById('name').value = savedName
// 2nd script, server API communication
-var name, agreed, tested
+var name, datetime, agreed, tested
mform.onsubmit = function(e) {
e.preventDefault()
- name = e.srcElement[0].value
- agreed = e.srcElement[1].checked
- if (e.srcElement.length > 2)
- tested = e.srcElement[2].checked
+ var i = 0;
+ name = e.srcElement[i++].value
+ if (qp.edittime && qp.edittime == 1) {
+ var value = e.srcElement[i++].value
+ datetime = new Date(value).toISOString()
+ }
+ agreed = e.srcElement[i++].checked
+ if (qp.action && qp.action == 'arrival')
+ tested = e.srcElement[i++].checked
+
sendMainData()
+ initPush(name)
+
}
function sendMainData() {
@@ -33,11 +43,13 @@ function sendMainData() {
{
'room': qp.room,
'name': name,
+ 'arrival': datetime,
'agreetoguidelines': agreed,
'tested': tested
} :
{
'name': name,
+ 'departure': datetime,
'cleanedworkspace': agreed
}
@@ -159,7 +171,7 @@ function handleRequest(res) {