-
Notifications
You must be signed in to change notification settings - Fork 0
/
___move___.html
116 lines (102 loc) · 3.15 KB
/
___move___.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- style -->
<style type='text/css'>
html, body{
height: 100%;
}
.place-list {
position: fixed;
height: calc(100% - 48px);
left: 0;
right: 0;
bottom: 48px;
overflow: auto;
}
.place-list .welcome {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
.welcome .btn {
width: 90%;
margin-bottom: 10px;
}
.bottom {
position: fixed;
height: 48px;
left: 0;
right: 0;
bottom: 0px;
}
.bottom .btn {
border-radius: 0px;
}
</style>
<title>บันทึกไทยชนะ</title>
</head>
<body>
<!-- list -->
<div class='place-list'>
<div class='welcome'>
<h3>Export / Import Data</h3>
<a class='btn btn-primary btn-lg btn-export' href='#'>Export Data</a>
<a class='btn btn-danger btn-lg btn-import' href='#'>Import Data</a>
</div>
</div>
<!-- back bottom -->
<div class='bottom'>
<a class='btn btn-back btn-lg btn-secondary w-100' href='./index.html'>ถอยกลับ</a>
</div>
<!-- bottom scripts -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
<!-- app scripts -->
<script src="https://diewland.github.io/disk.js/dist/disk.js"></script>
<script src="./app.js"></script>
<script>
// copy export data to clipboard
let clipboard = new ClipboardJS('.btn-export', {
text: _ => {
let export_data = {};
export_data[APP_TITLE] = Db.list();
export_data[KEY_HISTORY] = Db.list_history();
return JSON.stringify(export_data);
},
});
clipboard.on('success', e => {
// console.log('success', e);
alert("Copied export data to clipboard");
});
clipboard.on('error', e => {
// console.log('error', e);
});
// import data
$('.btn-import').click(_ => {
let go = confirm('Device data will be overwrite, Press OK to continue.');
if (!go) return;
let s = prompt("Paste export data");
if (!s) return;
try {
let export_data = JSON.parse(s);
for (let k in export_data) {
let v = export_data[k];
Disk.set(k, v);
}
location.href = "./index.html";
}
catch (err) {
alert(err);
}
});
</script>
</body>
</html>