Skip to content

Commit

Permalink
Merge pull request #36 from Incpi/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Incpi authored Oct 14, 2024
2 parents c611fa9 + 772d8fe commit a1f795a
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ If you want to create your own custom theme, you can modify the `themeMap` objec

### v1.3.6

- [Feature] Unix & ISO time stamp converter addedin popup
- [Improvement] load time was decreased by optimizing the extension runtime.
- [BugFix] Events includes further minor UI tweaks and consistent bit order
- [Release] Adding Release on github to quickly get binary via github.
- [BugFix] Toolbar will not be compromised with Super Easy extension.

### v1.3.5

Expand Down
6 changes: 6 additions & 0 deletions Whatsnew/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

const data_updates = {
bugFixes: [
{
description: "Toolbar will not be compromised with <strong>Super Easy extension</strong>",
},
{
description: "Events includes further minor UI tweaks and consistent bit order",
},
Expand All @@ -17,6 +20,9 @@ const data_updates = {
},
],
features: [
{
description: "Unix & ISO time stamp converter addedin popup",
},
{
description: "Adding Release on github to quickly get binary via github.",
},
Expand Down
Binary file modified bin/Dark CPI Extension.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions docs/readme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ If you want to create your own custom theme, you can modify the `themeMap` objec

### v1.3.6

- [Feature] Unix & ISO time stamp converter addedin popup
- [Improvement] load time was decreased by optimizing the extension runtime.
- [BugFix] Events includes further minor UI tweaks and consistent bit order
- [Release] Adding Release on github to quickly get binary via github.
- [BugFix] Toolbar will not be compromised with Super Easy extension.

### v1.3.5

Expand Down
6 changes: 6 additions & 0 deletions host/CPI/content/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ html:is([data-cpi-dark='sap_horizon_dark'], [data-cpi-dark='sap_horizon']) .sapU
margin-right: 0.5rem;
}

.modToolbar > ul > li {
margin-right: 0.75rem;
margin-left: 0.75rem;
padding-top: 0.5rem;
}

.cpiBadgeIndicator {
position: absolute;
top: 0;
Expand Down
16 changes: 14 additions & 2 deletions popup/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,18 @@ main h1 {
body {
font-family: Arial, sans-serif;
text-align: center;
width: max-content;
max-height: 800px;
margin: 0;
background-color: var(--bg-color);
color: var(--text-color);
}

span#output-text {
white-space: pre-wrap;
white-space-collapse: break-spaces;
text-wrap: pretty;
}

.darkcpiglobal .navbar {
justify-content: space-between;
}
Expand All @@ -70,6 +75,10 @@ main:not(:has(div[role='alert'])) {
}
}

.stat-value {
font-size: large !important;
}

.alert.alert-error {
border-radius: 0px;
font-size: medium;
Expand All @@ -96,8 +105,11 @@ main:not(:has(div[role='alert'])) {

.alert {
grid-auto-flow: column;
grid-template-columns: auto minmax(auto, 1fr);
/* grid-template-columns: auto minmax(auto, 1fr); */
justify-items: start;
text-align: start;
span {
color: var(--text-color);
}
}
}
38 changes: 35 additions & 3 deletions popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,41 @@ <h1 class="text-xl font-bold"><span class="activeapp"></span> Application: <span
<div id="options" class="space-x-2"></div>
</div>
</main>
<script src="./../lib/Daisyui.min.js"></script>
<script src="./../common/constants.js"></script>
<script type="module" src="popup.js"></script>
<div class="divider divider-info"><span style="font-size: larger;font-weight: bold;">Live Time</span></div>
<div class="stats stats-vertical lg:stats-horizontal shadow">
<div class="stat">
<div class="stat-title">UTC Time</div>
<div class="stat-value" id="utc-time"></div>
</div>
<div class="stat">
<div class="stat-title">Local Time</div>
<div class="stat-value" id="local-time"></div>
</div>
</div>
<!-- header -->
<div class="max-w-lg w-full bg-white rounded-xl shadow-lg p-6 space-y-6">
<div class="divider divider-info"><span style="font-size: larger;font-weight: bold;">Time Converter</span></div>
<div class="bg-gray-100 rounded-lg p-4 shadow border border-gray-300">
<input type="text" id="time-input" class="input input-bordered input-primary" style="width: 90% !important;"
placeholder="Enter Unix or ISO timestamp">
<div class="stat" id="converted-output">
<div class="stat-title" id="time-type"></div>
<div class="stat-value" id="output-text"></div>
<div id="copy-icon" class="stat-actions">
<button class="btn btn-sm">Copy</button>
</div>
</div>
</div>
<div id="toast" style="display: none;" class="toast toast-end">
<div class="alert" style="padding: 0.5rem;">
<span style="font-size: small;"></span>
</div>
</div>

<script src="./../lib/Daisyui.min.js"></script>
<script src="./../common/constants.js"></script>
<script type="module" src="popup.js"></script>
<script src="time-convert.js"></script>
</body>

</html>
7 changes: 4 additions & 3 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function populateOptions(vartheme) {
document.getElementById("options").innerHTML = Object.keys(vartheme)
.map((key) => {
return `<button class="btn btn-sm" data-value="${key}">${vartheme[key].buttonlabel}</button>`;
return `<button class="btn btn-sm btn-themes" data-value="${key}">${vartheme[key].buttonlabel}</button>`;
})
.join("");
}
Expand Down Expand Up @@ -114,13 +114,13 @@ async function main() {
} else {
}
console.log("Host:", internalHostname);
const buttons = document.querySelectorAll(".btn-sm");
const buttons = document.querySelectorAll(".btn-themes");
const activetheme = document.querySelector(".activetheme");
const activeapp = document.querySelector(".activeapp");
let theme = (await getProperty("SapDarkCPITheme")) || 0;
console.log("Theme:", theme);
const selectedButton = document.querySelector(`.btn-sm[data-value="${theme}"]`);

document.querySelector(".darkcpiglobal").setAttribute("data-theme", (await getProperty("SapDarkCPITheme")) === "1" ? "dark" : "light");
if (selectedButton) {
selectedButton.classList.add("active");
activetheme.textContent = selectedButton.textContent;
Expand All @@ -146,6 +146,7 @@ async function main() {
} else if (selectedValue === "2") {
document.body.classList.add("old-theme");
}
document.querySelector(".darkcpiglobal").setAttribute("data-theme", (await getProperty("SapDarkCPITheme")) === "1" ? "dark" : "light");
});
});
}
Expand Down
79 changes: 79 additions & 0 deletions popup/time-convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"use strict";

