NagVIS Javascript in Custom Context Menu

nagvis
customization
(Ash) #1

Hi All,

I’m trying to add a JavaScript function to a custom NagVIS context menu. Essentially i’m trying to add a function that copies a hosts IP Address to the clipboard from the context menu like below.

PING

In the HTML file this option calls the below code.

<li><a href="#" onclick="copyToClipboard('[address]');contextHide();return false">Copy IP</a></li>

Where the “copyToClipboard” function is defined in the “nagvis.js” file as below.

function copyToClipboard(element) {
var $temp = $("");
$(“body”).append($temp);
$temp.val($(element).text()).select();
document.execCommand(“copy”);
$temp.remove();
}

However anytime I click the “Copy IP” option I get the Error bellow.

Javascript error occured: Uncaught ReferenceError: copyToClipboard is not defined http://server/nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=map (1)

Any ideas how I can get NagVis to define this function correctly?

Thanks in advance,
Ash