-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (76 loc) · 3.29 KB
/
index.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<body>
<div style="margin: 10%;">
<h1>ILDeathmatch</h1>
<form id="form-parent" onSubmit="submitForm(); return false">
<div id="pointer-form" class="form-group">
<label for="payment-pointer">Payment Pointer Subdomain</label>
<input type="text" class="form-control" id="payment-pointer" placeholder="Enter Payment Pointer">
</div>
<button id="submit" type="button" class="btn btn-primary" disabled onclick="addPaymentPointer()">Submit</button>
</form>
<div id="pointer-message"></div>
</div>
</body>
<script src="/clientDm.js"></script>
<script>
var baseUrl = new URL(window.location)
function u8tohex(arr) {
var vals = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' ]
var ret = ''
for (var i = 0; i < arr.length; ++i) {
ret += vals[(arr[i] & 0xf0) / 0x10]
ret += vals[(arr[i] & 0x0f)]
}
return ret
}
function getRandomId() {
var idBytes = new Uint8Array(16)
crypto.getRandomValues(idBytes)
return u8tohex(idBytes)
}
function submitForm () {
const submit = document.getElementById('submit')
if (submit.classList.contains('disabled')) {
return
} else {
addPaymentPointer()
}
}
function addPaymentPointer () {
document.getElementById('pointer-message').innerHTML = 'Adding Pointer...'
const pointer = document.getElementById('payment-pointer').value
const monetizeId = document.cookie.split(';').filter(e => e.includes('monetizeId='))[0].split('=')[1]
console.log('monetizeId: ', monetizeId)
fetch(`http://${baseUrl.host}/addpointer/${monetizeId}/${pointer}`).then(res => {
console.log(res.status)
if(res.status === 200) {
document.getElementById('pointer-message').innerHTML = 'Pointer Added!'
window.location.href = `http://${baseUrl.host}/play?connect%20${baseUrl.hostname}:27960`
} else {
document.getElementById('pointer-message').innerHTML = 'Failed to ping pointer.'
}
})
}
window.addEventListener('load', function () {
const quake = document.getElementById('quake-game')
const socket = new WebSocket(`ws://${baseUrl.host}`)
socket.addEventListener('open', function (event) {
socket.send(JSON.stringify({ msg: 'New Client Connected' }))
})
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data)
if (event.data.includes('IP: ')) {
const id = getRandomId()
getMonetizationId(`http://${baseUrl.host}/pay/:id`, id)
document.cookie = 'monetizeId=' + id
document.getElementById('submit').removeAttribute('disabled')
}
})
})
</script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</html>