function updateTime() {
const localTime = new Date();
const utcTime = new Date(localTime.toISOString());

document.getElementById("local-time").innerText = localTime.toLocaleString().toUpperCase();
document.getElementById("utc-time").innerText = utcTime.toLocaleString("en-US", { timeZone: "UTC" });
}

function convertTimestamp() {
const input = document.getElementById("time-input").value.trim();
const outputTextElement = document.getElementById("output-text");
const localTimeDisplay = document.getElementById("local-time");
const utcTimeDisplay = document.getElementById("utc-time");
if (!input) {
outputTextElement.innerText = "";
updateTime();
return;
}

let date;
let timeType = "Error";
// Check if the input is a valid Unix timestamp (e.g., all digits).
if (/^\d+$/.test(input)) {
const unixTimestamp = parseInt(input, 10);
date = new Date(unixTimestamp * 1000); // Convert to milliseconds.
outputTextElement.innerText = `${date.toISOString()}`;
timeType = "ISO";
}
// Check if the input is a valid ISO string.
else if (!isNaN(Date.parse(input))) {
date = new Date(input);
const unixTimestamp = Math.floor(date.getTime() / 1000);
timeType = "Unix";
outputTextElement.innerText = `${unixTimestamp}`;
} else {
showToast("Invalid Unix or ISO timestamp", "error");
return;
}
document.getElementById("time-type").innerHTML = timeType;
// Display the local time and UTC time derived from the date.
localTimeDisplay.innerText = date.toLocaleString();
utcTimeDisplay.innerText = date.toLocaleString("en-US", { timeZone: "UTC" });
}

// Copy the output to clipboard when the icon is clicked.
document.getElementById("copy-icon").addEventListener("click", function () {
const outputText = document.getElementById("output-text").innerText;

if (outputText) {
navigator.clipboard
.writeText(outputText)
.then(() => {
showToast("Copied Stamp");
})
.catch(() => {
showToast("Failed to Copy", "error");
});
}
});

// Function to show the toast message
function showToast(message, type = "success", toast = document.getElementById("toast")) {
toast.querySelector("span").innerText = message;
toast.style.display = "block";
toast.querySelector(".alert").classList = "alert alert-" + type;
// Hide the toast after 3 seconds
setTimeout(() => {
toast.style.display = "none";
console.log("closed");
}, 3000);
}

// Add event listener for input change.
document.getElementById("time-input").addEventListener("input", convertTimestamp);

// Update the time every second.
setInterval(updateTime, 1000);

0 comments on commit a1f795a

Please sign in to comment.