Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
− | + | $(document).ready(function() { | |
− | function | + | $(document).on('click', '.warp-copy', function() { |
− | + | var textToCopy = $(this).attr('data-copy'); | |
− | + | ||
− | + | var tempInput = document.createElement('textarea'); | |
− | + | tempInput.value = textToCopy; | |
− | + | document.body.appendChild(tempInput); | |
− | + | tempInput.select(); | |
− | + | document.execCommand('copy'); | |
− | + | document.body.removeChild(tempInput); | |
− | + | ||
− | + | var originalColor = $(this).css('color'); | |
− | + | $(this).css('color', 'green'); | |
− | + | var self = this; | |
− | + | setTimeout(function() { | |
− | + | $(self).css('color', originalColor); | |
− | + | }, 500); | |
− | + | }); | |
− | |||
− | |||
− | |||
}); | }); |
Revision as of 12:16, 11 April 2025
/* Any JavaScript here will be loaded for all users on every page load. */ $(document).ready(function() { $(document).on('click', '.warp-copy', function() { var textToCopy = $(this).attr('data-copy'); var tempInput = document.createElement('textarea'); tempInput.value = textToCopy; document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); var originalColor = $(this).css('color'); $(this).css('color', 'green'); var self = this; setTimeout(function() { $(self).css('color', originalColor); }, 500); }); });