Skip to content

Commit

Permalink
Create code.html (#13)
Browse files Browse the repository at this point in the history
* Create code.html

Example for: #12

* add indent on tab

* improve more

* Make sure to load js at the right place

* styling

* correct spaces

* update
  • Loading branch information
LukyVj authored Oct 27, 2020
1 parent b327cfc commit 578054f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Awfice is a collection of tiny office suite apps:
* this project is only a half-joke, I actually use a few Awfice apps as quick scratchpads.
* the only way to save your job is to save a HTML or send it to the printer/print to PDF.

## Text editor - 59 bytes!
## Text editor - 59 bytes!

A simple rich text editor. Type whatever you want, it won't be saved anywhere, but it might be convenient for quick throwaway notes. You should be able to use Ctrl+B and Ctrl+I to mark text selection as bold or italic. Undo/redo should work as well. You can also copy/paste text and images from other sources.

Expand Down Expand Up @@ -69,8 +69,20 @@ data:text/html,<body><script>d=document;for(i=0;i<50;i++)d.body.innerHTML+='<div
[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/beam.html)
## Code editor - 686 bytes!
A simple code editor. You can type in HTML, CSS & Javascript.
Copy and add to bookmarks or open in the URL bar:
```html
data:text/html,<body oninput="i.srcdoc=h.value+'<style>'+c.value+'</style><script>'+j.value+'</script>'"><style>textarea,iframe{width:100%;height:50%;}body{margin:0;}textarea{width: 33.33%;font-size:18px;padding:0.5em}</style><textarea placeholder="HTML" id="h"></textarea><textarea placeholder="CSS" id="c"></textarea><textarea placeholder="JS" id="j"></textarea><iframe id="i"></iframe><script>document.querySelectorAll("textarea").forEach((t)=>t.addEventListener("keydown",function(t){var e,s;"Tab"==t.key&&(t.preventDefault(),e=this.selectionStart,s=this.selectionEnd,this.value=this.value.substring(0,e)+" "+this.value.substring(s),this.selectionStart=this.selectionEnd=e+1)}))</script></body>
```

[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/code.html)

## Contributions

The code is distributed under MIT license. PRs are always welcome, especially if they fix something or make the code smaller, or add features that are valuable, but do not require a lot of code.

To modify something - edit HTML files directly. There is README.sh script that re-generates the README and embeds apps code into it.
To modify something - edit HTML files directly. There is README.sh script that re-generates the README and embeds apps code into it.
12 changes: 12 additions & 0 deletions README.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ data:text/html,$(cat beam.html)
[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/beam.html)
## Code editor - $(wc -c < code.html) bytes!
A simple code editor. You can type in HTML, CSS & Javascript.
Copy and add to bookmarks or open in the URL bar:
\`\`\`html
data:text/html,$(cat code.html)
\`\`\`
[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/code.html)
## Contributions
The code is distributed under MIT license. PRs are always welcome, especially if they fix something or make the code smaller, or add features that are valuable, but do not require a lot of code.
Expand Down
1 change: 1 addition & 0 deletions code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<body oninput="i.srcdoc=h.value+'<style>'+c.value+'</style><script>'+j.value+'</script>'"><style>textarea,iframe{width:100%;height:50%;}body{margin:0;}textarea{width: 33.33%;font-size:18px;padding:0.5em}</style><textarea placeholder="HTML" id="h"></textarea><textarea placeholder="CSS" id="c"></textarea><textarea placeholder="JS" id="j"></textarea><iframe id="i"></iframe><script>document.querySelectorAll("textarea").forEach((t)=>t.addEventListener("keydown",function(t){var e,s;"Tab"==t.key&&(t.preventDefault(),e=this.selectionStart,s=this.selectionEnd,this.value=this.value.substring(0,e)+"  "+this.value.substring(s),this.selectionStart=this.selectionEnd=e+1)}))</script></body>

0 comments on commit 578054f

Please sign in to comment.