Skip to content

Commit b44a2f0

Browse files
authored
Add files via upload
1 parent 04ee3ea commit b44a2f0

File tree

3 files changed

+160
-0
lines changed

3 files changed

+160
-0
lines changed

Diff for: terminal protfolio/css/style.css

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
body {
2+
background-color: #181a1b;
3+
font-family: "Ubuntu Mono", courier, monospace;
4+
font-size: 1em;
5+
color: white;
6+
overflow-x: hidden;
7+
overflow-y: scroll;
8+
word-break: break-all;
9+
10+
}
11+
12+
input {
13+
color: white;
14+
font-family: 'Ubuntu Mono';
15+
font-size: 16px;
16+
border: none;
17+
outline: none;
18+
background: none;
19+
width: 70%;
20+
}
21+
22+
p {
23+
height: 1em;
24+
display: table-row;
25+
}
26+
27+
.lsDisplay {
28+
color: #3391ff;
29+
margin: 0px 25px 0 25px;
30+
}
31+
32+
.lsDisplay:first-of-type {
33+
margin-left: 0px;
34+
}

Diff for: terminal protfolio/index.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<title>Travis Pooley - Portfolio</title>
6+
7+
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Mono&display=swap" rel="stylesheet">
8+
<link href="css/style.css" rel="stylesheet" />
9+
<!-- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> -->
10+
<script src="js/script.js" defer></script>
11+
12+
</head>
13+
<body>
14+
<noscript>Your browser does not support JavaScript!</noscript>
15+
<div id="terminal">
16+
<div id="history"></div>
17+
<span style="color: #7fff7f;">[email protected]</span>:<span style="color: #3391ff;">~</span>$<input id="input" autofocus autocomplete="off" spellcheck="false" onfocusout="focus()">
18+
</div>
19+
20+
</body>
21+
</html>

Diff for: terminal protfolio/js/script.js

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
const input = document.getElementById('input');
2+
const history = document.getElementById('history');
3+
const files = {"readme.txt":"test readme file...", "about.txt":"My name is Travis Pooley, I'm a software engineer from Adelaide, Australia."};
4+
5+
// add codepen
6+
const directories = {"FlindersFinder":"https://travispooley.com/VEED2201/", "LinkedIn":"https://www.linkedin.com/in/travispooley/", "Twitter":"https://twitter.com/TravisPooley"};
7+
8+
let commandHistory = [];
9+
let historyNumber = -1;
10+
11+
// auto focus on input
12+
function focus() {
13+
document.getElementById("input").focus()
14+
}
15+
16+
function handleCommand(command) {
17+
const line = document.createElement('p');
18+
console.log(command)
19+
// sanitise input
20+
const commandText = document.createElement('span');
21+
commandText.innerText = command;
22+
line.innerHTML = '<span style="color: #7fff7f;">[email protected]</span>:<span style="color: #3391ff;">~</span>$';
23+
line.appendChild(commandText);
24+
history.appendChild(line);
25+
26+
// if command is not blank add to the history of commands
27+
if (command != "") {
28+
commandHistory.push(command);
29+
}
30+
31+
if (command == "clear") {
32+
history.innerHTML = "";
33+
}
34+
else if (command == "ls") {
35+
let ls = document.createElement('p');
36+
for (directory in directories) {
37+
let directoryName = document.createElement('span');
38+
directoryName.setAttribute('class', "lsDisplay")
39+
directoryName.innerText = directory;
40+
ls.appendChild(directoryName);
41+
}
42+
for (file in files) {
43+
let fileName = document.createElement('span');
44+
fileName.setAttribute('class', "lsDisplay")
45+
fileName.style.color = "white";
46+
fileName.innerText = file;
47+
ls.appendChild(fileName);
48+
}
49+
history.appendChild(ls);
50+
}
51+
// man command
52+
53+
else if (command == "reboot") {
54+
location.reload();
55+
}
56+
// reboot
57+
else if (command.split(" ")[0] == "cd") {
58+
if (Object.keys(directories).includes(command.split(" ")[1])) {
59+
window.open(directories[command.split(" ")[1]], '_blank').focus();
60+
let redirect = document.createElement('p');
61+
redirect.innerHTML = "attempting to open: <a href='"+(directories[command.split(" ")[1]])+"'>"+(directories[command.split(" ")[1]])+"<a>";
62+
history.appendChild(redirect);
63+
}
64+
}
65+
else if (command.split(" ")[0] == "cat") {
66+
if (Object.keys(files).includes(command.split(" ")[1])) {
67+
let cat = document.createElement('p');
68+
cat.innerHTML = files[command.split(" ")[1]];
69+
history.appendChild(cat);
70+
}
71+
else {
72+
let unknownFile = document.createElement('p');
73+
unknownFile.innerText = command.split(" ")[0]+": "+command.split(" ")[1]+": No such file or directory";
74+
history.appendChild(unknownFile);
75+
}
76+
}
77+
else if (command != "") {
78+
const unknownCommand = document.createElement('p');
79+
unknownCommand.innerText = command+": command not found";
80+
history.appendChild(unknownCommand);
81+
}
82+
console.log(command.split(" ")[0])
83+
}
84+
85+
86+
input.addEventListener("keyup", function(event) {
87+
if (event.key === "Enter") {
88+
handleCommand(input.value);
89+
input.value = '';
90+
historyNumber = -1;
91+
}
92+
else if (event.key === "ArrowUp") {
93+
// console.log(event.key)
94+
if (historyNumber < commandHistory.length) historyNumber++;
95+
input.value = commandHistory[(commandHistory.length-1) - historyNumber] !== undefined ? commandHistory[(commandHistory.length-1) - historyNumber] : "";
96+
}
97+
else if (event.key === "ArrowDown") {
98+
// console.log(event.key)
99+
if (historyNumber > -1) historyNumber--;
100+
input.value = commandHistory[(commandHistory.length-1) - historyNumber] !== undefined ? commandHistory[(commandHistory.length-1) - historyNumber] : "";
101+
}
102+
else if (event.key) {
103+
// console.log(event.key)
104+
}
105+
});

0 commit comments

Comments
 (0)