forked from swapagarwal/geeksay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
265 lines (261 loc) · 9.36 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
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<html lang="en">
<head>
<title>geeksay</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="icon" type="image/png" href="logo.png">
<link rel="apple-touch-icon" sizes="128x128" href="logo.png" />
<link href='https://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
<script src="geeksay.js"></script>
</head>
<style>
body {
font-family: 'Helvetica';
font-weight: 300;
background: #fff;
color: #535353;
margin: 0px;
padding: 50px;
overflow: auto;
font-size: 16px;
}
.container {
max-width: 600px;
margin: 0 auto;
overflow: auto;
z-index: 10;
}
@media (max-width: 500px) {
body {
padding: 20px;
}
button {
margin: 20px 0 !important;
}
}
h1 {
font-family: 'Lato', 'Helvetica', Arial, sans-serif;
font-weight: 300;
margin-bottom: 0;
}
textarea {
width: 100%;
font-family: 'Helvetica';
font-weight: 300;
font-size: 16px;
height: 150px;
line-height: 24px;
resize: none;
padding: 15px;
border-radius: 4px;
}
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
display: inline-block;
border: 0;
outline: 0;
background: transparent;
cursor: pointer;
font-size: 16px;
padding: 0 4px;
line-height: 1.5;
background-color: #eee;
border-radius: 3px;
margin: 0 4px 4px 4px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12),
0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
select:focus {
background-color: #7bd6cf;
}
button {
border: none;
outline: none;
cursor: pointer;
text-align: center;
background: #E91E63;
color: white;
font-weight: normal;
transition: all .4s;
height: 30px;
border-radius: 4px;
text-transform: uppercase;
vertical-align: middle;
font-size: 14px;
margin: 20px;
width: 130px;
}
#footer {
margin-top: 100px;
padding-top: 20px;
border-top: 2px solid #E91E63;
text-align: center;
text-transform: uppercase;
}
#footer > p {
text-transform: uppercase;
font-size: 10px;
letter-spacing: .2em;
padding-right: 6px;
}
.note {
margin-top: 0;
margin-bottom: 20px;
font-size: 12px;
}
.red {
color: #E91E63;
}
a:link, a:visited {
color: #E91E63;
text-decoration: none;
}
a:hover {
color: #2196F3;
}
/* Hide this somewhere */
#clipboardContents {
opacity: 0;
position: absolute;
bottom: 0;
left: 0;
z-index: 0;
}
#output {
padding: 15px;
background-color: black;
color: #54FE55;
border-radius: 3px;
font-weight: 500;
font-family: monospace;
}
.twitter-tweet-button {
float: right;
margin: 7px 0 0 0;
}
.random-quote-button {
float: right;
margin: 6px 0 0 0;
}
</style>
<body>
<a href="https://github.com/swapagarwal/geeksay" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<div class="container">
<h1>From layman 👶 <button class="random-quote-button" onclick="randomQuote()" id="randomQuoteButton">Random Quote</button></h1>
<p class="note">(just start typing!)</p>
<textarea id="input" aria-required="true">geeks will save the world!
There's no place like home
sometimes, i just need a break</textarea>
<br><br>
<h1>To geek 🤓 <a href="https://twitter.com/intent/tweet?button_hashtag=geeksay&ref_src=twsrc%5Etfw" class="twitter-hashtag-button" data-size="large" data-text="geeks will ctrl+s the world!
There's no place like 127.0.0.1
sometimes, i just need a <br>
Can you guess the original text?" data-url="http://geeksay.xyz" data-show-count="false">Tweet #geeksay</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></h1>
<br>
<div style="line-height: 24px" id="output"></div>
<div id="footer">
<p>made with <span class="red">❤︎</span> by <a href="https://swapnil.net/" target="_blank">swapnil</a> |
designed by <a href="https://twitter.com/notwaldorf" target="_blank">monica</a></p>
</div>
<br>
<div align="center">
<a id="help" href="https://github.com/swapagarwal/geeksay/issues/6" target="_blank">Need an API?</a>
</div>
<div align="center">
<p style="display:inline-block" id="randomTranslation"></p>
<br>
<button style="margin-top: 0px" onclick="randomTranslation()" id="randomTranslationButton">One more!</button>
</div>
</div>
<!-- Gigantor hack to get the copy-to-clipboard working. I don't think it
works with hidden divs, so uhhhh just hide this one real well -->
<div id="clipboardContents"></div>
<script type="text/javascript">
console.log(geeksay('geeks will save the world'));
document.getElementById("randomTranslation").innerText = getRandomTranslation();
</script>
<script>
updateOutput();
document.getElementById('input').addEventListener('input', function() {
updateOutput();
});
function updateOutput() {
// Rather than calling geekify, we want all the
// possible options.
document.getElementById('output').innerHTML = '';
var inputField = document.getElementById('input');
var text = inputField.value.trim();
if(text.length !== 0) {
var container = document.getElementById('output');
var allLines = text.split('\n');
for (var line = 0; line < allLines.length; line++ ){
if (allLines[line] == '')
continue
var words = allLines[line].split(' ');
// Re-add the translated words.
for (var i = 0; i < words.length; i++ ) {
var node = document.createElement('span');
node.innerText = geeksay(words[i]) + ' ';
if (node)
container.appendChild(node);
}
var newLine = document.createElement('br');
container.appendChild(newLine);
}
return container;
} else {
document.getElementById('output').innerHTML = "Type something in the above area...";
}
}
function copy() {
var value = getActualOutput();
clipboardContents.textContent = value;
// From https://github.com/google/material-design-lite/blob/master/docs/_assets/snippets.js
var snipRange = document.createRange();
snipRange.selectNodeContents(clipboardContents);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(snipRange);
var result = false;
try {
result = document.execCommand('copy');
copyButton.innerHTML = 'Done!';
} catch (err) {
// Copy command is not available
console.error(err);
copyButton.innerHTML = 'Oops, error copying :(';
}
// Return to the copy button after a second.
setTimeout(function() {
copyButton.innerHTML = 'Copy to clipboard';
}.bind(this), 1000);
selection.removeAllRanges();
return result;
}
function getActualOutput() {
var value = '';
var nodes = output.children;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].tagName === 'SELECT') {
// Do this instead of .value because we want to maintain whitespace.
value += nodes[i].options[nodes[i].selectedIndex].textContent;
} else if (nodes[i].tagName === 'BR') {
value += '\n';
} else if (nodes[i].tagName != 'OPTION') {
value += nodes[i].textContent;
}
}
return value;
}
function randomTranslation() {
document.getElementById("randomTranslation").innerText = getRandomTranslation();
}
function randomQuote() {
document.getElementById("input").value = getRandomQuote();
updateOutput();
}
</script>
</body>
</html>