-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
64 lines (55 loc) · 2.23 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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>trusted_auth_demo</title>
</head>
<body>
<div class="container" style="margin-top: 2em">
<form id="form" action="/api">
<div class="form-group">
<label for="username">Username:</label>
<input class="form-control" id="username" name="username" />
</div>
<div class="form-group">
<label for="share_link">Share Link:</label>
<input class="form-control" id="share_link" name="share_link" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div class="container" style="margin-top: 2em">
<pre id="response">
</pre>
</div>
<div class="container text-center" id="containerDiv">
</div>
<script>
document.forms['form'].addEventListener('submit', function (event) {
event.preventDefault();
fetch(event.target.action, {
method: 'POST',
body: new URLSearchParams(new FormData(event.target))
}).then(function (res) {
return res.json();
}).then(function (body) {
document.getElementById("response").innerText = JSON.stringify(body);
if (body.ticket === '-1') {
return;
}
let url = new URL(document.getElementById('share_link').value);
url.pathname = '/trusted/' + body.ticket + url.pathname;
let iframe = document.createElement('iframe');
iframe.src = url.href;
iframe.width = '800px';
iframe.height = '600px';
document.getElementById("containerDiv").appendChild(iframe);
});
});
</script>
</body>
</html>