-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.go
More file actions
91 lines (83 loc) · 2.46 KB
/
html.go
File metadata and controls
91 lines (83 loc) · 2.46 KB
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
package main
const letter = `
<!DOCTYPE html>
<html>
<head>
<title>Temporary text sharing - Temporary Web note - 临时文本 - 临时笔记</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Temporary text web sharing Tool, Temporary note web sharing - 临时文本分享工具, 临时笔记">
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 1rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-weight: bold;
border-radius: 6px;
}
</style>
</head>
<body>
<a href="https://github.com/kissjacky/tempnote"><img style="position: absolute; top: 0; right: 0; border: 0;" src="/static/github-fork.png" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"></a>
<textarea style="width:100%;height:800px;font-size: 20px;" placeholder="Input some words" name="data">{{.Data}}</textarea>
<div style="
position: fixed;
bottom: 10%;
width: 100%;
text-align: center;
"><button class="button" id="share">Share Page</button></div>
<button id="copy" style="display:none" data-clipboard-text=""></button>
<script src="/static/clipboard.2.0.4.min.js"></script>
<script>
let key='';
window.onload=function(){
clipboard = new ClipboardJS('#copy');
clipboard.on('success', function(e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
alert('Share Url Copied');
});
clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
alert(key);
});
let s=document.querySelector('#share');
let c=document.querySelector('textarea');
c.onkeypress=function(e){
}
s.onclick=function(e){
s.setAttribute('disabled','');
let content=c.value;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
key=xmlhttp.responseText;
s.removeAttribute('disabled');
document.querySelector('#copy').setAttribute('data-clipboard-text',location.protocol+'//'+location.host+'/'+key);
document.querySelector('#copy').click();
}
}
xmlhttp.open("POST","/save",true);
xmlhttp.send(content);
}
}
</script>
</body>
</html>
`