forked from mathiasbynens/mothereff.in
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Quoted-Printable
encoder/decoder
- Loading branch information
1 parent
107c976
commit f93b9fe
Showing
8 changed files
with
375 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# [`Quoted-Printable` encoder/decoder](http://mothereff.in/quoted-printable) | ||
|
||
This tool can be used to encode/decode any text using the `Quoted-Printable` content transfer encoding. It uses [_quoted-printable_](http://mths.be/quoted-printable) under the hood. | ||
|
||
Made by [Mathias Bynens](http://mathiasbynens.be/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
html, textarea { | ||
font: .8em/1.6 sans-serif; | ||
} | ||
|
||
body { | ||
max-width: 40em; | ||
padding: 0 1em; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
font-size: 1.3em; | ||
margin: 0 0 .5em; | ||
padding-top: 1em; | ||
} | ||
|
||
h2 { | ||
font-size: 1em; | ||
} | ||
|
||
a { | ||
color: #333; | ||
text-decoration: none; | ||
border-bottom: 1px solid #aaa; | ||
padding: .1em .2em; | ||
} | ||
|
||
a:hover, a:focus { | ||
color: #fff; | ||
border-color: #036; | ||
background: #36c; | ||
} | ||
|
||
textarea { | ||
font-family: Monaco, Consolas, monospace; | ||
} | ||
|
||
#footer { | ||
margin-top: 2em; | ||
text-align: center; | ||
} | ||
|
||
textarea { | ||
border: 3px double green; | ||
background: #90ee90; | ||
width: 100%; | ||
-moz-box-sizing: border-box; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
display: block; | ||
margin: 1em 0 .5em; | ||
padding: .7em; | ||
resize: vertical; | ||
min-height: 9.5em; | ||
} | ||
|
||
code { | ||
font-family: Monaco, Consolas, monospace; | ||
font-size: .9em; | ||
white-space: pre; | ||
white-space: pre-wrap; | ||
word-wrap: break-word; | ||
} | ||
|
||
.invalid, :invalid { | ||
border-color: red; | ||
background: #ffb6c1; | ||
} | ||
|
||
@media (min-width: 42em) { | ||
|
||
html { | ||
font-size: 1.2em; | ||
background: #c4c4c4; | ||
height: 100%; | ||
} | ||
|
||
body { | ||
margin: 0 auto; | ||
padding: 0 2em; | ||
min-height: 100%; | ||
background: #fff; | ||
border: solid #aaa; | ||
border-width: 0 1px; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
(function(window, document) { | ||
|
||
var textareas = document.getElementsByTagName('textarea'); | ||
var decoded = textareas[0]; | ||
var encoded = textareas[1]; | ||
var permalink = document.getElementById('permalink'); | ||
// http://mathiasbynens.be/notes/localstorage-pattern | ||
var storage = (function() { | ||
var uid = new Date; | ||
var storage; | ||
var result; | ||
try { | ||
(storage = window.localStorage).setItem(uid, uid); | ||
result = storage.getItem(uid) == uid; | ||
storage.removeItem(uid); | ||
return result && storage; | ||
} catch (exception) {} | ||
}()); | ||
|
||
function encode(string) { | ||
// URL-encode some more characters to avoid issues when using permalink URLs in Markdown | ||
return encodeURIComponent(string).replace(/['()_*]/g, function(character) { | ||
return '%' + character.charCodeAt().toString(16); | ||
}); | ||
} | ||
|
||
function update() { | ||
var shouldDecode = this == encoded; | ||
var value; | ||
if (shouldDecode) { | ||
value = quotedPrintable.decode(encoded.value); | ||
decoded.value = value; | ||
} else { | ||
value = quotedPrintable.encode(decoded.value); | ||
encoded.value = value; | ||
} | ||
value = decoded.value; | ||
permalink.hash = encode(value); | ||
storage && (storage.quotedPrintable = value); | ||
}; | ||
|
||
// http://mathiasbynens.be/notes/oninput | ||
decoded.onkeyup = encoded.onkeyup = update; | ||
decoded.oninput = encoded.oninput = function() { | ||
decoded.onkeyup = encoded.onkeyup = null; | ||
update.call(this); | ||
}; | ||
|
||
if (storage) { | ||
storage.quotedPrintable && (decoded.value = storage.quotedPrintable); | ||
update(); | ||
} | ||
|
||
window.onhashchange = function() { | ||
decoded.value = decodeURIComponent(location.hash.slice(1)); | ||
update(); | ||
}; | ||
|
||
if (location.hash) { | ||
window.onhashchange(); | ||
} | ||
|
||
}(this, document)); | ||
|
||
// Google Analytics | ||
window._gaq = [['_setAccount', 'UA-6065217-60'], ['_trackPageview']]; | ||
(function(d, t) { | ||
var g = d.createElement(t), | ||
s = d.getElementsByTagName(t)[0]; | ||
g.src = '//www.google-analytics.com/ga.js'; | ||
s.parentNode.insertBefore(g, s); | ||
}(document, 'script')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang=en> | ||
<meta charset=utf-8> | ||
<title>`Quoted-Printable` encoder/decoder</title> | ||
<meta name=viewport content="width=device-width,initial-scale=1"> | ||
<link rel=stylesheet href=eff.css> | ||
<meta name=description content="An online, on-the-fly `Quoted-Printable` encoder/decoder."> | ||
<h1><code>Quoted-Printable</code> encoder/decoder</h1> | ||
<noscript><strong>To use this tool, please <a href=http://enable-javascript.com/>enable JavaScript</a> and reload the page.</strong></noscript> | ||
<h2>Decoded:</h2> | ||
<textarea autofocus>If you believe that truth=beauty, then surely mathematics is the most beautiful branch of philosophy.</textarea> | ||
<h2>Encoded: (<a href=#If%20you%20believe%20that%20truth%3Dbeauty%2C%20then%20surely%20mathematics%20is%20the%20most%20beautiful%20branch%20of%20philosophy. id=permalink>permalink</a>)</h2> | ||
<textarea>If you believe that truth=3Dbeauty, then surely mathematics is the most bea= | ||
utiful branch of philosophy.</textarea> | ||
<h2>About this tool</h2> | ||
<p>This tool uses <a href=http://mths.be/quoted-printable><i>quoted-printable</i></a> to do all the encoding/decoding. | ||
<p id=footer>Made by <a href=http://mathiasbynens.be/>@mathias</a> — <a href=https://github.com/mathiasbynens/mothereff.in/tree/master/quoted-printable>fork this on GitHub!</a></p> | ||
<script src=vendor/quoted-printable.js></script> | ||
<script src=eff.js></script> |
Oops, something went wrong.