2024-02-25, 12:07 PM
2024-02-25, 01:10 PM
You can try using some code formatter like Prism which has this feature in-built.
2024-02-25, 01:12 PM
I did that on one of my forums.
In the mycode_code template (and also in mycode_php), add
In a css (I created one, you can do the same or add to global.css) added:
In the mycode_code template (and also in mycode_php), add
<button class="copy">copy</button>
just after {$lang->code}
In a css (I created one, you can do the same or add to global.css) added:
.copy {
float: right;
font-variant: small-caps;
color: green;
}
Then, add a js file containing:$('.codeblock').find('.title').find('button').click(function() {
blk = $(this).parent();
$('.codeblock').each(function(i) {
$(this).find('.title').find('button').css('color', 'green');
});
var range = document.createRange();
var code = blk.next('.body')[0];
range.selectNodeContents(code);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
blk.find('button').css('color', 'blue');
})
and load it in footer template2024-02-25, 02:02 PM
"Then, add a js file containing:"
shall I create a js file and place it in the jscprits folder?
shall I create a js file and place it in the jscprits folder?
2024-02-25, 03:04 PM
Yes, js files must be uploaded, they can't be write from the ACP
2024-02-25, 03:11 PM
Thank you very much for your help. I succeeded and it works perfectly!
+1
+1
2024-02-27, 02:44 AM