.json file - help with <a> tag in text field

I’ve used HTML anchors [tt][/tt] quite successfully in a number of plugin .json files, but I’m having a specific problem with crafting the right static .json file syntax for a link which references port 3480…

Plain URL references to ‘self’ work just fine:

"text": "<a href='/dashboard.html' target='_blank'>Dashboard</a>"

…will link to the file in [tt]/www/dashboard.html[/tt] just fine.

However, I have a plugin which registers a Luup HTML handler in the usual way, say:

luup.register_handler ("HTTP_MyHandler", "dashboard")

…and thus needs to be invoked with a URL of the form [tt]http://10.0.0.2:3480/data_request?id=lr_dashboard[/tt].

I think this also works fine if the .json file specifies a specific URL:

"text": "<a href='10.0.0.2:3480/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

BUT, I don’t want to hardwire the IP Vera address (since this is supposed to be installable on any machine) and would like to use something like:

"text": "<a href='127.0.0.1:3480/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

But it doesn’t work. Neither does:

"text": "<a href='/port_3480/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

The only thing I can think of (which is horrible) is to have a standard URL link to a file which the app writes to /www/ containing a redirect with the specific IP address and port 3480.

There must be a better way … ? (Frankly, I know very little about HTML and am probably being very stupid)

"text": "<a href='127.0.0.1:3480/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

This will not work because it sends the request to the Device (PC, Laptop, Mobile) that is running the browser.

"text": "<a href='/port_3480/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

This should work locally (I do not thing it will work remotely).
If not you might try just:

"text": "<a href='/data_request?id=lr_dashboard' target='_blank'>Dashboard</a>"

It might be that the base URL for this context already has port 3480 set.
You can find this out if you are handy with the JavaScript InSpector/Debugger.

You might want to review the ALTUI implementation.

If I understand what I see correctly, I think this means using JS, which is something I normally eschew. I had hoped to do this with HTML, pure and simple. Sigh.

Why cant you do you HTML in your .JS file…
here is how I did it

[code]var iKettle = (function(api){
return {
about: function() {
try {
var html = ‘

How this plugin works:

iKettle

 

Boil:  Boils Kettle with whatever settings are set on the Kettle

Off: Cancels current function

5/10/20 Mins: This will start boiling the kettle and keep it warm for the length chosen.

65/95/100 Deg: This will start the boiling of the kettle to that temperature.

’;
api.setCpanelContent(html);
} catch (e) {
Utils.logError('Error in MyPlugin.about(): ’ + e);
}
}

};

})(api);[/code]