Skip to content

Commit

Permalink
Add tab support
Browse files Browse the repository at this point in the history
  • Loading branch information
ohno committed Dec 13, 2023
1 parent 59b3ea5 commit b5ea09c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
2 changes: 2 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ footer {
position: relative;
width: 100%;
}

@media screen and (max-width:840px) {
.textareas {
flex-direction: column;
Expand Down Expand Up @@ -282,6 +283,7 @@ footer {
resize: none;
width: 100%;
word-wrap: break-word;
tab-size: 4;
}

@media screen and (max-width:840px) {
Expand Down
25 changes: 0 additions & 25 deletions assets/js/copy.js

This file was deleted.

17 changes: 17 additions & 0 deletions assets/js/onload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@ Start writing!
`;
}
document.getElementById('output').value = math(document.getElementById('input').value);

// tab support
document.getElementById('input').addEventListener('keydown', function (e) {
var elem, end, start, value;
if (e.keyCode === 9) {
if (e.preventDefault) {
e.preventDefault();
}
elem = e.target;
start = elem.selectionStart;
end = elem.selectionEnd;
value = elem.value;
elem.value = "" + (value.substring(0, start)) + "\t" + (value.substring(end));
elem.selectionStart = elem.selectionEnd = start + 1;
return false;
}
});
}
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<link rel="stylesheet" href="./assets/css/style.css">
<script src="./assets/js/url.js"></script>
<script src="./assets/js/onload.js"></script>
<script src="./assets/js/copy.js"></script>
<script src="./assets/js/math.js"></script>
<!-- https://docs.mathjax.org/en/latest/web/configuration.html?highlight=heading#configuration-using-an-in-line-script -->
<script>
Expand Down

0 comments on commit b5ea09c

Please sign in to comment.