mirror of
https://github.com/Mabbs/mabbs.github.io
synced 2026-06-30 17:52:40 -03:00
7943cc7d6a
- /_data/other_repo_list.csv - /index.html - /_posts/2026-07-01-vibe-coding.md - /assets/js/main_new.js - /assets/js/main.js
18 lines
645 B
JavaScript
18 lines
645 B
JavaScript
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 () { $btn.text('✅'); })
|
|
.catch(function () { $btn.text('❌'); })
|
|
.finally(function () { setTimeout(function () { $btn.text('📋'); }, 1500); });
|
|
});
|
|
});
|
|
}
|
|
|
|
$(function () {
|
|
initCopyButtons();
|
|
}); |