mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-16 04:59:42 +01:00
Copy button in BS style is dynamic now
This commit is contained in:
@@ -136,23 +136,22 @@
|
||||
const copyText = button.closest('.form-group').querySelector('textarea');
|
||||
copyText.select();
|
||||
document.execCommand("copy");
|
||||
|
||||
// Show tooltip
|
||||
const tooltip = document.createElement("div");
|
||||
tooltip.innerHTML = "Copied!";
|
||||
tooltip.style.position = "fixed";
|
||||
tooltip.style.bottom = "10px";
|
||||
tooltip.style.right = "10px";
|
||||
tooltip.style.backgroundColor = "lightgreen";
|
||||
tooltip.style.padding = "10px";
|
||||
tooltip.style.borderRadius = "5px";
|
||||
document.body.appendChild(tooltip);
|
||||
|
||||
// Remove tooltip after 3 seconds
|
||||
|
||||
// Store original button text
|
||||
const originalButtonText = button.textContent;
|
||||
|
||||
// Disable button while text is being copied
|
||||
button.disabled = true;
|
||||
|
||||
// Change button text to "Copied!"
|
||||
button.textContent = "✔️";
|
||||
|
||||
// Wait for 3 seconds and then change button text back to original
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(tooltip);
|
||||
button.textContent = originalButtonText;
|
||||
button.disabled = false;
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
function convertSize(size) {
|
||||
if (size > 1024 * 1024 * 1024) {
|
||||
@@ -217,7 +216,6 @@
|
||||
self.humanSize = humanSize;
|
||||
let newHTML = humanSent + " / " + humanSize + " (" + percent.toFixed(2) + "%) complete";
|
||||
stats.innerHTML = newHTML;
|
||||
console.log(uploadSpeed);
|
||||
};
|
||||
|
||||
xhttp.onreadystatechange = function (e) {
|
||||
@@ -241,6 +239,19 @@
|
||||
});
|
||||
html += "</ul>";
|
||||
speed.insertAdjacentHTML("afterend", html);
|
||||
|
||||
// Add buttons after the new textareas
|
||||
const formGroups = document.querySelectorAll(".form-group");
|
||||
formGroups.forEach(formGroup => {
|
||||
const textarea = formGroup.querySelector("textarea");
|
||||
if (textarea) {
|
||||
const button = document.createElement("button");
|
||||
button.innerHTML = "📋";
|
||||
button.classList.add("btn", "btn-primary", "btn-sm", "mt-2");
|
||||
button.addEventListener("click", copyText);
|
||||
textarea.insertAdjacentElement("afterend", button);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (this.readyState == 4 && this.status != 200)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<div class="form-group w-100">
|
||||
<label for="thumb">{b_title}</label>
|
||||
<textarea id="thumb" readonly="readonly" rows="2" cols="40" class="form-control" tabindex="1">[url={b_url_link}][img]{b_img_link}[/img][/url]</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<!-- END image_thumb -->
|
||||
@@ -22,19 +21,16 @@
|
||||
<div class="form-group w-100">
|
||||
<label for="image1">{b_title}</label>
|
||||
<textarea id="image1" readonly="readonly" rows="1" cols="40" class="form-control" tabindex="2">{b_url_link}</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group w-100">
|
||||
<label for="imageBBC">{b_bbc_title}</label>
|
||||
<textarea id="imageBBC" readonly="readonly" rows="2" cols="40" class="form-control" tabindex="3">[url={siteurl}][img]{b_url_link}[/img][/url]</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group w-100">
|
||||
<label for="imageHTML">HTML</label>
|
||||
<textarea id="imageHTML" readonly="readonly" rows="4" cols="40" class="form-control" tabindex="4"><a href="{siteurl}" target="_blank" title="{siteurl}"><img src="{b_url_link}" border="0" alt="{b_url_link}" /></a></textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
<!-- END image -->
|
||||
|
||||
@@ -45,13 +41,11 @@
|
||||
<div class="form-group w-100">
|
||||
<label for="file1">{b_title}</label>
|
||||
<textarea id="file1" readonly="readonly" rows="2" cols="40" class="form-control" tabindex="5">{b_url_link}</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group w-100">
|
||||
<label for="fileBBC">{b_bbc_title}</label>
|
||||
<textarea id="fileBBC" readonly="readonly" rows="2" cols="40" class="form-control" tabindex="6">[url={b_url_link}]{b_url_link}[/url]</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<!-- END file -->
|
||||
@@ -64,7 +58,6 @@
|
||||
<div class="form-group w-100">
|
||||
<label for="delCode">{b_title}</label>
|
||||
<textarea id="delCode" readonly="readonly" rows="2" cols="40" class="form-control" tabindex="7">{b_code_link}</textarea>
|
||||
<button type="button" class="btn btn-primary btn-sm mt-2" onclick="copyText(event)">Copy</button>
|
||||
</div>
|
||||
|
||||
<!-- END del_file_code -->
|
||||
|
||||
Reference in New Issue
Block a user