Skip to content

Instantly share code, notes, and snippets.

@edfuh
Created October 5, 2011 00:37
Show Gist options
  • Select an option

  • Save edfuh/1263289 to your computer and use it in GitHub Desktop.

Select an option

Save edfuh/1263289 to your computer and use it in GitHub Desktop.
portable text editor, copy and paste into address bar
data:text/html,<textarea contenteditable spellcheck=false ></textarea><button>Save</button><style>body{margin:0; padding:0;}textarea{background%3A%23666%3Bcolor%3A%230F0%3Bheight:100%;width:100%;line-height:1.3;font-size:14px;letter-spacing:1px;padding:10px;}button{position:absolute;color:black;right:20px;top:20px;border:1px solid grey;font-size:14px;padding:6px 14px;border-radius:8px;background%3A%239ECFF5%3B}</style><script>p = document.body.firstChild;p.focus();var val,tabs = 2,spaces = (function (s, t){while (--t) s += s;return s}(' ', tabs));p.onkeydown = function (e) {val = this.value;sstart = this.selectionStart;s = val.substr(0, sstart);n = val.substr(sstart);if (e.which === 9) {this.value = s + spaces + n;this.selectionStart = this.selectionEnd = sstart + tabs;return false;}};document.querySelector('button').onclick = function () {window.location = 'data:application/json,' + val;}</script>
data:text/html,
<textarea contenteditable spellcheck=false ></textarea>
<button>Save</button>
<style>
body{margin:0;}
textarea{
background%3A%23666%3B
color%3A%230F0%3B
height:100%;
width:100%;
line-height:1.3;
font-size:14px;
letter-spacing:1px;
padding:10px;
}
button{
position:absolute;
color:black;
right:20px;
top:20px;
border:1px solid grey;
font-size:14px;
padding:6px 14px;
border-radius:8px;
background%3A%239ECFF5%3B
}
</style>
<script>
p = document.body.firstChild;
p.focus();
var val,
tabs = 2,
spaces = (function (s, t){
while (--t) s += s;
return s
}(' ', tabs));
p.onkeydown = function (e) {
val = this.value;
sstart = this.selectionStart;
s = val.substr(0, sstart);
n = val.substr(sstart);
if (e.which === 9) {
this.value = s + spaces + n;
this.selectionStart = this.selectionEnd = sstart + tabs;
return false;
}
};
document.querySelector('button').onclick = function () {
window.location = 'data:application/json;' + val;
}
</script>
@edfuh
Copy link
Copy Markdown
Author

edfuh commented Oct 5, 2011

tested in FF7 only.
ugly DHTML FTL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment