Skip to content

Commit ad78104

Browse files
authored
Add files via upload
1 parent f72956e commit ad78104

File tree

3 files changed

+381
-0
lines changed

3 files changed

+381
-0
lines changed

css/style.css

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
a:visited {
23+
color: white;
24+
}
25+
26+
a {
27+
color: white;
28+
}
29+
30+
p {
31+
height: 1em;
32+
display: table-row;
33+
white-space: break-spaces;
34+
}
35+
36+
.special {
37+
color: #c67243;
38+
}
39+
40+
.lsDisplay {
41+
color: #3391ff;
42+
margin: 0px 25px 0 25px;
43+
}
44+
45+
.lsDisplay:first-of-type {
46+
margin-left: 0px;
47+
}
48+
49+
.blinkyBoi {
50+
position: absolute;
51+
width: 8px;
52+
height: 1em;
53+
background-color: white;
54+
left: 1px;
55+
opacity: 1;
56+
/* top: 50%; */
57+
/* transform: translateY(-50%); */
58+
59+
60+
animation-name: blink;
61+
animation-duration: 1000ms;
62+
animation-iteration-count: infinite;
63+
}

index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="js/script.js" defer></script>
10+
<meta charset="UTF-8">
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" disabled onfocusout="focus()">
18+
<!-- style="left: 8px;" -->
19+
<!-- <i id="blinky" class="blinkyBoi" style="left: 10px;"></i> -->
20+
</div>
21+
22+
</body>
23+
</html>

js/script.js

