fix secrets tab functionalitty
This commit is contained in:
@@ -202,7 +202,9 @@ if ($authenticated && isset($_GET['host'])) {
|
|||||||
> <?php echo htmlspecialchars(str_replace('_', ' ', $type)); ?>
|
> <?php echo htmlspecialchars(str_replace('_', ' ', $type)); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="command">
|
<div class="command">
|
||||||
<?php echo htmlspecialchars($value); ?>
|
<div class="secret-content">
|
||||||
|
<?php echo htmlspecialchars($value); ?>
|
||||||
|
</div>
|
||||||
<button class="copy-btn" data-clipboard="<?php echo htmlspecialchars($value); ?>">
|
<button class="copy-btn" data-clipboard="<?php echo htmlspecialchars($value); ?>">
|
||||||
copy
|
copy
|
||||||
</button>
|
</button>
|
||||||
|
@@ -2,16 +2,53 @@
|
|||||||
document.addEventListener('click', function(e) {
|
document.addEventListener('click', function(e) {
|
||||||
if (e.target && e.target.classList.contains('copy-btn')) {
|
if (e.target && e.target.classList.contains('copy-btn')) {
|
||||||
const text = e.target.getAttribute('data-clipboard');
|
const text = e.target.getAttribute('data-clipboard');
|
||||||
navigator.clipboard.writeText(text).then(function() {
|
|
||||||
const originalText = e.target.innerText;
|
// Check for clipboard API support
|
||||||
e.target.innerText = "copied!";
|
if (navigator.clipboard) {
|
||||||
setTimeout(() => {
|
navigator.clipboard.writeText(text)
|
||||||
e.target.innerText = originalText;
|
.then(function() {
|
||||||
}, 1000);
|
const originalText = e.target.innerText;
|
||||||
});
|
e.target.innerText = "copied!";
|
||||||
|
setTimeout(() => {
|
||||||
|
e.target.innerText = originalText;
|
||||||
|
}, 1000);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.error('Failed to copy: ', err);
|
||||||
|
// Fallback method
|
||||||
|
fallbackCopyTextToClipboard(text, e.target);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Fallback for browsers without clipboard API
|
||||||
|
fallbackCopyTextToClipboard(text, e.target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fallback copy method for older browsers
|
||||||
|
function fallbackCopyTextToClipboard(text, button) {
|
||||||
|
const textArea = document.createElement("textarea");
|
||||||
|
textArea.value = text;
|
||||||
|
textArea.style.position = "fixed"; // Avoid scrolling to bottom
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const successful = document.execCommand('copy');
|
||||||
|
if (successful) {
|
||||||
|
const originalText = button.innerText;
|
||||||
|
button.innerText = "copied!";
|
||||||
|
setTimeout(() => {
|
||||||
|
button.innerText = originalText;
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Fallback: Unable to copy', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
}
|
||||||
// Search functionality
|
// Search functionality
|
||||||
function setupSearch(inputId, itemsSelector) {
|
function setupSearch(inputId, itemsSelector) {
|
||||||
const searchInput = document.getElementById(inputId);
|
const searchInput = document.getElementById(inputId);
|
||||||
|
@@ -179,47 +179,46 @@ button:hover, .action-btn:hover {
|
|||||||
color: var(--secondary);
|
color: var(--secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.secrets {
|
/* Fix for secrets layout */
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.secret {
|
.secret {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 15px;
|
||||||
border: 1px solid var(--border);
|
|
||||||
background: rgba(255, 255, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.secret-title {
|
|
||||||
border-bottom: 1px dashed var(--border);
|
|
||||||
padding: 5px 8px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: var(--text-dim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.command {
|
.command {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
background-color: #111;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
position: relative;
|
border-radius: 3px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.secret-content {
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-all;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
font-family: monospace;
|
||||||
|
max-width: calc(100% - 70px);
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
white-space: pre;
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.copy-btn {
|
.copy-btn {
|
||||||
position: absolute;
|
flex: 0 0 60px;
|
||||||
right: 5px;
|
margin-left: 10px;
|
||||||
top: 5px;
|
align-self: flex-start;
|
||||||
background: transparent;
|
background: #333;
|
||||||
color: var(--secondary);
|
color: #0f0;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid #444;
|
||||||
padding: 2px 5px;
|
padding: 4px 8px;
|
||||||
|
border-radius: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 12px;
|
font-family: monospace;
|
||||||
width: auto;
|
text-transform: lowercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
.copy-btn:hover {
|
.copy-btn:hover {
|
||||||
background: var(--hover);
|
background: #444;
|
||||||
color: var(--text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert {
|
.alert {
|
||||||
|
Reference in New Issue
Block a user