<?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: What to import (require) in my custom JavaScript to avoid error &amp;quot;Uncaught reference: Splunk is not defined&amp;quot;? in Security</title>
    <link>https://community.splunk.com/t5/Security/What-to-import-require-in-my-custom-JavaScript-to-avoid-error/m-p/157999#M4735</link>
    <description>&lt;P&gt;OK, I decided to look at other apps. I took a look at &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/appserver/static/status_dashboard.js&lt;/CODE&gt; and went on to mimic the approach.&lt;BR /&gt;
Here is what I have in my dashboard.js right now - hides &lt;STRONG&gt;Settings&lt;/STRONG&gt;, &lt;STRONG&gt;Activity&lt;/STRONG&gt; and &lt;STRONG&gt;Help&lt;/STRONG&gt; dropdowns in the navigation bar from all users but &lt;EM&gt;admin&lt;/EM&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var allowedUsers = ["admin"];
require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function(){
 if (allowedUsers.indexOf(Splunk.util.getConfigValue("USERNAME")) ==-1) {
    $(document).ready(function() {
        var x = document.createElement("STYLE");
        var t = document.createTextNode(".shared-splunkbar-activitymenu{display:none !important;}.shared-splunkbar-systemmenu{display:none !important;}.shared-splunkbar-helpmenu{display:none !important}");
        x.appendChild(t);
        document.head.appendChild(x);
    });
}});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I still don't know which of the splunkjs/mvc and splunkjs/mvc/simplexml/ready! is responsible for defining that Splunk object, but it's working for me now.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Feb 2015 14:04:20 GMT</pubDate>
    <dc:creator>arkadyz1</dc:creator>
    <dc:date>2015-02-24T14:04:20Z</dc:date>
    <item>
      <title>What to import (require) in my custom JavaScript to avoid error "Uncaught reference: Splunk is not defined"?</title>
      <link>https://community.splunk.com/t5/Security/What-to-import-require-in-my-custom-JavaScript-to-avoid-error/m-p/157998#M4734</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I'm trying to customize my page depending on the user. I found an example (hiding the navbar selectively - needed something else but wanted to start somewhere) with this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;// show the jobs and alerts links for the given usernames.
 var allowedUsers = ["admin"];
 if (allowedUsers.indexOf(Splunk.util.getConfigValue("USERNAME")) !=-1) {
     $(".navbar").show();
     // $(".AccountBar .job_manager_opener").show();
 } 
 //otherwise finish the job started by the css, and hide the little divider
 //lines too. 
 else {
     $(".navbar").parent().next().hide();
     // $(".AccountBar .job_manager_opener").parent().next().hide();
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately, this code fails with "Uncaught reference: Splunk is not defined" message. What should I add to my script to define it? The script is in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/myapp/appserver/static&lt;/CODE&gt;. I'm using Splunk 6.2.1.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2015 20:27:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/What-to-import-require-in-my-custom-JavaScript-to-avoid-error/m-p/157998#M4734</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2015-02-23T20:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: What to import (require) in my custom JavaScript to avoid error "Uncaught reference: Splunk is not defined"?</title>
      <link>https://community.splunk.com/t5/Security/What-to-import-require-in-my-custom-JavaScript-to-avoid-error/m-p/157999#M4735</link>
      <description>&lt;P&gt;OK, I decided to look at other apps. I took a look at &lt;CODE&gt;$SPLUNK_HOME/etc/apps/search/appserver/static/status_dashboard.js&lt;/CODE&gt; and went on to mimic the approach.&lt;BR /&gt;
Here is what I have in my dashboard.js right now - hides &lt;STRONG&gt;Settings&lt;/STRONG&gt;, &lt;STRONG&gt;Activity&lt;/STRONG&gt; and &lt;STRONG&gt;Help&lt;/STRONG&gt; dropdowns in the navigation bar from all users but &lt;EM&gt;admin&lt;/EM&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var allowedUsers = ["admin"];
require(["jquery", "splunkjs/mvc", "splunkjs/mvc/simplexml/ready!"], function(){
 if (allowedUsers.indexOf(Splunk.util.getConfigValue("USERNAME")) ==-1) {
    $(document).ready(function() {
        var x = document.createElement("STYLE");
        var t = document.createTextNode(".shared-splunkbar-activitymenu{display:none !important;}.shared-splunkbar-systemmenu{display:none !important;}.shared-splunkbar-helpmenu{display:none !important}");
        x.appendChild(t);
        document.head.appendChild(x);
    });
}});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I still don't know which of the splunkjs/mvc and splunkjs/mvc/simplexml/ready! is responsible for defining that Splunk object, but it's working for me now.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2015 14:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/What-to-import-require-in-my-custom-JavaScript-to-avoid-error/m-p/157999#M4735</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2015-02-24T14:04:20Z</dc:date>
    </item>
  </channel>
</rss>

