HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body style="cursor: default">
<div class="datetime-content">
<div class="datetime-wrapper">
<h1 id="datetime-day">SUNDAY</h1>
<h5 id="datetime-date">24 JUNE 2024</h5>
<h5 id="datetime-time">- 8:24 AM -</h5>
</div>
<div id="window-terminal" class="window hidden">
<div class="window-top-bar">
<div>Terminal - Nuvola OS</div>
<div style="margin-left: auto">
<img class="window-minimize-icon" src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/window-minimize-symbolic.svg" alt="minimize icon" width="16" height="16" onclick="minimize('window-terminal');" />
<img class="window-maximize-icon" src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/window-maximize-symbolic.svg" alt="maximize icon" width="16" height="16" data-maximized="false" onclick="maximize('window-terminal');" />
<img class="window-close-icon" src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/window-close-symbolic.svg" alt="close icon" width="16" height="16" onclick="closeWindow('window-terminal');" />
</div>
</div>
<div class="window-content" style="padding: 10px 20px">
<div style="display: flex">
<div class="logo">
MMMMMMMMMMMMMMMWWWMMMMMMMMMMMMMMMM<br />
MMMMMMMMMMMMMMWKkOXWMMMMMMMMMMMMMM<br />
MMMMMMMMMMMMMW0l..oKWMMMMMMMMMMMMM<br />
MMMMMMMMMMMMW0c....oKWMMMMMMMMMMMM<br />
MMMMMMMMMMMWOc......oKWMMMMMMMMMMM<br />
MMMMMMMMMMWOc........oKWMMMMMMMMMM<br />
MMMMMMMMMNOc...oxdc...lKWMMMMWX000<br />
MMMMMMMMNk....dXWN0lclxKNX0kdodk0N<br />
MMMMMMMNk....dXMMMWX0Oxoc..lx0NMMM<br />
MMMMWKko..ldOKXOxddo......xNMMMMMM<br />
WNKkxddkkkkdo........c.....0WMMMMM<br />
K0O00kdl.........cokXW0.....0WMMMM<br />
WMMXo.........oOXWWMMMW0c....0WMMM<br />
MMXo.......d0NWMMMMMMMMW0.....OWMM<br />
MNx....cd0NMMMMMMMMMMMMMM0c...lKMM<br />
MWK0KKKNMMMMMMMMMMMMMMMMMMXKKKKNMM<br />
</div>
<div class="output">
<div>
<span class="key">Author:</span>
<span class="value">
<strong><a href="https://github.com/Fantantonio/DevPlayground/blob/main/Nuvola%20OS" target="_blank">Antonio Panfili</a> - www.antoniopanfili.it</strong>
</span>
</div>
<div>
<span class="key">Version:</span>
<span class="value">1.0.0-alpha</span>
</div>
<div>
<span class="key">Description:</span>
<span class="value">Just a project I made for fun in my spare time. Feel free to
like it 💚
</span>
</div>
<div>
<span class="key">Uptime:</span>
<span id="time-elapsed" class="value"></span>
</div>
<div>
<span class="key">Min-resolution:</span>
<span class="value">1200x900</span>
</div>
<div>
<span class="key">Icons:</span>
<span class="value">
Thanks to:
<a href="https://github.com/yeyushengfan258/We10X-icon-theme/tree/master" target="_blank">
We10X-icon-theme
</a>
</span>
</div>
<div>
<span class="key">Background image:</span>
<span class="value">
<a href="https://leonardo.ai" target="_blank">Leonardo.ai</a>
</span>
</div>
<div>
<span class="key">Browser:</span>
<span id="browser-info" class="value"></span>
</div>
<div>
<span class="key">Browser version:</span>
<span id="browser-version" class="value"></span>
</div>
<div>
<span class="key">Fonts:</span>
<span class="value">
<a href="https://www.dafont.com/it/disolve.font" target="_blank">Disolve</a>,
<a href="https://www.dafont.com/it/roboto.font" target="_blank">Roboto</a>
</span>
</div>
<div>
<span class="key">Language:</span>
<span id="browser-language" class="value"></span>
</div>
<div>
<span class="key">Client OS:</span>
<span id="client-OS" class="value"></span>
</div>
<div>
<span class="key">Platform:</span>
<span id="client-platform" class="value"></span>
</div>
<div>
<span class="key">Timezone:</span>
<span id="time-zone" class="value"></span>
</div>
<div>
<span class="key">User agent:</span>
<span id="user-agent" class="value"></span>
</div>
<div>
<span class="key">Java enabled:</span>
<span id="client-java" class="value"></span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Navbar -->
<div class="navbar-container">
<nav class="navbar navbar-left">
<img id="icon-search" src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/folder-saved-search-symbolic.svg" alt="search icon" width="32" height="32" />
<span style="
border-style: solid;
border-color: white;
border-width: 1px;
height: 40px;
margin-left: 5px;
margin-right: 5px;
"></span>
<ul>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/folder-development-symbolic.svg" alt="settings icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/ubiquity-symbolic.svg" alt="update icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/camera-web-symbolic.svg" alt="webcam icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/media-removable-symbolic.svg" alt="usb icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/edit-paste-symbolic.svg" alt="paste icon" width="16" height="16" />
</li>
</ul>
</nav>
<nav class="navbar">
<ul>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/preferences-desktop-display-color.svg" />
</a>
</li>
<li>
<div style="
display: flex;
flex-direction: column;
align-items: center;
">
<a class="bar-img" href="#">
<img onclick="show('window-terminal');" onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/terminal.svg" />
</a>
<div id="nav-open-terminal" class="nav-open-window hidden"></div>
</div>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/file-manager.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/abrowser.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/desktop.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/smplayer.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/google-music.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/apps/scalable/office-calendar.svg" />
</a>
</li>
<li>
<a class="bar-img" href="#">
<img onmouseover="this.classList.add('scale-in-bottom'); this.classList.remove('scale-out-bottom');" onmouseleave="this.classList.add('scale-out-bottom'); this.classList.remove('scale-in-bottom');" src="https://raw.githubusercontent.com/yeyushengfan258/We10X-icon-theme/5ec70feac22ed9e415850d14c755563c5ff0e225/src/places/16/user-trash.svg" />
</a>
</li>
</ul>
</nav>
<nav class="navbar navbar-right">
<ul>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/display-brightness-symbolic.svg" alt="brightness icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/bluetooth-active-symbolic.svg" alt="bluetooth icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/battery-full-charging-symbolic.svg" alt="battery icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/network-wired-symbolic.svg" alt="network icon" width="16" height="16" />
</li>
<li>
<img src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/audio-volume-medium-symbolic.svg" alt="volume icon" width="16" height="16" />
</li>
</ul>
<span style="
border-style: solid;
border-color: white;
border-width: 1px;
height: 40px;
margin-left: 5px;
margin-right: 5px;
"></span>
<img id="icon-notification" src="https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/user-invisible-symbolic.svg" alt="volume icon" width="32" height="32" />
</nav>
</div>
</body>
@font-face {
font-family: "Dissolve";
src: url("https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/font/disolve/Disolve_regular.ttf")
format("truetype");
}
@font-face {
font-family: "Roboto";
src: url("https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/font/roboto/Roboto-Light.ttf")
format("truetype");
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
background-color: black;
background-image: url("https://github.com/Fantantonio/DevPlayground/blob/main/Nuvola%20OS/img/background.jpg?raw=true");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}
h5 {
margin: 0px;
}
.datetime-content {
color: white;
display: flex;
font-family: Roboto, sans-serif;
justify-content: center;
letter-spacing: 4px;
margin-top: 100px;
}
.datetime-wrapper {
align-items: center;
display: flex;
flex-direction: column;
}
#datetime-day {
font-family: Dissolve, sans-serif;
font-size: 70px;
font-weight: lighter;
letter-spacing: 20px;
margin-bottom: 30px;
padding-left: 20px;
}
#datetime-date {
margin-bottom: 15px;
}
/* Navbar */
.navbar-container {
position: fixed;
display: flex;
bottom: 20px;
justify-content: space-between;
left: 20px;
right: 20px;
align-items: center;
}
.navbar {
display: flex;
justify-content: space-around;
background-color: rgba(255, 255, 255, 0.4);
border-radius: 10px;
padding: 10px 17px 10px 10px;
width: fit-content;
height: 80px;
ul {
list-style: none;
padding: 0;
margin: 0;
li {
display: inline-block;
margin: 0 10px;
a {
color: white;
text-decoration: none;
font-size: 24px;
img {
height: 54px;
}
img:hover {
cursor: pointer;
}
}
}
}
img:hover {
cursor: pointer;
}
}
.navbar-left,
.navbar-right {
display: flex;
align-items: center;
padding: 10px 10px 10px 10px;
height: min-content;
ul {
li {
margin: 0 3px;
}
}
}
.nav-open-window {
width: 10px;
height: 5px;
border-radius: 15px;
background: #404040;
margin-top: -5px;
}
#icon-notification,
#icon-search {
margin-left: 4px;
margin-right: 4px;
}
.scale-in-bottom {
-webkit-animation: scale-in-bottom 0.5s cubic-bezier(0.23, 1, 0.32, 1) both;
animation: scale-in-bottom 0.5s cubic-bezier(0.23, 1, 0.32, 1) both;
}
.scale-out-bottom {
-webkit-animation: scale-out-bottom 0.5s cubic-bezier(0.23, 1, 0.32, 1) both;
animation: scale-out-bottom 0.5s cubic-bezier(0.23, 1, 0.32, 1) both;
}
@-webkit-keyframes scale-in-bottom {
0% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
100% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
}
@keyframes scale-in-bottom {
0% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
100% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
}
@-webkit-keyframes scale-out-bottom {
0% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
}
@keyframes scale-out-bottom {
0% {
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
opacity: 1;
}
}
/* Window */
.window {
background-color: #0b002c94;
backdrop-filter: blur(10px);
border-color: #0b002c94;
color: #2ecc71;
border-radius: 15px;
border-style: solid;
border-width: 1px;
width: 700px;
height: 500px;
position: absolute;
font-family: monospace;
font-size: 14px;
.window-top-bar {
border-bottom-color: #0b002cb3;
border-bottom-style: solid;
border-bottom-width: 1px;
color: white;
padding: 10px 13px 10px 13px;
display: flex;
.window-minimize-icon,
.window-maximize-icon,
.window-close-icon {
cursor: pointer;
border-radius: 10px;
}
.window-minimize-icon {
box-shadow: 0px 1px 10px limegreen;
}
.window-maximize-icon {
box-shadow: 0px 1px 10px orange;
}
.window-close-icon {
box-shadow: 0px 1px 10px red;
}
}
.window-content {
height: calc(100% - 49px);
overflow-y: auto;
letter-spacing: normal;
.key {
color: #f39c12;
}
.value {
color: #2ecc71;
}
.logo {
color: #2ecc71;
font-family: monospace;
margin-right: 20px;
}
}
a,
a:visited {
color: #cfb850;
}
a:hover {
color: #cf6350;
}
}
.hidden {
display: none !important;
}
.maximized {
width: 100%;
height: 100%;
left: 0px;
top: 0px;
}
const windowTerminal = document.getElementById("window-terminal");
let offsetX, offsetY;
const show = function (element_id) {
document.getElementById(element_id).classList.remove("hidden");
document.getElementById("nav-open-terminal").classList.remove("hidden");
};
const hide = function (element_id) {
document.getElementById(element_id).classList.add("hidden");
};
const maximize = function (element_id) {
const element = document.getElementById(element_id);
const icon = element.querySelector(".window-maximize-icon");
if (element.getAttribute("data-maximized") === "true") {
element.classList.remove("maximized");
element.setAttribute("data-maximized", "false");
element.setAttribute("style", "");
icon.src =
"https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/window-maximize-symbolic.svg";
} else {
element.classList.add("maximized");
element.setAttribute("data-maximized", "true");
element.setAttribute("style", "");
icon.src =
"https://raw.githubusercontent.com/Fantantonio/DevPlayground/3a7c92fd206d73b519d2619ec667f59761c22218/Nuvola%20OS/img/icons/window-restore-symbolic.svg";
}
};
const minimize = function (element_id) {
hide(element_id);
show("nav-open-terminal");
};
const closeWindow = function (element_id) {
hide(element_id);
hide("nav-open-terminal");
};
const getCurrentDayName = function () {
const days = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
const currentDate = new Date();
// Get the day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
const dayIndex = currentDate.getDay();
return days[dayIndex].toUpperCase();
};
const getCurrentDateFormat = function () {
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
const currentDate = new Date();
const day = currentDate.getDate();
const monthIndex = currentDate.getMonth();
const year = currentDate.getFullYear();
const monthName = months[monthIndex].toUpperCase();
return `${day} ${monthName} ${year}`;
};
const getCurrentTimeFormat = function () {
const currentDate = new Date();
let hours = currentDate.getHours();
const minutes = currentDate.getMinutes();
const ampm = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
const formattedTime = `${hours}:${minutes < 10 ? "0" : ""}${minutes} ${ampm}`;
return `- ${formattedTime} -`;
};
const handleMouseDown = function (e) {
// Store the initial mouse position
offsetX = e.clientX - windowTerminal.getBoundingClientRect().left;
offsetY = e.clientY - windowTerminal.getBoundingClientRect().top;
// Add event listeners for mouse move and mouse up events
document.addEventListener("mousemove", handleMouseMove);
document.addEventListener("mouseup", handleMouseUp);
};
const handleMouseMove = function (e) {
// Calculate new window position based on mouse movement
const newX = e.clientX - offsetX;
const newY = e.clientY - offsetY;
// Set the new window position
windowTerminal.style.left = newX + "px";
windowTerminal.style.top = newY + "px";
};
const handleMouseUp = function () {
// Remove event listeners for mouse move and mouse up events
document.removeEventListener("mousemove", handleMouseMove);
document.removeEventListener("mouseup", handleMouseUp);
};
const timeElapsed = function (datetimeString) {
const [dateStr, timeStr] = datetimeString.split(" ");
const [day, month, year] = dateStr.split("/");
const [_hours, _minutes, _seconds] = timeStr.split(":").map(Number);
const givenDatetime = new Date(
year,
month - 1,
day,
_hours,
_minutes,
_seconds
);
const currentDatetime = new Date();
let timeDiff = currentDatetime - givenDatetime;
const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
timeDiff -= days * (1000 * 60 * 60 * 24);
const hours = Math.floor(timeDiff / (1000 * 60 * 60));
timeDiff -= hours * (1000 * 60 * 60);
const minutes = Math.floor(timeDiff / (1000 * 60));
timeDiff -= minutes * (1000 * 60);
const seconds = Math.floor(timeDiff / 1000);
let result = "";
if (days > 0) {
result += `${days} day${days > 1 ? "s" : ""}, `;
}
if (hours > 0) {
result += `${hours} hour${hours > 1 ? "s" : ""}, `;
}
if (minutes > 0) {
result += `${minutes} minute${minutes > 1 ? "s" : ""}`;
}
if (days === 0 && hours === 0 && minutes === 0) {
result += `${seconds} second${seconds > 1 ? "s" : ""}`;
}
return result;
};
const getBrowserInfo = function () {
var userAgent = window.navigator.userAgent;
var browsers = {
Chrome: /(?:Chrome|CriOS)\/([\d\.]+)/,
Edge: /Edge\/([\d\.]+)/,
Firefox: /Firefox\/([\d\.]+)/,
IE: /MSIE\s([\d\.]+)/,
Opera: /(?:Opera|OPR)\/([\d\.]+)/,
Safari: /Version\/([\d\.]+).*Safari/
};
for (var browser in browsers) {
var match = userAgent.match(browsers[browser]);
if (match) {
return {
name: browser,
version: match[1]
};
}
}
return {
name: "Unknown",
version: "Unknown"
};
};
document.getElementById("datetime-day").innerText = getCurrentDayName();
document.getElementById("datetime-date").innerText = getCurrentDateFormat();
document.getElementById("datetime-time").innerText = getCurrentTimeFormat();
windowTerminal
.querySelector(".window-top-bar")
.addEventListener("mousedown", handleMouseDown);
document.getElementById("time-elapsed").innerText = timeElapsed(
"15/05/2024 14:00:00"
);
const browser_info = getBrowserInfo();
document.getElementById("browser-info").innerText = browser_info.name;
document.getElementById("browser-version").innerText = browser_info.version;
document.getElementById("browser-language").innerText = navigator.language;
document.getElementById("client-platform").innerText = navigator.platform;
document.getElementById("client-OS").innerText = navigator.appVersion;
document.getElementById("user-agent").innerText = navigator.userAgent;
document.getElementById("client-java").innerText = navigator.javaEnabled();
document.getElementById(
"time-zone"
).innerText = Intl.DateTimeFormat().resolvedOptions().timeZone;
Also see: Tab Triggers