-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
169 lines (153 loc) · 4.6 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<html>
<head>
<title>HashBin</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<style>
body, textarea, input, #tools {
background-color: #002b36;
color: #93a1a1;
font: 14px/20px monospace;
padding: 0;
margin: 0;
}
body:before {
position: fixed;
content: '>';
z-index: 1000;
text-align: center;
margin-top: 60px;
width: 30px;
color: #586e75;
}
#t {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: auto;
outline: none;
border: none;
box-sizing: border-box;
padding: 60px 30px 30px 30px;
}
a {
text-decoration: none;
color: #268bd2;
}
#tools {
text-align: center;
padding: 20px;
z-index: 1000;
width: 100%;
position: fixed;
top: 0;
box-sizing: border-box;
}
input {
display: none;
margin-top: 5px;
width: 100%;
border: 1px solid #268bd2;
padding: 5px;
border-radius: 3px;
}
/* Light color theme */
body, textarea, input, #tools {
background-color: #fdf6e3;
color: #586e75;
}
body:before {
color: #93a1a1;
}
@media (min-width: 600px) {
#tools {
padding: 10px 20px 0 0;
right: 0;
width: auto;
background: none;
}
body:before {
margin-top: 30px;
width: 50px;
}
#t {
padding: 30px 50px 30px 50px;
}
}
</style>
</head>
<body>
<div id='tools'>
<a href='#' id='share'>Share</a> |
<a href='#' id='new'>New</a> |
<a href='#' id='download' download='hashbin-download.txt'>Download</a> |
<a href='https://github.com/captbaritone/hashb.in' target='_blank'>?</a>
<input id='urlInput'>
</div>
<textarea spellcheck="false" id="t">HashBin is a paste bin that never sees the contents of its pastes.
I posit, that it should be immune to takedown notices.
- Click "New" to create your own paste
- Click "?" to learn more
--
Jordan Eldrege (@captbaritone)</textarea>
<script language="javascript" src="js/lz-string.min.js"></script>
<script>
var f;
var textarea = document.getElementById("t");
var urlInput = document.getElementById("urlInput");
var download = document.getElementById('download');
var content = LZString.decompressFromBase64(window.location.hash.slice(1));
if(content) {
textarea.value = content;
}
processContent(); // Update urlInput and download link
function processContent() {
window.location.hash = hash();
urlInput.value = window.location;
document.title = title();
download.setAttribute('download', filename());
download.href = downloadUri();
}
function hash() {
return LZString.compressToBase64(textarea.value);
}
function title() {
return textarea.value ? textarea.value.slice(0,30) : 'HashBin';
}
function filename() {
return title().replace(/[^a-z0-9]/gi, '_').toLowerCase() + '.txt';
}
function downloadUri() {
return "data:text/plain," + encodeURIComponent(textarea.value);
}
function contentChanged() {
clearInterval(f);
f = setTimeout(function() {
processContent();
}, 500);
}
function share() {
urlInput.style.display = "block";
urlInput.select();
return false;
}
function unshare() {
urlInput.style.display = "none";
}
function clear() {
textarea.value = '';
unshare();
textarea.focus();
processContent();
return false;
}
textarea.onkeyup = contentChanged;
textarea.onpaste = contentChanged;
textarea.onfocus = unshare;
document.getElementById('share').onclick = share;
document.getElementById('new').onclick = clear;
</script>
</body>
</html>