derfvgtbyhnju / index.html
Krikoset's picture
Update index.html
4b2205b verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ASCII Art Clock</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #000;
color: #fff;
font-family: monospace;
margin: 0;
position: relative;
}
.clock {
white-space: pre;
text-align: center;
font-size: 4vw;
line-height: 0.8;
}
.blink {
animation: blink-animation 1s steps(1, end) infinite;
}
@keyframes blink-animation {
50% {
visibility: hidden;
}
}
#editor, #style-selector {
position: fixed;
top: 10px;
right: 10px;
background-color: rgba(50, 50, 50, 0.9);
color: #fff;
padding: 20px;
border-radius: 10px;
border: 1px solid #fff;
display: none;
z-index: 1000;
font-family: Arial, sans-serif;
}
#editor textarea {
width: 100%;
height: 200px;
background-color: #222;
color: #fff;
font-family: monospace;
border: none;
padding: 10px;
border-radius: 5px;
}
#open-editor, #open-style-selector {
position: fixed;
top: 10px;
right: 10px;
color: #fff;
cursor: pointer;
z-index: 1000;
font-size: 24px;
}
#style-selector select {
width: 100%;
padding: 10px;
margin-top: 10px;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
}
#style-selector button, #editor button {
background-color: #444;
color: #fff;
border: none;
padding: 10px 20px;
margin-top: 10px;
cursor: pointer;
border-radius: 5px;
width: 100%;
}
</style>
</head>
<body>
<div class="clock" id="clock"></div>
<div id="open-editor">*</div>
<div id="style-selector">
<label for="styles">Choose a style:</label>
<select id="styles">
<option value="default">Default</option>
<option value="style1">Style 1</option>
<option value="style2">Style 2</option>
</select>
<button onclick="closeStyleSelector()">Close</button>
</div>
<div id="editor">
<h3>Edit ASCII Art</h3>
<textarea id="custom-style"></textarea>
<button onclick="saveCustomStyle()">Save</button>
<button onclick="closeEditor()">Close</button>
</div>
<script>
const asciiArtStyles = {
"default": {
"0": "###\n# #\n# #\n# #\n###",
"1": " #\n #\n #\n #\n #",
"2": "###\n #\n###\n# \n###",
"3": "###\n #\n###\n #\n###",
"4": "# #\n# #\n###\n #\n #",
"5": "###\n# \n###\n #\n###",
"6": "###\n# \n###\n# #\n###",
"7": "###\n #\n #\n #\n #",
"8": "###\n# #\n###\n# #\n###",
"9": "###\n# #\n###\n #\n###",
":": " \n # \n \n # \n "
},
"style1": {
"0": "@@@\n@ @\n@ @\n@ @\n@@@",
"1": " @\n @\n @\n @\n @",
"2": "@@@\n @\n@@@\n@ \n@@@",
"3": "@@@\n @\n@@@\n @\n@@@",
"4": "@ @\n@ @\n@@@\n @\n @",
"5": "@@@\n@ \n@@@\n @\n@@@",
"6": "@@@\n@ \n@@@\n@ @\n@@@",
"7": "@@@\n @\n @\n @\n @",
"8": "@@@\n@ @\n@@@\n@ @\n@@@",
"9": "@@@\n@ @\n@@@\n @\n@@@",
":": " \n @ \n \n @ \n "
},
"style5": {
"0": "OOO\nO O\nO O\nO O\nOOO",
"1": " O\n O\n O\n O\n O",
"2": "OOO\n O\nOOO\nO \nOOO",
"3": "OOO\n O\nOOO\n O\nOOO",
"4": "O O\nO O\nOOO\n O\n O",
"5": "OOO\nO \nOOO\n O\nOOO",
"6": "OOO\nO \nOOO\nO O\nOOO",
"7": "OOO\n O\n O\n O\n O",
"8": "OOO\nO O\nOOO\nO O\nOOO",
"9": "OOO\nO O\nOOO\n O\nOOO",
":": " \n O \n \n O \n "
}
};
let currentStyle = "default";
function updateClock() {
const currentTime = new Date();
const hours = String(currentTime.getHours()).padStart(2, '0');
const minutes = String(currentTime.getMinutes()).padStart(2, '0');
const seconds = String(currentTime.getSeconds()).padStart(2, '0');
const timeString = `${hours}:${minutes}:${seconds}`;
const lines = ["", "", "", "", ""];
for (let char of timeString) {
const charLines = asciiArtStyles[currentStyle][char].split('\n');
for (let i = 0; i < 5; i++) {
lines[i] += char === ':' ? `<span class="blink">${charLines[i]}</span> ` : `${charLines[i]} `;
}
}
document.getElementById('clock').innerHTML = lines.join('\n');
}
function openStyleSelector() {
document.getElementById('style-selector').style.display = 'block';
}
function closeStyleSelector() {
document.getElementById('style-selector').style.display = 'none';
}
function openEditor() {
document.getElementById('editor').style.display = 'block';
}
function closeEditor() {
document.getElementById('editor').style.display = 'none';
}
function saveCustomStyle() {
const customStyle = document.getElementById('custom-style').value;
const customStyleLines = customStyle.split('\n');
const customAsciiArt = {};
let currentChar = null;
let currentArt = [];
for (let line of customStyleLines) {
if (line.length === 1 && line.match(/[0-9:]/)) {
if (currentChar) {
customAsciiArt[currentChar] = currentArt.join('\n');
}
currentChar = line;
currentArt = [];
} else {
currentArt.push(line);
}
}
if (currentChar) {
customAsciiArt[currentChar] = currentArt.join('\n');
}
asciiArtStyles.custom = customAsciiArt;
currentStyle = 'custom';
closeEditor();
updateClock();
}
document.getElementById('open-editor').addEventListener('click', () => {
openStyleSelector();
});
document.getElementById('styles').addEventListener('change', (event) => {
currentStyle = event.target.value;
updateClock();
});
setInterval(updateClock, 1000);
updateClock(); // Initial call to display the clock immediately
</script>
</body>
</html>