+295
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
// nothing to see here :))
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
// type based on url param
34+
35+
// lower case for cd
36+
37+
// make help command
38+
// sudo rm -rf /
39+
40+
41+
// echo
42+
43+
// sumfetch is a summary
44+
// add email
45+
46+
47+
// make function for each command so that it can be done with a switch
48+
49+
// make aliases work
50+
// repo -> cd github
51+
// help -> cat help.txt
52+
53+
54+
// add some form of privilage escalation
55+
56+
57+
// make proper directory system
58+
59+
// projects directory
60+
61+
62+
// about banner cd date donate echo emacs
63+
// email github gui help linkedin ls nvim
64+
// projects quote readme resume sudo sumfetch theme
65+
// vi vim whoami
66+
67+
// [tab]: trigger completion.
68+
// [ctrl+l]/clear: clear terminal.
69+
70+
// Type 'sumfetch' to display summary.
71+
72+
73+
74+
// finish tab to autocomplete
75+
76+
77+
const input = document.getElementById('input');
78+
const history = document.getElementById('history');
79+
// const blinky = document.getElementById("blinky")
80+
const socials = {
81+
"LinkedIn": "https://www.linkedin.com/in/travispooley/",
82+
"Twitter": "https://twitter.com/TravisPooley",
83+
"GitHub": "https://github.com/TravisPooley/",
84+
"CodePen": "https://codepen.io/TravisPooley/",
85+
"StackOverflow": "https://stackoverflow.com/users/9627710/travispooley",
86+
}
87+
const files = {"readme.txt":`
88+
89+
90+
__________ ___ _ ___________ ____ ____ ____ __ ________ __
91+
/_ __/ __ \\/ | | / / _/ ___// __ \\/ __ \\/ __ \\/ / / ____/\\ \\/ /
92+
/ / / /_/ / /| | | / // / \\__ \\/ /_/ / / / / / / / / / __/ \\ /
93+
/ / / _, _/ ___ | |/ // / ___/ / ____/ /_/ / /_/ / /___/ /___ / /
94+
/_/ /_/ |_/_/ |_|___/___//____/_/ \\____/\\____/_____/_____/ /_/
95+
96+
97+
98+
Travis Pooley portfolio v2.0.0 🚧 Work In Progress 🚧
99+
100+
Type '<a href='javascript:;' onclick='handleCommand("cat help.txt")'>cat help</a>' for a list of commands.
101+
102+
--
103+
104+
This website is open-source, type '<a href='javascript:;' onclick='handleCommand("cd repo")'>cd repo</a>' to checkout the repository.
105+
106+
--
107+
108+
`,
109+
110+
"travispooley.txt": `Here is some social links:`+Object.keys(socials).map((social) => {
111+
return `<p><span class="special">${social}</span>: <a href="${socials[social]}">${socials[social]}</a></p>`
112+
}).join(""),
113+
"about.txt":"My name is Travis Pooley, I'm a software engineer from Adelaide, Australia.",
114+
"help.txt":`
115+
Welcome! Here are all the available commands:
116+
117+
I'm still working on that
118+
`
119+
};
120+
121+
let commandHistory = [];
122+
let historyNumber = -1;
123+
124+
const COMMANDS = {
125+
"help": "",
126+
"clear": "",
127+
"ls": "",
128+
"cd": "",
129+
"reboot": "",
130+
"repo": "",
131+
"email": "",
132+
"sumfetch": "",
133+
"echo": "",
134+
"cat": "",
135+
}
136+
137+
// add codepen
138+
const DIRECTORIES = {"repo": "https://github.com/TravisPooley/TravisPooley.github.io", "FlindersFinder":"https://travispooley.com/VEED2201/", "LinkedIn":"https://www.linkedin.com/in/travispooley/", "Twitter":"https://twitter.com/TravisPooley", "GitHub":"https://github.com/TravisPooley/"};
139+
140+
141+
const ALIASES = {"repo:":"cd repo", "help":"cat help.txt", }
142+
143+
144+
145+
const STARTUP_COMMANDS = ["cat readme.txt", "cat travispooley.txt", "ls", ""];
146+
const STARTUP_INPUT = STARTUP_COMMANDS.join(String.fromCharCode(13))
147+
148+
type(STARTUP_INPUT, 100);
149+
150+
function type(text, speed) {
151+
152+
let currentChar = 0;
153+
const interval = setInterval(function() {
154+
if (text[currentChar] == "\r") Enter();
155+
else input.value = input.value + text[currentChar];
156+
currentChar++;
157+
if (currentChar == text.length) {
158+
input.disabled = false;
159+
focus();
160+
clearInterval(interval);
161+
}
162+
}, speed);
163+
}
164+
165+
// auto focus on input
166+
function focus() {
167+
document.getElementById("input").focus()
168+
}
169+
170+
function handleCommand(command) {
171+
const line = document.createElement('p');
172+
console.log(command)
173+
// sanitise input
174+
const commandText = document.createElement('span');
175+
commandText.innerText = command;
176+
line.innerHTML = '<span style="color: #7fff7f;">[email protected]</span>:<span style="color: #3391ff;">~</span>$';
177+
line.appendChild(commandText);
178+
history.appendChild(line);
179+
180+
// if command is not blank add to the history of commands
181+
if (command != "") {
182+
commandHistory.push(command);
183+
}
184+
185+
if (command == "clear") {
186+
history.innerHTML = "";
187+
}
188+
else if (command == "ls") {
189+
let ls = document.createElement('p');
190+
for (directory in DIRECTORIES) {
191+
let directoryName = document.createElement('span');
192+
directoryName.setAttribute('class', "lsDisplay")
193+
directoryName.innerText = directory;
194+
ls.appendChild(directoryName);
195+
}
196+
for (file in files) {
197+
let fileName = document.createElement('span');
198+
fileName.setAttribute('class', "lsDisplay")
199+
fileName.style.color = "white";
200+
fileName.innerText = file;
201+
ls.appendChild(fileName);
202+
}
203+
history.appendChild(ls);
204+
}
205+
// man command
206+
207+
// reboot
208+
else if (command == "reboot") {
209+
location.reload();
210+
}
211+
else if (command.split(" ")[0] == "cd") {
212+
if (Object.keys(DIRECTORIES).includes(command.split(" ")[1])) {
213+
window.open(DIRECTORIES[command.split(" ")[1]], '_blank').focus();
214+
let redirect = document.createElement('p');
215+
redirect.innerHTML = "attempting to open: <a href='"+(DIRECTORIES[command.split(" ")[1]])+"'>"+(DIRECTORIES[command.split(" ")[1]])+"<a>";
216+
history.appendChild(redirect);
217+
}
218+
}
219+
else if (command.split(" ")[0] == "echo") {
220+
let echo = document.createElement('p');
221+
echo.innerText = command.split(" ").slice(1).join(" ");
222+
history.appendChild(echo);
223+
}
224+
else if (command.split(" ")[0] == "cat") {
225+
if (Object.keys(files).includes(command.split(" ")[1])) {
226+
let cat = document.createElement('p');
227+
cat.innerHTML = files[command.split(" ")[1]];
228+
history.appendChild(cat);
229+
}
230+
else {
231+
let unknownFile = document.createElement('p');
232+
unknownFile.innerText = command.split(" ")[0]+": "+command.split(" ")[1]+": No such file or directory";
233+
history.appendChild(unknownFile);
234+
}
235+
}
236+
// else if (command == "sumfetch") {
237+
// }
238+
// else if (command == "email") {
239+
// }
240+
else if (command == "sudo rm -rf /") {
241+
let sudo = document.createElement('p');
242+
sudo.innerHTML = "Sorry, I can't let you do that.";
243+
history.appendChild(sudo);
244+
}
245+
else if (Object.keys(ALIASES).includes(command)) {
246+
handleCommand(ALIASES[command]);
247+
console.log(ALIASES[command])
248+
}
249+
else if (command != "") {
250+
const unknownCommand = document.createElement('p');
251+
unknownCommand.innerText = command+": command not found";
252+
history.appendChild(unknownCommand);
253+
}
254+
console.log(command.split(" ")[0])
255+
}
256+
257+
function Enter() {
258+
handleCommand(input.value);
259+
input.value = '';
260+
historyNumber = -1;
261+
}
262+
input.addEventListener("keyup", function(event) {
263+
console.log(event.target.selectionStart)
264+
// blinky.style.left = event.target.selectionStart;
265+
266+
if (event.key === "Enter") {
267+
Enter();
268+
}
269+
else if (event.key === "ArrowUp") {
270+
// console.log(event.key)
271+
if (historyNumber < commandHistory.length) historyNumber++;
272+
input.value = commandHistory[(commandHistory.length-1) - historyNumber] !== undefined ? commandHistory[(commandHistory.length-1) - historyNumber] : "";
273+
}
274+
else if (event.key === "ArrowDown") {
275+
// console.log(event.key)
276+
if (historyNumber > -1) historyNumber--;
277+
input.value = commandHistory[(commandHistory.length-1) - historyNumber] !== undefined ? commandHistory[(commandHistory.length-1) - historyNumber] : "";
278+
}
279+
});
280+
281+
input.addEventListener("keydown", function(event) {
282+
if (event.key === "Tab") {
283+
event.preventDefault();
284+
// attempt to autocomplete compare current input against COMMANDS
285+
let currentInput = input.value;
286+
let possibleCommands = [];
287+
for (command in COMMANDS) {
288+
if (command.startsWith(currentInput)) possibleCommands.push(command);
289+
}
290+
if (possibleCommands.length == 1) {
291+
input.value = possibleCommands[0];
292+
}
293+
294+
}
295+
});

0 commit comments

Comments
 (0)