-
Notifications
You must be signed in to change notification settings - Fork 50
/
index.html
89 lines (76 loc) · 2.66 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
85
86
87
88
89
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
<title>Stencil Component Starter</title>
<style>
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
img {
max-width: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/exif-js"></script>
<script type="module" src="/build/ionicpwaelements.esm.js"></script>
<script nomodule src="/build/ionicpwaelements.js"></script>
</head>
<body>
<div id="target">
</div>
<button id="camera-button">Open Camera</button>
<button id="toast-button">Open Toast</button>
<button id="action-sheet-button">Open Action Sheet</button>
<script>
var b = document.querySelector('#camera-button');
b.addEventListener('click', async (ev) => {
const camera = document.createElement('pwa-camera-modal');
document.body.appendChild(camera);
await camera.componentOnReady();
camera.addEventListener('noDeviceError', async (e) => {
console.log('NO DEVICE', e);
});
camera.addEventListener('onPhoto', async (e) => {
const photo = e.detail;
console.log('CAMERA ON PHOTO', photo);
if (photo && !(photo instanceof Error)) {
const url = window.URL.createObjectURL(photo);
const img = document.querySelector('#img') || document.createElement('img');
img.src = url;
img.id = 'img';
img.parentNode && img.parentNode.removeChild(img);
document.body.appendChild(img);
} else if (photo) {
console.error(photo.message);
}
// Hide the modal
await camera.dismiss();
document.body.removeChild(camera);
})
camera.present();
});
var b = document.querySelector('#toast-button');
b.addEventListener('click', async (ev) => {
const toast = document.createElement('pwa-toast');
toast.message = 'Hello, Moto!';
document.body.appendChild(toast);
});
var b = document.querySelector('#action-sheet-button');
b.addEventListener('click', async (ev) => {
const actionSheet = document.createElement('pwa-action-sheet');
actionSheet.header = 'choose option';
actionSheet.cancelable = false;
actionSheet.options = [{title: 'hi'},{title: 'bye', style: "DESTRUCTIVE"},{title: 'cancel', style: "CANCEL"}]
document.body.appendChild(actionSheet);
actionSheet.addEventListener('onSelection', async (e) => {
const selection = e.detail;
console.log('selected', selection);
})
});
</script>
</body>
</html>