mirror of
https://github.com/maciejpedzich/maciejpedzi.ch.git
synced 2024-11-27 23:55:47 +01:00
Version 2.4.1 release
This commit is contained in:
parent
42d2a471b5
commit
cd7ea8f7ee
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.4.1
|
||||||
|
|
||||||
|
- Set `inputHistory` in localStorage to a stringified array, rather tan a string of comma-separated values
|
||||||
|
|
||||||
## 2.4.0
|
## 2.4.0
|
||||||
|
|
||||||
- Persist input history (up to 10 entries) using `localStorage`
|
- Persist input history (up to 10 entries) using `localStorage`
|
||||||
|
@ -3,7 +3,7 @@ const cmdHistoryElement = document.querySelector('#cmd-history');
|
|||||||
const today = new Date();
|
const today = new Date();
|
||||||
const currentYear = today.getFullYear();
|
const currentYear = today.getFullYear();
|
||||||
const inputHistory = localStorage.getItem('inputHistory')
|
const inputHistory = localStorage.getItem('inputHistory')
|
||||||
? localStorage.getItem('inputHistory').split(',')
|
? JSON.parse(localStorage.getItem('inputHistory'))
|
||||||
: [];
|
: [];
|
||||||
let cmdIndex = 0;
|
let cmdIndex = 0;
|
||||||
|
|
||||||
@ -17,9 +17,9 @@ window.addEventListener('keypress', (evt) => {
|
|||||||
|
|
||||||
if (evt.key === 'Enter' && command.length > 0) {
|
if (evt.key === 'Enter' && command.length > 0) {
|
||||||
const args = split.slice(1);
|
const args = split.slice(1);
|
||||||
|
|
||||||
const cmdToSave = document.createElement('p');
|
const cmdToSave = document.createElement('p');
|
||||||
const output = document.createElement('p');
|
const output = document.createElement('p');
|
||||||
|
|
||||||
cmdToSave.textContent = `> ${inputText}`;
|
cmdToSave.textContent = `> ${inputText}`;
|
||||||
cmdHistoryElement.append(cmdToSave);
|
cmdHistoryElement.append(cmdToSave);
|
||||||
|
|
||||||
@ -37,14 +37,14 @@ window.addEventListener('keypress', (evt) => {
|
|||||||
When not coding, he is probably watching an F1 race, or playing retro video games.`;
|
When not coding, he is probably watching an F1 race, or playing retro video games.`;
|
||||||
break;
|
break;
|
||||||
case 'bgcolor':
|
case 'bgcolor':
|
||||||
const bgcolor = args[0];
|
const [bgcolor] = args;
|
||||||
document.body.style.backgroundColor = bgcolor;
|
document.body.style.backgroundColor = bgcolor;
|
||||||
break;
|
break;
|
||||||
case 'cls':
|
case 'cls':
|
||||||
cmdHistoryElement.textContent = '';
|
cmdHistoryElement.textContent = '';
|
||||||
break;
|
break;
|
||||||
case 'color':
|
case 'color':
|
||||||
const color = args[0];
|
const [color] = args;
|
||||||
document.body.style.color = color;
|
document.body.style.color = color;
|
||||||
input.style.color = color;
|
input.style.color = color;
|
||||||
break;
|
break;
|
||||||
@ -53,7 +53,7 @@ window.addEventListener('keypress', (evt) => {
|
|||||||
<a href="mailto:contact@maciejpedzi.ch">contact@maciejpedzi.ch</a>`;
|
<a href="mailto:contact@maciejpedzi.ch">contact@maciejpedzi.ch</a>`;
|
||||||
break;
|
break;
|
||||||
case 'github':
|
case 'github':
|
||||||
output.innerHTML = `If new tab didn't show up, go <a href="https://github.com/maciejpedzich">here</a>`;
|
output.innerHTML = `If a new tab didn't show up, go <a href="https://github.com/maciejpedzich">here</a>`;
|
||||||
window.open('https://github.com/maciejpedzich');
|
window.open('https://github.com/maciejpedzich');
|
||||||
break;
|
break;
|
||||||
case "'help'":
|
case "'help'":
|
||||||
@ -81,7 +81,10 @@ window.addEventListener('keypress', (evt) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inputHistory.unshift(inputText);
|
inputHistory.unshift(inputText);
|
||||||
localStorage.setItem('inputHistory', inputHistory.slice(0, 10).join());
|
localStorage.setItem(
|
||||||
|
'inputHistory',
|
||||||
|
JSON.stringify(inputHistory.slice(0, 10))
|
||||||
|
);
|
||||||
|
|
||||||
cmdHistoryElement.append(output);
|
cmdHistoryElement.append(output);
|
||||||
input.value = '';
|
input.value = '';
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<p>maciejpedzi.ch [Version 2.4.0]</p>
|
<p>maciejpedzi.ch [Version 2.4.1]</p>
|
||||||
<p>(C) Maciej Pedzich <span id="current-year"></span></p>
|
<p>(C) Maciej Pedzich <span id="current-year"></span></p>
|
||||||
<p id="hint">Welcome! Type 'help' for more information</p>
|
<p id="hint">Welcome! Type 'help' for more information</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user