Files
blog/assets/js/main_new.js
T

18 lines
645 B
JavaScript
Raw Normal View History

2026-05-23 10:06:55 +00:00
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();
2025-06-19 08:51:38 +00:00
navigator.clipboard.writeText(code)
2026-05-23 10:06:55 +00:00
.then(function () { $btn.text('✅'); })
.catch(function () { $btn.text('❌'); })
.finally(function () { setTimeout(function () { $btn.text('📋'); }, 1500); });
2025-05-11 16:12:22 +00:00
});
});
2026-05-23 10:06:55 +00:00
}
2026-05-27 02:37:23 +00:00
$(function () {
2026-05-23 10:06:55 +00:00
initCopyButtons();
2025-05-11 16:12:22 +00:00
});