Skip to content

Instantly share code, notes, and snippets.

@ArtBIT
Last active October 31, 2020 16:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtBIT/98c15ec047d30ebd5d2a18c601ca180f to your computer and use it in GitHub Desktop.
Save ArtBIT/98c15ec047d30ebd5d2a18c601ca180f to your computer and use it in GitHub Desktop.
WEB is a minimalistic HTML, CSS, and JavaScript CodePen-like web editor that fits inside a bookmarklet.
data:text/html, <div> <div contenteditable id=html placeholder=html></div> <div contenteditable id=css placeholder=css></div> <div contenteditable id=js placeholder=js></div> <iframe id=code frameborder=0></iframe> <button id=share>Copy Share Link</button> </div> <style> * { box-sizing: border-box; font-family: Consolas,monaco,monospace;} html, body { padding:0; margin:0; } body>div { display:flex; flex-wrap:wrap; height:100vh; width:100vw; } [contenteditable] { border:1px solid gray; width:calc(100vw / 3); height:40vh; } [contenteditable]:empty:before{ content:attr(placeholder); color: gray; display:block; } iframe { width: 100vw; height:60vh; } #share { position: fixed; bottom: 0; right: 0; } </style> <script> var d=document, t=function(el) { return el.textContent.replace(/\u00a0/g, " ")}, stage=code.contentWindow.document, compile=function(e) { stage.open(); stage.writeln(t(html)+"<style>"+t(css)+"</style>"+"<script>"+t(js)+"</s"+"cript>"); stage.close(); }, copy = function(str) { var el = d.createElement('textarea'); el.value = str; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); }; d.body.onload = compile; d.body.onkeyup = compile; share.onclick = function() {copy('data:text/html;base64,'+btoa(d.documentElement.outerHTML))}; </script>
# WEB
WEB is a recursive acronym. WEB stands for WEB Editor Bookmarklet.
WEB is a minimalistic HTML, CSS, and JavaScript CodePen-like web editor that fits inside a bookmarklet.
# Usage
Every time you edit the HTML, CSS, and JavaScript in the top three boxes, the result gets evaluated.
# Sharing
Click the share button in the bottom right to copy the contents of your WEB onto the clipboard for sharing.
<div>
<div contenteditable id=html placeholder=html></div>
<div contenteditable id=css placeholder=css></div>
<div contenteditable id=js placeholder=js></div>
<iframe id=code frameborder=0></iframe>
<button id=share>Copy Share Link</button>
</div>
<style>
* {
box-sizing: border-box;
font-family: Consolas,monaco,monospace
}
html, body {
padding:0;
margin:0;
}
body>div {
display:flex;
flex-wrap:wrap;
height:100vh;
width:100vw;
}
[contenteditable] {
border:1px solid gray;
width:calc(100vw / 3);
height:40vh;
}
[contenteditable]:empty:before{
content:attr(placeholder);
color: gray;
display:block;
}
iframe {
width: 100vw;
height:60vh;
}
#share {
position: fixed;
bottom: 0;
right: 0;
}
</style>
<script>
var d=document,
t=function(el) { return el.textContent.replace(/\u00a0/g, " ")},
stage=code.contentWindow.document,
compile=function(e) {
stage.open();
stage.writeln(t(html)+"<style>"+t(css)+"</style>"+"<script>"+t(js)+"</s"+"cript>");
stage.close();
},
copy = function(str) {
var el = d.createElement('textarea');
el.value = str;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
};
d.body.onload = compile;
d.body.onkeyup = compile;
share.onclick = function() {copy('data:text/html;base64,'+btoa(d.documentElement.outerHTML))};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment