-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
56 lines (48 loc) · 2.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="/lib/index.js"></script>
<title>Simple Example</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<span class="navbar-brand">Example Service</a>
</nav>
<div class="container mt-4">
<div class="list-group">
<a href="#" data-id="1" class="list-group-item list-group-item-action">Cras justo odio</a>
<a href="#" data-id="2" class="list-group-item list-group-item-action">Dapibus ac facilisis in</a>
<a href="#" data-id="3" class="list-group-item list-group-item-action">Morbi leo risus</a>
<a href="#" data-id="4" class="list-group-item list-group-item-action">Porta ac consectetur ac</a>
<a href="#" data-id="5" class="list-group-item list-group-item-action">Vestibulum at eros</a>
</div>
</div>
<script>
// DSW Widget: Instantiate the widget
const dswWidget = new dsw.IntegrationWidget('localhost')
// DSW Widget: Wait for the initialzation
dswWidget.init().then(() => {
console.log('widget initialized')
// Example: Clicking on item in the list group will send the values back
document.querySelectorAll('.list-group a').forEach((el) => {
el.onclick = () => {
const id = el.dataset.id // we need id
const value = el.innerHTML // and visible value
// DSW Widget: Send the values back to the DSW
dswWidget.send(value, id)
// Example: Close the popup window after the selection is done
window.close()
}
})
}).catch((error) => {
// Example: Handle the error
console.error(error)
})
</script>
</body>
</html>