Skip to content

Commit

Permalink
بهبود فرایند کپی کلید
Browse files Browse the repository at this point in the history
  • Loading branch information
ircfspace committed Apr 16, 2024
1 parent 2db7b22 commit 751c4da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
function copyToClipboard(text) {
function copyToClipboard(text, key) {
navigator.clipboard.writeText(text).then(() => {
alert("کلید کپی شد!");
$('button[data-key="'+key+'"]').html('✔️');
setTimeout(function() {
$('button[data-key="'+key+'"]').html('📋');
}, 2500)
}).catch(() => {
//
});
Expand All @@ -11,21 +14,25 @@ function renderData(dataArray) {
if (typeof dataArray === "undefined" || dataArray.length < 1) {
return false;
}
let x = 1;
dataArray.forEach(function(element) {
if ( element !== "" ) {
html += '<div class="input-group">';
html += '<input type="text" class="form-control" placeholder="Key" readonly value="'+element+'" />';
html += '<div class="input-group-btn">';
html += '<button class="btn btn-default" onclick="copyToClipboard(\'' + element + '\')">';
html += '<button class="btn btn-default" onclick="copyToClipboard(\'' + element + '\', \'' + x + '\')" data-key="'+x+'">';
html += '📋';
html += '</button>';
html += '</div>';
html += '</div>';
x++;
}
});
html += '<div class="clearfix"></div>';
html += '<a class="btn btn-warning btn-block" href="https://raw.githubusercontent.com/ircfspace/warpkey/main/plus/full" dir="rtl" target="_blank">کلیدهای بیشتر ...</a>';
$('#setContent').html(html);
let loadMore = '<div class="clearfix"></div>';
loadMore += '<a class="btn btn-warning btn-block" href="https://raw.githubusercontent.com/ircfspace/warpkey/main/plus/full" dir="rtl" target="_blank">';
loadMore += 'کلیدهای بیشتر ...';
loadMore += '</a>';
$('#setContent').html(html+loadMore);
}

window.addEventListener('load', function() {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h4 class="modal-title">دونیت</h4>
</div>
<script src="./assets/js/jquery.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/script.js?v1.0.1"></script>
<script src="./assets/js/script.js?v1.1"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</footer>
</div>
Expand Down

0 comments on commit 751c4da

Please sign in to comment.