-
Notifications
You must be signed in to change notification settings - Fork 1
/
body-mapping.html
241 lines (216 loc) · 10.4 KB
/
body-mapping.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<html itemtype="http://schema.org/WebPage" lang="en">
<head>
<title>URL Shortner | tiny URL trim.live</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="title" content="URL Shortner">
<meta name="description" content="trim.live provides free and fast url shortning and will work forever. We don't clear the results and you can keep using the same url">
<meta property="og:image" content="https://www.shreyasgaonkar.com/favicon/favicon-32x32.png">
<meta property="og:description" content="trim.live provides free and fast url shortning and will work forever. We don't clear the results and you can keep using the same url">
<meta name="author" content="Shreyas Gaonkar">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- Favicon -->
<link rel="icon" type="image/png" href="https://www.shreyasgaonkar.com/favicon/favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="https://www.shreyasgaonkar.com/favicon/android-chrome-192x192.png" sizes="192x192"/>
<link rel="icon" type="image/png" href="https://www.shreyasgaonkar.com/favicon/favicon-96x96.png" sizes="96x96"/>
<link rel="icon" type="image/png" href="https://www.shreyasgaonkar.com/favicon/favicon-16x16.png" sizes="16x16"/>
<link rel="shortcut icon" href="https://www.shreyasgaonkar.com/favicon/favicon.ico"/>
<meta name="theme-color" content="#ffffff"/>
<style>
html {
border: 0;
margin: 0;
padding: 20px;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
body {
height: fit-content;
background-color: #3a1e5c;
}
#link,
a,
h1,
h2 {
color: #c2dea0 !important;
}
#urltext {
max-width: 250px;
border: 0;
height: 44px;
}
#submit {
background-color: #c2dea0;
color: #3a1e5c;
border-color: transparent;
}
.btn-outline-secondary.focus,
.btn-outline-secondary:focus,
.form-control:focus {
box-shadow: none !important;
}
.hidden {
display: none;
}
.alert-link {
color: #491217 !important;
}
.container,
.fade {
display: block;
visibility: visible;
opacity: 1;
animation: fade 1s ease-in-out;
}
.credits {
font-size: 0.65rem;
opacity: 0.5;
color: #c2dea0 !important;
text-align: center;
bottom: 0;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
text-decoration: underline;
animation: fade 1s ease-in-out;
}
@media (max-width: 780px) {
html {
padding: 0 !important;
}
/* Hide HTTP/HTTPS sidebar on mobile*/
#basic-addon1 {
display: none;
}
#urltext {
border-radius: 0.25rem 0 0 0.25rem;
}
}
@keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.spinner-border').hide();
$('#urltext').focus();
$.ajax({
url: window.location.href + 'lambda',
success: console.log("Container warm now")
});
$('#urltext').css({"height": $('.input-group-append').css("height")});
var urlData = $('#urltext').val();
$('#urltext').keypress(function (e) {
if (e.which == 13) {
$('#submit').click();
}
})
$('#submit').click(function (e) {
e.preventDefault();
$('.spinner-border').show();
var urlData = $('#urltext').val();
var headersData = {
'url': urlData
};
if (urlData.length > 1) {
$.ajax({
type: "POST",
url: window.location.pathname,
headers: headersData,
contentType: "application/json",
dataType: 'json',
success: function (response) {
var hlink = '<a href="' + response + '" target="_blank">' + response + '</a>';
$('#link').html(hlink);
$('.alert-danger').css("display", "none");
$('.alert-success').css("display", "block");
copyToClipboard();
},
error: function (xhr, ajaxOptions, thrownError) {
$('.alert-success').css("display", "none");
$('.alert-danger').css("display", "block");
var rbody = xhr.responseJSON;
console.log("thrown error is " + thrownError);
if (xhr.status == 403) {
$('.alert-danger').html(
'<strong>Error: </strong> ' + rbody + '.<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'
)
} else if (xhr.status == 400) {
alert('Something\'s amiss... Try again.');
} else if (xhr.status == 429 && rbody.message == "Limit Exceeded") {
alert('You have exceeded the number of requests today. Try again tomorrow.')
} else if (xhr.status == 429) {
alert('You need to slow down.')
}
} //end error
}); // end textLength end ajax
} else {
alert("Enter URL!");
}
function copyToClipboard() {
var copyText = $('#link > a').text();
var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = copyText;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
console.log("Copied the text to the clipboard: " + copyText);
}
$('.spinner-border').hide();
}); //end click submit
}); //end doc ready
</script>
<div class="container">
<div class="alert alert-success alert-dismissible fade show" role="alert" style="display: none;">
<strong>Sweet!</strong>
See the shortned url below.
<br/>
URL copied to clipboard.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="alert alert-danger alert-dismissible fade show" role="alert" style="display: none;">
<strong>Umm..?!</strong>
Something went wrong.
<a href="." class="alert-link">Refresh?</a>.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<h1>trim.live</h1>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">http(s)://</span>
</div>
<input id="urltext" type="text" class="form-control" placeholder="Enter your URL" aria-label="Username" aria-describedby="basic-addon1">
<div class="input-group-append">
<button id="submit" class="btn btn-outline-secondary" type="button">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Shrink It!
</button>
</div>
</div>
<div id="link">
Your tiny URL will appear here after you Shrink It!</div>
<section class="credits">Created by
<a href="https://www.shreyasgaonkar.com/">Shreyas</a>
</section>
</div>
<!-- end container -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>