Splunk Search

Overriding popup.js

werz
New Member

Where do I need to place a copy of the popup.js script in order to override it? Is it even possible?

I have tried placing a copy in my applications appserver/static folder, but none of changes I have tried making are showing up. For example, I tried adding an alert to the Splunk.Popup.SchedulePDF() function, but after restarting splunk and refreshing my page, clicking the button still has it's default behavior.

Thanks for any help!

Tags (3)
0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

Simply placing a file named popup.js won't have any effect. What you have to do is have some JS file that will by itself get included in the page redeclare the relevant Popup function or class or classes.

I know this can be done reliably because I've been doing it in Sideview Utils for a while now.

In the specific case of overriding a utility function like Splunk.Popup.SchedulePDF(), it should be pretty simple. Since application.js is loaded after popup.js I think you can simply provide your own declaration in application.js. Then at runtime when something calls Splunk.Popup.SchedulePDF, it will call your implementation and not the core one.

If and when you have to modify Module classes or Popup classes or some of the singletons, things get more complicated, and you have to pay attention to file load order and when things are actually constructed etc, but even then it's all pretty doable.

View solution in original post

0 Karma

sideview
SplunkTrust
SplunkTrust

Simply placing a file named popup.js won't have any effect. What you have to do is have some JS file that will by itself get included in the page redeclare the relevant Popup function or class or classes.

I know this can be done reliably because I've been doing it in Sideview Utils for a while now.

In the specific case of overriding a utility function like Splunk.Popup.SchedulePDF(), it should be pretty simple. Since application.js is loaded after popup.js I think you can simply provide your own declaration in application.js. Then at runtime when something calls Splunk.Popup.SchedulePDF, it will call your implementation and not the core one.

If and when you have to modify Module classes or Popup classes or some of the singletons, things get more complicated, and you have to pay attention to file load order and when things are actually constructed etc, but even then it's all pretty doable.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...