(function($){
    $(document).on('click','[data-st-type="copy-to-clipboard"]', function(){
        if($(this).data('st-copy-target').length > 0) {
            const tmp = $(this).html();
            $(this).attr('disabled',true);
            $(this).html('Copying...');
            const targetInputId =  $(this).data('st-copy-target');
            const stringToCopy = $(targetInputId).val();
            
            // logic for copy to clipboard
            var tempInput = $("<input>");
            $("body").append(tempInput);
            tempInput.val(stringToCopy).select();
            document.execCommand("copy");
            $(this).html('Copied');
            tempInput.remove();
            
            setTimeout(() => {
                $(this).html(tmp);
                $(this).attr('disabled',false);
            },1000);


            
        }
    });
})(jQuery);