-
Notifications
You must be signed in to change notification settings - Fork 2
/
annotator.html
59 lines (54 loc) · 1.92 KB
/
annotator.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 lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"/>
<title>Image Annotator demo with list</title>
<script src="/exist/apps/ecpo/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/exist/apps/ecpo/bower_components/polymer/lib/elements/custom-style.html"></script>
<link rel="import" href="/exist/apps/ecpo/components/ecpo-app.html"/>
<style>
.seamless {
padding:0;
margin: 0;
}
#navigatorDiv {
height: 200px;
width: 100%;
}
</style>
</head>
<body class="seamless">
<ecpo-app></ecpo-app>
<script>
document.addEventListener('WebComponentsReady', function () {
// look for URL parameter
const url = new URL(window.location)
const documentId = url.searchParams.get('document')
if (documentId) {
console.log('loading document:', documentId)
return document.querySelector('ecpo-app').setAttribute('document', documentId)
}
// load random image from list
console.log('Loading random Image ...')
fetch('/documents/', { method: 'GET', credentials: 'same-origin' })
.then(function(response) {
if(!response.ok){
return console.error(response)
}
return response.json()
})
.then(function (list) {
console.log('Image list loaded:', list)
const items = list.images.length
const randomIndex = Math.floor(Math.random() * items)
const randomImageId = list.images[randomIndex].id
console.log('Loading image:', randomImageId)
document.querySelector('ecpo-app').setAttribute('document', randomImageId)
})
.catch(function (reason) {
return console.error(reason)
})
})
</script>
</body>
</html>