-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.html
149 lines (131 loc) · 10.7 KB
/
frontend.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link id="favicon" rel="shortcut icon" type="image/x-icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAEBAQEAAQEBAQABAQEBAAABAQEBAAEBAQEAAQAAAQAAAQEBAQABAQEBAAEAAAEAAAEBAQEAAQEBAQABAQEBAAAAAAAAAAAAAAAAAAAAAAAAAQEBAQABAQEBAAEBAQEAAAEBAQEAAQAAAQABAQEBAAABAQEBAAEAAAEAAQEBAQAAAQEBAQABAQEBAAEBAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=">
<title>{{ title }}</title>
<style type="text/css">
body {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
background-color: #4c719e;
}
.paste {
margin: auto;
margin-top: 50px;
padding: 10px;
border: 4px solid #a59f80;
background-color: #c1c1c1;
width: 75%;
}
.content {
font-family: "Courier New", Courier, monospace;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
background-color: #999999;
width: 98%;
resize: none;
}
.controls {
margin: 10px;
margin-left: 0px;
margin-top: 20px;
overflow: hidden;
}
.submit {
margin-left: 10px;
float: left;
}
.events {
overflow: hidden;
padding-top: 3px;
padding-left: 10px;
}
.footer {
position: absolute;
margin-top: 10px;
left: 0px;
right: 0px;
color: #a59f80;
text-align: center;
}
.container {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow: auto;
background-color: #4c719e;
}
</style>
</head>
<body onload="document.getElementById('content').focus()">
<div class="container" style='background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAABvCAQAAACOJQAXAAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAADdcAAA3XAUIom3gAAAAHdElNRQfoARoXIBc7ObmUAAANsUlEQVR42u2ceXwURRbHv5mEM2A4Ei655RZFRTm8MIsoJi6ioqIiCrJ8PNYDXWFhl/VAPMELVBD5AAYBj/UEUUAXBBGIJHIYFgSSEIhAAiFDzplM1/5B0VT1HEwyPQl8dn79z/Sr7qp6r7tevas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ibpcwUS+w4kgnUXsI4v+0i1KrGkWQnc0a3ETw0iSrAsOsJejlFCCm5acSytaEA3sYQWf8T2CWtSjlCWczzsWQ+qsFMBJ/20Q19KaNnQgTm6uAjfZZJFDOisUNXhqbFHzL3E4Qg2NaEwsRRynUKkgiSCCCCKIIIIIIogggggiiCCCCCKIIIIIIogggggiiCCCCGoS/wPOYVF2q+4MKgAAAABJRU5ErkJggg==") no-repeat right bottom;'>
<div class="paste">
<form id="paste-form">
<textarea tabindex="1" class="content" id="content" columns=80 rows=30 spellcheck="false"></textarea>
<div class="controls">
<input id="paste" class="submit" type="button" tabindex="2" value="Create paste" />
<div id="events" class="events"></div>
</div>
</form>
</div>
<div id="footer" class="footer"></div>
<script>
function readableSize(size) {
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
return (size / Math.pow(1024, i)).toFixed(2) * 1 + '' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
}
function readableSeconds(raw_seconds) {
var sec_num = parseInt(raw_seconds, 10)
var hours = Math.floor(sec_num / 3600)
var minutes = Math.floor(sec_num / 60) % 60
var seconds = sec_num % 60
response = ""
if (hours > 0) {
response += hours + "h"
}
if (minutes > 0) {
response += minutes + "m"
}
if (seconds > 0) {
response += seconds + "s"
}
return response
}
window.addEventListener("DOMContentLoaded", function () {
var max_size = {{ max_size }}
var ttl = {{ ttl }}
document.getElementById("content").value = ""
document.getElementById("footer").innerHTML = "Powered by {{ title }}. Maximum allowed size is " + readableSize(max_size) + "; Content will be deleted after " + readableSeconds(ttl) + "<br/>"
document.getElementById("footer").innerHTML += "Unleash the full power of {{ title }} by adding the following alias to your profile:<br/>"
document.getElementById("footer").innerHTML += "<tt>alias np='curl --data-binary @- " + document.location.origin + "'</tt>"
document.getElementById("paste").addEventListener("click", function () {
var content = document.getElementById("content").value
if (content.length > max_size) {
document.getElementById("events").innerHTML = "ERROR: you tried to store " + readableSize(content.length) + ", and the maximum allowed size is " + readableSize(max_size)
return
}
var xhr = new XMLHttpRequest()
xhr.open("POST", "/", true)
xhr.send(content)
xhr.onload = (event) => {
if (xhr.status == 200) {
window.location.replace(xhr.responseURL)
} else {
document.getElementById("events").innerHTML = "ERROR: Something went wrong while storing your paste"
}
}
xhr.onerror = function() {
document.getElementById("events").innerHTML = "ERROR: Something went wrong while storing your paste"
}
})
})
</script>
</div>
</body>
</html>