-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool.html
84 lines (77 loc) · 2.57 KB
/
tool.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
<!DOCTYPE html>
<html lang="zh-Hans">
<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">
<title>Tools</title>
<style>
textarea{
outline: 0 none;
border-radius: 3px;
box-shadow: 0 0 6px #000;
width: 49%;
zoom: 0.9;
}
a{
box-shadow: 0 0 6px #000;
border-radius: 3px;
padding: 6px;
text-align: center;
}
a:active{
box-shadow: 0 0 2px #000;
}
.poster-setting{
display: flex;
gap: 6px;
margin: 12px 0;
}
</style>
</head>
<body>
POSTER - SETTING
<a onclick="poster_json()">确定</a>
<a onclick="saveJSON(document.getElementById('json-show').innerHTML, 'poster.json')">下载</a>
<div id="count"></div>
<div class="poster-setting">
<textarea name="" id="poster-url" cols="100" rows="20"></textarea>
<textarea name="" id="json-show" cols="100" rows="20"></textarea>
<script>
function saveJSON(data, filename) {
if (!data) {
alert('data is null');
return;
}
if (!filename) {
filename = 'json.json'
}
if (typeof data === 'object') {
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {
type: 'text/json'
});
var e = document.createEvent('MouseEvents');
var a = document.createElement('a');
a.download = filename;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
}
function poster_json() {
let poster_url = document.getElementById('poster-url').value.split('\n');
document.getElementById('count').innerHTML = poster_url.length;
var data = {
"poster": poster_url
};
if (typeof data === 'object') {
data = JSON.stringify(data, undefined, 4)
}
document.getElementById('json-show').innerHTML = data;
};
</script>
</div>
</body>
</html>