-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
61 lines (54 loc) · 2 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
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<head>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/offer-viewer.css">
<script type="text/javascript" src="dist/offer-viewer.min.js"></script>
</head>
<body>
<offer></offer>
<div id="error"></div>
</body>
<script>
function getQueryParam(param) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == param){return pair[1];}
}
return undefined;
}
var repositoryId = getQueryParam('repository');
var offerId = getQueryParam('offer');
var errMsg = '';
if (repositoryId === undefined) {
errMsg += 'Error: Missing required query parameter "repository". <br>';
}
if (offerId === undefined) {
errMsg += 'Error: Missing required query parameter "offer". <br>';
}
if (errMsg) {
var err = document.getElementById('error');
err.innerHTML = errMsg;
} else {
var url = 'https://query.copyrighthub.org/v1/query/entities/' + repositoryId + '/offer/' + offerId;
var request = new XMLHttpRequest();
request.open('GET', url);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
request.onload = function () {
if (request.status === 200) {
var response = JSON.parse(request.responseText);
new OfferViewer(response.data);
} else {
var error = new Error(request.statusText);
error.response = request;
throw error
}
};
request.send();
}
</script>
</html>