diff --git a/app/assets/javascripts/foreman_virt_who_configure/config_copy_and_paste.js b/app/assets/javascripts/foreman_virt_who_configure/config_copy_and_paste.js index 7a7ff13..a72cd06 100644 --- a/app/assets/javascripts/foreman_virt_who_configure/config_copy_and_paste.js +++ b/app/assets/javascripts/foreman_virt_who_configure/config_copy_and_paste.js @@ -1,8 +1,10 @@ function virt_who_copy_configuration_to_clipboard(text) { - var aux = document.createElement("textarea"); - $(aux).html(text); - document.body.appendChild(aux); - aux.select(); - document.execCommand("copy"); - document.body.removeChild(aux); + try { + navigator.clipboard.writeText(text); + } catch (error) { + console.error( + "Copying to clipboard is not supported in this browser, or in unsecure connection." + ); + console.error(error); + } } diff --git a/app/assets/javascripts/foreman_virt_who_configure/config_edit.js b/app/assets/javascripts/foreman_virt_who_configure/config_edit.js index d59c6fb..74a4892 100644 --- a/app/assets/javascripts/foreman_virt_who_configure/config_edit.js +++ b/app/assets/javascripts/foreman_virt_who_configure/config_edit.js @@ -82,7 +82,13 @@ $(document).ready(function () { virt_who_update_hypervisor_fields(); virt_who_update_ahv_debug(); - $('#foreman_virt_who_configure_config_listing_mode').change(virt_who_update_listing_mode); - $('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_credentials_help); - $('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_hypervisor_fields); + $("#foreman_virt_who_configure_config_listing_mode").on("change", virt_who_update_listing_mode); + $("#foreman_virt_who_configure_config_hypervisor_type").on( + "change", + virt_who_update_credentials_help + ); + $("#foreman_virt_who_configure_config_hypervisor_type").on( + "change", + virt_who_update_hypervisor_fields + ); }); diff --git a/app/views/foreman_virt_who_configure/configs/show.html.erb b/app/views/foreman_virt_who_configure/configs/show.html.erb index 76ca044..8366ac6 100644 --- a/app/views/foreman_virt_who_configure/configs/show.html.erb +++ b/app/views/foreman_virt_who_configure/configs/show.html.erb @@ -79,7 +79,7 @@
- <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html()); return false' %> + <%= link_to _('Copy to clipboard'), '#', :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html()); return false' %>
@@ -103,7 +103,7 @@
- <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html()); return false' %> + <%= link_to _('Copy to clipboard'), '#', :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html()); return false' %> <%= link_to _('Download the script'), deploy_script_foreman_virt_who_configure_config_path(@config), :class => 'btn btn-default' %>