-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (59 loc) · 1.95 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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css">
<link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">
<script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>
</head>
<script>
document.addEventListener('init', function(event) {
var page = event.target;
function showPosition(position) {
page.querySelector('#latlng').innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude;
let Data = {
latitude:position.coords.latitude,
longitude:position.coords.longitude
};
const Params = {
headers:{
'Content-Type':'application/json'
},
body:JSON.stringify(Data),
method:'POST'
};
console.log(JSON.stringify(Data));
fetch(Url, Params).then(data=>{return data.json();}).then(res=>{console.log(res);});
}
if (page.id === 'page1') {
page.querySelector('#push-button').onclick = function() {
document.querySelector('#myNavigator').pushPage('page2.html', {data: {title: 'Page 2'}});
};
} else if (page.id === 'page2') {
page.querySelector('ons-toolbar .center').innerHTML = page.data.title;
navigator.geolocation.getCurrentPosition(showPosition);
}
});
</script>
<body>
<ons-button onclick="alert('Hello World!')">Click Me</ons-button>
<ons-navigator swipeable id="myNavigator" page="page1.html"></ons-navigator>
<template id="page1.html">
<ons-page id="page1">
<ons-toolbar>
<div class="center">Page 1</div>
</ons-toolbar>
<p>This is the first page.</p>
<ons-button id="push-button">Push page</ons-button>
</ons-page>
</template>
<template id="page2.html">
<ons-page id="page2">
<ons-toolbar>
<div class="left"><ons-back-button>Page 1</ons-back-button></div>
<div class="center"></div>
</ons-toolbar>
<p id="latlng">This is the second page.</p>
</ons-page>
</template>
</body>
</html>