first commit

This commit is contained in:
Able 2021-12-28 03:35:10 -06:00
commit 904c704d3a
3 changed files with 109 additions and 0 deletions

19
base.css Normal file
View file

@ -0,0 +1,19 @@
body {
background:black;
color: white;
}
line {
margin: 0;
overflow-x: hidden;
}
.bottomBar{
width: 99%;
position: absolute;
bottom: 0;
}

22
editor.html Normal file
View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="base.css">
<script src="main.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div id="textArea">
</div>
<div class="bottomBar">
<hr>
<p id="count">0</p>
</div>
</body>
</html>

68
main.js Normal file
View file

@ -0,0 +1,68 @@
document.addEventListener('DOMContentLoaded', function (event) {
const log = document.getElementById('textArea');
let lineNum = 1;
let columnCount = 0;
updateCount();
const newLine = document.createElement("Line");
newLine.setAttribute("id", "line" + lineNum);
log.appendChild(newLine);
document.addEventListener('keydown', keyPress);
function keyPress(event) {
if (event.key == "Enter") {
const lineBreak = document.createElement("br");
log.appendChild(lineBreak);
lineNum = lineNum + 1;
columnCount = 0;
const newLine = document.createElement("Line");
newLine.setAttribute("id", "line" + lineNum);
log.appendChild(newLine);
} else if (event.key == "Shift") {
} else if (event.key == "Control") {
} else if (event.key == "Backspace") {
const line = document.getElementById("line" + lineNum);
if (line.textContent.length > 0) {
line.textContent = line.textContent.slice(0, -1);
columnCount = columnCount - 1;
} else if (lineNum > 1) {
columnCount = 0;
line.remove();
lineNum = lineNum - 1;
log.lastElementChild.remove();
}
} else {
const line = document.getElementById("line" + lineNum);
line.textContent = line.textContent + event.key;
// log.appendChild(text);
columnCount = columnCount + 1;
}
updateCount();
}
function updateCount() {
const lineCount = document.getElementById("count");
lineCount.textContent = "Line Count: " + lineNum + " | Column Count: " + columnCount;
}
})