Skip to content

Commit

Permalink
fix: Update copy button behavior in custom.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jmservera committed May 23, 2024
1 parent 2c288d1 commit a93f83a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
18 changes: 3 additions & 15 deletions web/_layouts/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,14 @@
$(this).parent().prepend(button);
});

var message = $('<div>').attr('id', 'copy-message').text('Text copied to clipboard').hide();
$('body').append(message);

$('.copy-button').click(function() {
let btn = $(this);
var code = $(this).siblings('code').text();
var position = $(this).offset();

navigator.clipboard.writeText(code).then(function() {
// Get the position of the button

// Set the position of the message
$('#copy-message').css({
top: position.top + 'px',
left: (position.left - $('#copy-message').width()) + 'px'
});
// Show the message
$('#copy-message').fadeIn('slow', function() {
// Hide the message after 800 ms
$(this).delay(800).fadeOut('slow');
});
btn.text('✅');
setTimeout(()=>btn.text('📋'),1800);
}, function() {
// failure
alert('Failed to copy text');
Expand Down
2 changes: 1 addition & 1 deletion web/_site/feed.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2024-05-23T18:57:36+02:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">Demos and labs</title><subtitle>Demos of tools and Azure services.</subtitle></feed>
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2024-05-23T19:18:55+02:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">Demos and labs</title><subtitle>Demos of tools and Azure services.</subtitle></feed>
18 changes: 3 additions & 15 deletions web/_site/prompt-engineering.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,26 +523,14 @@ <h2 id="some-more-example-prompts">Some more example prompts</h2>
$(this).parent().prepend(button);
});

var message = $('<div>').attr('id', 'copy-message').text('Text copied to clipboard').hide();
$('body').append(message);

$('.copy-button').click(function() {
let btn = $(this);
var code = $(this).siblings('code').text();
var position = $(this).offset();

navigator.clipboard.writeText(code).then(function() {
// Get the position of the button

// Set the position of the message
$('#copy-message').css({
top: position.top + 'px',
left: (position.left - $('#copy-message').width()) + 'px'
});
// Show the message
$('#copy-message').fadeIn('slow', function() {
// Hide the message after 800 ms
$(this).delay(800).fadeOut('slow');
});
btn.text('✅');
setTimeout(()=>btn.text('📋'),1800);
}, function() {
// failure
alert('Failed to copy text');
Expand Down

0 comments on commit a93f83a

Please sign in to comment.