-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
41 lines (33 loc) · 1018 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var base_api = "https://motus-express.herokuapp.com"
function post (path, values) {
fetch(`${base_api}/${path}`, {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: values,
})
}
function motusjs () {
var userid = document.querySelector('meta[name="motustracker"]').content;
if (userid) {
console.log('MotusJS initialized')
} else {
console.log('MotusJS failed to run. Failed to find meta tag.')
}
window.addEventListener('submit', function (e) {
var form = e.target
var values = Object.values(form).reduce(
(obj, field) => {
obj[field.name] = field.value
return obj
}, {}
)
values.path = window.location.pathname
post(`clubos/texasfamilyfitness`, JSON.stringify(values))
});
}
document.addEventListener("DOMContentLoaded", function (event) {
motusjs()
});