mirror of
https://www.gitlink.org.cn/mayx/mayx.gitlink.net
synced 2026-05-24 12:43:55 +00:00
Update 5 files
- /_layouts/default.html - /_data/proxylist.yml - /assets/js/main.js - /assets/js/pjax.js - /assets/js/main_new.js
This commit is contained in:
parent
1a529143a8
commit
481df19596
5 changed files with 35 additions and 88 deletions
|
|
@ -43,35 +43,21 @@ $(function () {
|
|||
});
|
||||
});
|
||||
|
||||
$(function() {
|
||||
var $codeBlocks = $('div.highlight');
|
||||
|
||||
$codeBlocks.each(function() {
|
||||
var $copyButton = $('<button>', {
|
||||
class: 'copy',
|
||||
type: 'button',
|
||||
text: '📋'
|
||||
});
|
||||
|
||||
$(this).append($copyButton);
|
||||
|
||||
$copyButton.on('click', function() {
|
||||
var code = $(this).siblings('pre').find('code').text().trim();
|
||||
var $button = $(this);
|
||||
|
||||
function initCopyButtons() {
|
||||
$('.copy').remove();
|
||||
$('div.highlight').each(function () {
|
||||
var $btn = $('<button>', { class: 'copy', type: 'button', text: '📋' });
|
||||
$(this).append($btn);
|
||||
$btn.on('click', function () {
|
||||
var code = $btn.siblings('pre').find('code').text().trim();
|
||||
navigator.clipboard.writeText(code)
|
||||
.then(function() {
|
||||
$button.text('✅');
|
||||
})
|
||||
.catch(function(err) {
|
||||
$button.text('❌');
|
||||
console.error('复制失败:', err);
|
||||
})
|
||||
.finally(function() {
|
||||
setTimeout(function() {
|
||||
$button.text('📋');
|
||||
}, 1500);
|
||||
});
|
||||
.then(function () { $btn.text('✅'); })
|
||||
.catch(function () { $btn.text('❌'); })
|
||||
.finally(function () { setTimeout(function () { $btn.text('📋'); }, 1500); });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
initCopyButtons();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue