<?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: real time,  timer/counter in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440046#M42465</link>
    <description>&lt;P&gt;That's not really the type of function Splunk offers. &lt;BR /&gt;
Whilst I'm not saying that this can't be done, you probably shouldn't.&lt;/P&gt;

&lt;P&gt;What's your use case?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2019 09:51:25 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2019-03-14T09:51:25Z</dc:date>
    <item>
      <title>real time,  timer/counter</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440045#M42464</link>
      <description>&lt;P&gt;hello! Good afternoon, &lt;/P&gt;

&lt;P&gt;i want to create a timer, wherein when I push the switch to turn on the green light, the timer starts and then stops after when the switch is turned off . then when I turn it on again, the timer should reset again to zero,  and start a new timer . is this possible?&lt;/P&gt;

&lt;P&gt;thank you so much! &lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 09:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440045#M42464</guid>
      <dc:creator>mdmaala</dc:creator>
      <dc:date>2019-03-14T09:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: real time,  timer/counter</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440046#M42465</link>
      <description>&lt;P&gt;That's not really the type of function Splunk offers. &lt;BR /&gt;
Whilst I'm not saying that this can't be done, you probably shouldn't.&lt;/P&gt;

&lt;P&gt;What's your use case?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 09:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440046#M42465</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2019-03-14T09:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: real time,  timer/counter</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440047#M42466</link>
      <description>&lt;P&gt;@mdmaala,&lt;/P&gt;

&lt;P&gt;You can achieve this by using Javascript and CSS in your dashboard.&lt;/P&gt;

&lt;P&gt;Check below dashboard code.&lt;BR /&gt;
timer.xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="timer.js" stylesheet="timer.css"&amp;gt;
  &amp;lt;label&amp;gt;Timer&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;h2&amp;gt;Toggle Switch&amp;lt;/h2&amp;gt;

        &amp;lt;label class="switch"&amp;gt;
          &amp;lt;input type="checkbox" /&amp;gt;
          &amp;lt;span class="slider round"&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;/label&amp;gt;
        &amp;lt;div id="divCount" style="height: 1.5em; font-size: 2em; color: red;"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;timer.js&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function($, mvc) {

    var count = 0;
    function Increament() {
        count++;
        console.log(count);
        document.getElementById("divCount").innerHTML = "Timer: "+count;
    }
    var myVar;

    $(document).ready(function () {
        var checkbox = document.querySelector('input[type="checkbox"]');

        checkbox.addEventListener('change', function () {
            if (checkbox.checked) {
              // do this
              console.log('Checked');
              myVar = setInterval(Increament, 1000);
            } else {
              // do that
              console.log('Not checked');
               clearInterval(myVar);
               count = 0;
               document.getElementById("divCount").innerHTML = "Timer: "+count;
            }
          });

    });


});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;timer.css&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try and let me know if any issue.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 11:11:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440047#M42466</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-03-14T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: real time,  timer/counter</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440048#M42467</link>
      <description>&lt;P&gt;thank u so much @kamlesh_vaghela , i'll try and i'll get back to let you know if this worked. thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 02:13:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/real-time-timer-counter/m-p/440048#M42467</guid>
      <dc:creator>mdmaala</dc:creator>
      <dc:date>2019-03-15T02:13:44Z</dc:date>
    </item>
  </channel>
</rss>

