Skip to content

Commit

Permalink
✨ Minor Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zingzy committed Jan 20, 2024
1 parent 585143e commit e69f3e7
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
</head>
<body>
<div class="terminal">
<span class="input-prefix inital-command" style="padding-top: 10px;"><span class="dark-green">user</span>@<span class="yellow">{{ base_url }}</span>:~$ about</span>
<span class="input-prefix inital-command" style="padding-top: 10px;"><span class="dark-green">user</span>@<span class="yellow">{{ base_url }}</span>:~$ </span>
<div class="output">
<div id="welcome-message">
<div class="intro">
Expand Down Expand Up @@ -206,7 +206,7 @@

<div class="input-container">
<span class="input-prefix"><span class="dark-green">user</span>@<span class="yellow">{{ base_url_no_http }}</span>:~$</span>
<input type="text" class="command-input" id="commandInput" title="Command Input">
<input type="text" class="command-input" id="commandInput" title="Command Input" autocomplete="off" spellcheck="false">
</div>
</div>

Expand Down Expand Up @@ -267,14 +267,22 @@
displayHelp();
break;
case 'fact':
case 'all':
case 'health':
case 'stats':
fetch(`{{ base_url }}${command}`)
.then(response => response.json())
.then(data => appendOutput(JSON.stringify(data, null, 4)))
.catch(error => appendOutput(`Error: ${error.message}`));
break;
case 'all':
fetch(`{{ base_url }}${command}`)
.then(response => response.json())
.then(data => {
data.pic = `<a href='${data.pic}' target='_blank' class='url'>${data.pic}</a>`;
data.gif = `<a href='${data.gif}' target='_blank' class='url'>${data.gif}</a>`;
appendOutput(JSON.stringify(data, null, 4));
})
.catch(error => appendOutput(`Error: ${error.message}`));
break;
case 'api':
window.open('{{ base_url }}docs');
break;
Expand Down Expand Up @@ -308,7 +316,6 @@
<span class="yellow help-out">pic</span><span class="blue">- Get a random panda pic</span>
<span class="yellow help-out">gif</span><span class="blue">- Get a random panda gif</span>
<span class="yellow help-out">all</span><span class="blue">- Get a random panda fact, pic, and gif</span>
<span class="yellow help-out">health</span><span class="blue">- Get the health of the API</span>
<span class="yellow help-out">stats</span><span class="blue">- Get the stats of the API</span>
<span class="yellow help-out">api</span><span class="blue">- Get the full API docs</span>
<span class="yellow help-out">github</span><span class="blue">- Go to the Github Repo</span>
Expand All @@ -326,7 +333,7 @@
if (command === '') {
return;
}
const commands = ['fact', 'pic', 'gif', 'all', 'health', 'stats', 'api', 'github', 'help', 'cls'];
const commands = ['fact', 'pic', 'gif', 'all', 'stats', 'api', 'github', 'help', 'cls'];
const matchingCommands = commands.filter(c => c.startsWith(command));
matchingCommands.sort((a, b) => a.length - b.length);

Expand All @@ -340,8 +347,12 @@

function clearTerminal() {
outputArea.innerHTML = '';
let intial_command = document.querySelector('.inital-command');
intial_command.parentNode.removeChild(intial_command);
try {
let intial_command = document.querySelector('.inital-command');
intial_command.parentNode.removeChild(intial_command);
} catch (error) {
console.log(error);
}
commandInput.value = '';
}

Expand Down

0 comments on commit e69f3e7

Please sign in to comment.