You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
688 B

(exports => {
'use strict';
exports.debounce = (func, wait, immediate) => {
let timeout;
return function (...args) {
const later = () => {
timeout = null;
if (!immediate) {
func.apply(this, args);
}
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(this, args);
}
};
};
exports.copyToClipboard = value => {
const $textArea = $('<textarea>').css({
opacity: 0,
position: 'fixed'
}).appendTo('body').val(value);
$textArea.select();
const success = document.execCommand('copy');
$textArea.remove();
return success;
};
})(window.utils = {});