<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to copy text and tokens values getting populated inside textarea  to the clipboard while clicking on copy button in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-copy-text-and-tokens-values-getting-populated-inside/m-p/534968#M36479</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Can someone please help me around here. That would be highly appreciable.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jan 2021 15:30:00 GMT</pubDate>
    <dc:creator>tarunmalhotra79</dc:creator>
    <dc:date>2021-01-06T15:30:00Z</dc:date>
    <item>
      <title>How to copy text and tokens values getting populated inside textarea  to the clipboard while clicking on copy button ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-copy-text-and-tokens-values-getting-populated-inside/m-p/534668#M36459</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;&lt;P&gt;I am trying to copy the whole text inside textarea to the clipboard when user clicks on a button. I tried implementing suggestions from stackoverflow but nothing worked.&lt;/P&gt;&lt;P&gt;It looks like may be i have hardcoded some text and also using run time token which might be causing issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;panel id="Os_details"&amp;gt;
      &amp;lt;html&amp;gt;
				&amp;lt;div&amp;gt;
					&amp;lt;label&amp;gt;Paste the following in your alerting search&amp;lt;/label&amp;gt;
					&amp;lt;button id="clipboard"&amp;gt;Copy to Clipboard&amp;lt;/button&amp;gt;
					&amp;lt;textarea name="generateSearchWindow" rows="25" readonly="true" style="width:98%;margin-top:12px;color:black; text-align: left;"&amp;gt;
$MainSearch$
| eval p_os = "$os_change_tok$"
| eval p_alert_class = "$alert_class_change_tok$" 
| eval p_monitoring_type = "$monitoring_type_change_tok$"
| eval p_monitoring_component = $monitoringComponent$
| eval p_hostname = "$hostnamePattern$" 
| eval search_name = "$searchName$" 
| eval unique_id=p_os + ":" + p_alert_class + ":" + p_monitoring_type + ":" + p_monitoring_component + ":" + p_hostname  
| fields - _raw
| collect index=Test_monitoring_test addtime=false report_name="Test_EE_$searchName$_default" 
          &amp;lt;/textarea&amp;gt;
				&amp;lt;/div&amp;gt;
			&amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JS Used:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  'underscore',
  'jquery',
  'backbone',
  'splunkjs/mvc',
  'splunkjs/mvc/searchmanager',
  'splunkjs/mvc/simplexml/ready!'
], function(_, $, Backbone, mvc,SearchManager) {
  //Find your input control and associate tool tip attribute for it. Here data-placement represents the position of tool tip(top,bottom,right,left,auto)
  $('#textbox1').find('input').attr('title', 'Hovering Example to be added').attr('data-toggle', 'tooltip').attr('data-placement', 'bottom');
  $('#monitoringComponent').find('div').attr('title', 'TextArea example').attr('data-toggle', 'tooltip').attr('data-placement', 'bottom');
  $('[data-toggle="tooltip"]').tooltip();
   // Iitialize Default and Submitted Token Model.
                var defaultTokenModel = mvc.Components.get("default");
        var submittedTokenModel = mvc.Components.get("submitted");
        $("#ValidateButton").click(function()
                {
            defaultTokenModel.set("show_details","true");
            submittedTokenModel.set("show_details","true");
        });

    var defaultTokenSpace = mvc.Components.getInstance('default');
                $('textarea').parent().parent().addClass('textarea_div');
                $('textarea').each(function (ta) {
                $(this).on('input', function(input) {
                defaultTokenSpace.set($(this).attr('id').replace('ta_' ,'') ,$(this).val());
    });
  });
   document.getElementById("clipboard").onclick = function() {
  var copyTextarea = document.createElement("textarea");
  copyTextarea.style.position = "fixed";
  copyTextarea.style.opacity = "0";
  copyTextarea.textContent = document.getElementById("generateSearchWindow").value;

  document.body.appendChild(copyTextarea);
  copyTextarea.select();
  document.execCommand("copy");
  document.body.removeChild(copyTextarea);
}

});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly help me, what am I missing please or where should i focus more. It would be highly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 10:01:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-copy-text-and-tokens-values-getting-populated-inside/m-p/534668#M36459</guid>
      <dc:creator>tarunmalhotra79</dc:creator>
      <dc:date>2021-01-04T10:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy text and tokens values getting populated inside textarea  to the clipboard while clicking on copy button</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-copy-text-and-tokens-values-getting-populated-inside/m-p/534968#M36479</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Can someone please help me around here. That would be highly appreciable.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 15:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-copy-text-and-tokens-values-getting-populated-inside/m-p/534968#M36479</guid>
      <dc:creator>tarunmalhotra79</dc:creator>
      <dc:date>2021-01-06T15:30:00Z</dc:date>
    </item>
  </channel>
</rss>

