-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
146 lines (143 loc) · 3.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>word转html助手</title>
<link rel="shortcut icon" href="img/favicon.png" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/clipboard.min.js"></script>
<script src="js/creat_html.js"></script>
<script src="js/FileSaver.js"></script>
</head>
<style>
#preview {
display: none;
}
#preview article {
width: 950px;
margin: 50px auto
}
#preview article img {
max-width: 100%;
}
body.preview-mode #home {
display: none;
}
body.preview-mode #preview {
display: block;
}
.close {
position: fixed;
right: 50px;
top: 50px;
display: inline-block;
font-size: 30px;
text-align: center;
color: #aaa;
cursor: pointer;
}
</style>
<body>
<div id="home">
<div class="banner">
<div class="container">
<h1>
<a href="/">word转html助手</a>
<a style="float: right" href="https://github.com/zaaack/word2html">
<img src="https://img.shields.io/github/stars/zaaack/word2html?style=social" alt="">
</a>
</h1>
</div>
</div>
<div class="container">
<h3 style="width: 620px;">文件预览区</h3>
<input
id="document"
type="file"
onChange="if(this.value)insertTitle(this.value);"
/>
<!-- # 水平布局区-->
<div class="row">
<div class="span8">
<div id="output" class="well2"></div>
</div>
</div>
</div>
<p></p>
<div class="container" style="margin-bottom: 50px;">
<h3>工具选项</h3>
<div class="display-flex">
<button onclick="download_text()">下载txt</button>
<button onclick="download_html()">下载html</button>
<button onclick="open_html()">剪藏或打印</button>
</div>
</div>
</div>
<div id="preview">
<div class="close" onclick="exitPreview()">X</div>
<article>
</article>
</div>
<script src="js/mammoth.browser.js"></script>
<script src="js/demo.js"></script>
<script>
var clipboard = new ClipboardJS('.btn')
var $=document.querySelector.bind(document)
clipboard.on('success', function (e) {
console.log(e)
alert('复制到剪辑板成功')
})
clipboard.on('error', function (e) {
console.log(e)
alert('复制到失败,换谷歌浏览器吧')
})
function getHtml() {
return document.getElementById('output').innerHTML
}
function download_text() {
let value = getHtml()
let file_name2 = window.file_name + '.txt'
downloadText(value, file_name2)
}
function download_html() {
let value = getHtml()
let file_name2 = window.file_name + '.html'
downloadText(value, file_name2)
}
function downloadText(data, filename2) {
let blob = new Blob([data], { type: 'text/html;charset=utf-8,' })
saveAs(blob, filename2)
}
function open_html() {
let html = `
<h1>${window.file_name}</h1>
${getHtml()}
`
$('#preview article').innerHTML = html
$('body').classList.add('preview-mode')
}
function exitPreview() {
$('body').classList.remove('preview-mode')
}
</script>
<script src="./js/upup.min.js"></script>
<script>
UpUp.start({
'content-url': 'index.html',
assets: [
'./',
'./index.html',
'./css/style.css',
'./img/favicon.png',
'./js/clipboard.min.js',
'./js/creat_html.js',
'./js/demo.js',
'./js/FileSaver.js',
'./js/mammoth.browser.js',
'./js/upup.min.js',
],
'service-worker-url': '/word2html/upup.sw.min.js',
})
</script>
</body>
</html>